diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-07-06 15:54:49 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-07-06 16:32:35 +0000 |
| commit | 384432d31e7bee6bf35d8af6b7165410303ffda4 (patch) | |
| tree | ddb845aa8dacbf00151ee3fda8a233d0620d6ab1 /apps/web/components | |
| parent | 47624547f8cb352426d597537c11e7a4550aa91e (diff) | |
| download | karakeep-384432d31e7bee6bf35d8af6b7165410303ffda4.tar.zst | |
feat: Add per user storage quota
Diffstat (limited to 'apps/web/components')
| -rw-r--r-- | apps/web/components/admin/UpdateUserDialog.tsx | 26 | ||||
| -rw-r--r-- | apps/web/components/admin/UserList.tsx | 7 |
2 files changed, 33 insertions, 0 deletions
diff --git a/apps/web/components/admin/UpdateUserDialog.tsx b/apps/web/components/admin/UpdateUserDialog.tsx index 82a239ca..7093ccda 100644 --- a/apps/web/components/admin/UpdateUserDialog.tsx +++ b/apps/web/components/admin/UpdateUserDialog.tsx @@ -41,12 +41,14 @@ interface UpdateUserDialogProps { userId: string; currentRole: "user" | "admin"; currentQuota: number | null; + currentStorageQuota: number | null; children?: React.ReactNode; } export default function UpdateUserDialog({ userId, currentRole, currentQuota, + currentStorageQuota, children, }: UpdateUserDialogProps) { const apiUtils = api.useUtils(); @@ -55,6 +57,7 @@ export default function UpdateUserDialog({ userId, role: currentRole, bookmarkQuota: currentQuota, + storageQuota: currentStorageQuota, }; const form = useForm<UpdateUserSchema>({ resolver: zodResolver(updateUserSchema), @@ -149,6 +152,29 @@ export default function UpdateUserDialog({ /> <FormField control={form.control} + name="storageQuota" + render={({ field }) => ( + <FormItem> + <FormLabel>Storage Quota (bytes)</FormLabel> + <FormControl> + <Input + type="number" + min="0" + placeholder="Unlimited (leave empty)" + {...field} + value={field.value ?? ""} + onChange={(e) => { + const value = e.target.value; + field.onChange(value === "" ? null : parseInt(value)); + }} + /> + </FormControl> + <FormMessage /> + </FormItem> + )} + /> + <FormField + control={form.control} name="userId" render={({ field }) => ( <FormItem> diff --git a/apps/web/components/admin/UserList.tsx b/apps/web/components/admin/UserList.tsx index a3b4d94f..2dd86277 100644 --- a/apps/web/components/admin/UserList.tsx +++ b/apps/web/components/admin/UserList.tsx @@ -72,6 +72,7 @@ export default function UsersSection() { <TableHead>{t("common.email")}</TableHead> <TableHead>{t("admin.users_list.num_bookmarks")}</TableHead> <TableHead>{t("common.quota")}</TableHead> + <TableHead>Storage Quota</TableHead> <TableHead>{t("admin.users_list.asset_sizes")}</TableHead> <TableHead>{t("common.role")}</TableHead> <TableHead>{t("admin.users_list.local_user")}</TableHead> @@ -89,6 +90,11 @@ export default function UsersSection() { {u.bookmarkQuota ?? t("admin.users_list.unlimited")} </TableCell> <TableCell className="py-1"> + {u.storageQuota + ? toHumanReadableSize(u.storageQuota) + : t("admin.users_list.unlimited")} + </TableCell> + <TableCell className="py-1"> {toHumanReadableSize(userStats[u.id].assetSizes)} </TableCell> <TableCell className="py-1"> @@ -140,6 +146,7 @@ export default function UsersSection() { userId={u.id} currentRole={u.role!} currentQuota={u.bookmarkQuota} + currentStorageQuota={u.storageQuota} > <ButtonWithTooltip tooltip="Edit User" |
