Formatting and added migration

This commit is contained in:
SwiftyOS
2024-11-07 18:32:44 +01:00
parent deee943c3a
commit ff0e786202
7 changed files with 53 additions and 87 deletions

View File

@@ -1,4 +1,3 @@
from re import _FlagsType
import fastapi
import fastapi.responses
import pydantic

View File

@@ -1,12 +1,6 @@
-- CreateEnum
CREATE TYPE "UserGroupRole" AS ENUM ('MEMBER', 'OWNER');
-- CreateEnum
CREATE TYPE "SubmissionStatus" AS ENUM ('DAFT', 'PENDING', 'APPROVED', 'REJECTED');
-- AlterTable
ALTER TABLE "AgentGraph" ADD COLUMN "groupId" TEXT;
-- AlterTable
ALTER TABLE "AgentGraphExecution" ADD COLUMN "agentPresetId" TEXT;
@@ -22,30 +16,6 @@ ALTER TABLE "AnalyticsDetails" ALTER COLUMN "id" DROP DEFAULT;
-- AlterTable
ALTER TABLE "AnalyticsMetrics" ALTER COLUMN "id" DROP DEFAULT;
-- CreateTable
CREATE TABLE "UserGroup" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"name" TEXT NOT NULL,
"description" TEXT NOT NULL,
"groupIconUrl" TEXT,
CONSTRAINT "UserGroup_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "UserGroupMembership" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" TEXT NOT NULL,
"userGroupId" TEXT NOT NULL,
"Role" "UserGroupRole" NOT NULL DEFAULT 'MEMBER',
CONSTRAINT "UserGroupMembership_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "AgentPreset" (
"id" TEXT NOT NULL,
@@ -84,7 +54,6 @@ CREATE TABLE "Profile" (
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" TEXT,
"groupId" TEXT,
"username" TEXT NOT NULL,
"description" TEXT NOT NULL,
"links" TEXT[],
@@ -103,7 +72,6 @@ CREATE TABLE "StoreListing" (
"agentId" TEXT NOT NULL,
"agentVersion" INTEGER NOT NULL,
"owningUserId" TEXT NOT NULL,
"owningGroupId" TEXT,
CONSTRAINT "StoreListing_pkey" PRIMARY KEY ("id")
);
@@ -158,18 +126,6 @@ CREATE TABLE "StoreListingSubmission" (
CONSTRAINT "StoreListingSubmission_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "UserGroup_name_idx" ON "UserGroup"("name");
-- CreateIndex
CREATE INDEX "UserGroupMembership_userId_idx" ON "UserGroupMembership"("userId");
-- CreateIndex
CREATE INDEX "UserGroupMembership_userGroupId_idx" ON "UserGroupMembership"("userGroupId");
-- CreateIndex
CREATE UNIQUE INDEX "UserGroupMembership_userId_userGroupId_key" ON "UserGroupMembership"("userId", "userGroupId");
-- CreateIndex
CREATE INDEX "AgentPreset_userId_idx" ON "AgentPreset"("userId");
@@ -203,15 +159,6 @@ CREATE INDEX "StoreListingSubmission_storeListingId_idx" ON "StoreListingSubmiss
-- CreateIndex
CREATE INDEX "StoreListingSubmission_Status_idx" ON "StoreListingSubmission"("Status");
-- AddForeignKey
ALTER TABLE "UserGroupMembership" ADD CONSTRAINT "UserGroupMembership_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "UserGroupMembership" ADD CONSTRAINT "UserGroupMembership_userGroupId_fkey" FOREIGN KEY ("userGroupId") REFERENCES "UserGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "AgentGraph" ADD CONSTRAINT "AgentGraph_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "UserGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "AgentPreset" ADD CONSTRAINT "AgentPreset_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -239,18 +186,12 @@ ALTER TABLE "AgentGraphExecutionSchedule" ADD CONSTRAINT "AgentGraphExecutionSch
-- AddForeignKey
ALTER TABLE "Profile" ADD CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Profile" ADD CONSTRAINT "Profile_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "UserGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "StoreListing" ADD CONSTRAINT "StoreListing_agentId_agentVersion_fkey" FOREIGN KEY ("agentId", "agentVersion") REFERENCES "AgentGraph"("id", "version") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "StoreListing" ADD CONSTRAINT "StoreListing_owningUserId_fkey" FOREIGN KEY ("owningUserId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "StoreListing" ADD CONSTRAINT "StoreListing_owningGroupId_fkey" FOREIGN KEY ("owningGroupId") REFERENCES "UserGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "StoreListingVersion" ADD CONSTRAINT "StoreListingVersion_agentId_agentVersion_fkey" FOREIGN KEY ("agentId", "agentVersion") REFERENCES "AgentGraph"("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -143,7 +143,7 @@ export const Navbar: React.FC<NavbarProps> = ({
]}
userEmail={userEmail}
avatarSrc={avatarSrc}
className="z-50 fixed right-4 top-4"
className="fixed right-4 top-4 z-50"
/>
) : (
<Link

View File

@@ -17,7 +17,7 @@ export const Default: Story = {
email: "johndoe@email.com",
desktopNotifications: {
first: false,
second: true
}
}
second: true,
},
},
};

View File

@@ -10,39 +10,48 @@ interface SettingsInputFormProps {
};
}
export const SettingsInputForm = ({
export const SettingsInputForm = ({
email = "johndoe@email.com",
desktopNotifications = { first: false, second: true }
desktopNotifications = { first: false, second: true },
}: SettingsInputFormProps) => {
const [notifications, setNotifications] = React.useState(desktopNotifications);
const [notifications, setNotifications] =
React.useState(desktopNotifications);
const handleToggleFirst = () => {
setNotifications(prev => ({
setNotifications((prev) => ({
...prev,
first: !prev.first
first: !prev.first,
}));
};
const handleToggleSecond = () => {
setNotifications(prev => ({
setNotifications((prev) => ({
...prev,
second: !prev.second
second: !prev.second,
}));
};
return (
<div className="mx-auto w-full max-w-[1077px] px-4 pt-8 sm:px-6 sm:pt-16">
<h1 className="mb-8 text-2xl font-semibold sm:mb-16 sm:text-3xl">Settings</h1>
<h1 className="mb-8 text-2xl font-semibold sm:mb-16 sm:text-3xl">
Settings
</h1>
{/* My Account Section */}
<section aria-labelledby="account-heading">
<h2 id="account-heading" className="mb-8 text-lg font-medium text-neutral-500 sm:mb-12">
<h2
id="account-heading"
className="mb-8 text-lg font-medium text-neutral-500 sm:mb-12"
>
My account
</h2>
<div className="flex flex-col gap-7">
<div className="relative">
<div className="flex flex-col gap-1.5">
<label htmlFor="email-input" className="text-base font-medium text-slate-950">
<label
htmlFor="email-input"
className="text-base font-medium text-slate-950"
>
Email
</label>
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
@@ -70,7 +79,10 @@ export const SettingsInputForm = ({
<div className="relative">
<div className="flex flex-col gap-1.5">
<label htmlFor="password-input" className="text-base font-medium text-slate-950">
<label
htmlFor="password-input"
className="text-base font-medium text-slate-950"
>
Password
</label>
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
@@ -98,25 +110,35 @@ export const SettingsInputForm = ({
</div>
</section>
<div className="my-8 border-t border-neutral-200 sm:my-12" role="separator" />
<div
className="my-8 border-t border-neutral-200 sm:my-12"
role="separator"
/>
{/* Notifications Section */}
<section aria-labelledby="notifications-heading">
<h2 id="notifications-heading" className="mb-8 text-lg font-medium text-neutral-500 sm:mb-12">
<h2
id="notifications-heading"
className="mb-8 text-lg font-medium text-neutral-500 sm:mb-12"
>
Notifications
</h2>
<div className="flex flex-col gap-7">
<div className="flex flex-col gap-4 sm:flex-row">
<div className="w-full sm:w-[638px]">
<h3 id="desktop-notif-1" className="text-base font-medium text-slate-950">
<h3
id="desktop-notif-1"
className="text-base font-medium text-slate-950"
>
Enable desktop notifications
</h3>
<p className="mt-2 text-base text-neutral-600">
More detailed explanation for the notifications that this person is enabling
More detailed explanation for the notifications that this person
is enabling
</p>
</div>
<div className="flex h-[43px] items-center sm:ml-4 sm:w-[88px] sm:justify-center">
<Switch
<Switch
checked={notifications.first}
onCheckedChange={handleToggleFirst}
aria-labelledby="desktop-notif-1"
@@ -127,15 +149,19 @@ export const SettingsInputForm = ({
<div className="flex flex-col gap-4 sm:flex-row">
<div className="w-full sm:w-[638px]">
<h3 id="desktop-notif-2" className="text-base font-medium text-slate-950">
<h3
id="desktop-notif-2"
className="text-base font-medium text-slate-950"
>
Enable desktop notifications
</h3>
<p className="mt-2 text-base text-neutral-600">
More detailed explanation for the notifications that this person is enabling
More detailed explanation for the notifications that this person
is enabling
</p>
</div>
<div className="flex h-[43px] items-center sm:ml-4 sm:w-[88px] sm:justify-center">
<Switch
<Switch
checked={notifications.second}
onCheckedChange={handleToggleSecond}
aria-labelledby="desktop-notif-2"
@@ -147,4 +173,4 @@ export const SettingsInputForm = ({
</section>
</div>
);
};
};

View File

@@ -97,4 +97,4 @@ export const LoggedOut: Story = {
userName: "",
userEmail: "",
},
};
};

View File

@@ -55,4 +55,4 @@ export const SettingsPage: React.FC<SettingsPageProps> = ({
</div>
</div>
);
};
};