High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
refactor: user edit modal (#23169)
Jason Rasmussencb7e68a2870d
diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex be6b2974b0..cb7549022b 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -681,8 +681,8 @@ importers:specifier: file:../open-api/typescript-sdkversion: link:../open-api/typescript-sdk'@immich/ui':- specifier: ^0.36.0- version: 0.36.4(@internationalized/[email protected])([email protected])+ specifier: ^0.37.1+ version: 0.37.1(@internationalized/[email protected])([email protected])'@mapbox/mapbox-gl-rtl-text':specifier: 0.2.3version: 0.2.3([email protected])@@ -2726,8 +2726,8 @@ packages:cpu: [x64]os: [win32]- '@immich/[email protected]':- resolution: {integrity: sha512-urA7yD3ylKPqh6BhctvnpwZ1BZke75qaArRvnmUhjy5mV9Bud4D/yqbX5BlYq+Z3TvNP365BPLJDj7euG91gZw==}+ '@immich/[email protected]':+ resolution: {integrity: sha512-8S9KsyqyRcNgRHeBU8G3qMQ7D7fN4u9I31jjRc9c3s2tkiYucASofPJdcFdmGZnKLX5fIj+yofxiNZV9tVitOg==}peerDependencies:svelte: ^5.0.0@@ -14182,7 +14182,7 @@ snapshots:'@img/[email protected]':optional: truedependencies:'@mdi/js': 7.4.47bits-ui: 2.9.8(@internationalized/[email protected])([email protected])diff --git a/web/package.json b/web/package.jsonindex 1096f8a199..fad799813d 100644--- a/web/package.json+++ b/web/package.json@@ -27,7 +27,7 @@"dependencies": {"@formatjs/icu-messageformat-parser": "^2.9.8","@immich/sdk": "file:../open-api/typescript-sdk",- "@immich/ui": "^0.36.0",+ "@immich/ui": "^0.37.1","@mapbox/mapbox-gl-rtl-text": "0.2.3","@mdi/js": "^7.4.47","@photo-sphere-viewer/core": "^5.11.5",diff --git a/web/src/lib/modals/UserEditModal.svelte b/web/src/lib/modals/UserEditModal.svelteindex 26683c4bbb..657f6dee61 100644--- a/web/src/lib/modals/UserEditModal.svelte+++ b/web/src/lib/modals/UserEditModal.svelte@@ -5,7 +5,19 @@import { ByteUnit, convertFromBytes, convertToBytes } from '$lib/utils/byte-units';import { handleError } from '$lib/utils/handle-error';import { updateUserAdmin, type UserAdminResponseDto } from '@immich/sdk';- import { Button, Field, HStack, Input, Label, Link, Modal, ModalBody, ModalFooter, Switch, Text } from '@immich/ui';+ import {+ Button,+ Field,+ HStack,+ Input,+ Link,+ Modal,+ ModalBody,+ ModalFooter,+ NumberInput,+ Switch,+ Text,+ } from '@immich/ui';import { mdiAccountEditOutline } from '@mdi/js';import { t } from 'svelte-i18n';@@ -21,15 +33,19 @@let email = $derived(user.email);let storageLabel = $derived(user.storageLabel || '');- let quotaSize = $state(user.quotaSizeInBytes === null ? null : convertFromBytes(user.quotaSizeInBytes, ByteUnit.GiB));-const previousQuota = user.quotaSizeInBytes;+ let quotaSize = $state(+ typeof user.quotaSizeInBytes === 'number' ? convertFromBytes(user.quotaSizeInBytes, ByteUnit.GiB) : undefined,+ );++ const quotaSizeBytes = $derived(typeof quotaSize === 'number' ? convertToBytes(quotaSize, ByteUnit.GiB) : null);+let quotaSizeWarning = $derived(- previousQuota !== convertToBytes(Number(quotaSize), ByteUnit.GiB) &&- !!quotaSize &&+ previousQuota !== quotaSizeBytes &&+ !!quotaSizeBytes &&userInteraction.serverInfo &&- convertToBytes(Number(quotaSize), ByteUnit.GiB) > userInteraction.serverInfo.diskSizeRaw,+ quotaSizeBytes > userInteraction.serverInfo.diskSizeRaw,);const handleEditUser = async () => {@@ -40,7 +56,7 @@email,name,storageLabel,- quotaSizeInBytes: quotaSize === null ? null : convertToBytes(Number(quotaSize), ByteUnit.GiB),+ quotaSizeInBytes: typeof quotaSize === 'number' ? convertToBytes(quotaSize, ByteUnit.GiB) : null,isAdmin,},});@@ -68,22 +84,12 @@<Input bind:value={name} /></Field>- <div class="flex flex-col gap-1 mt-4">- <Label class="flex items-center gap-2" for="quotaSize">{$t('admin.quota_size_gib')}</Label>- <input- class="immich-form-input"- id="quotaSize"- name="quotaSize"- placeholder={$t('unlimited')}- type="number"- step="1"- min="0"- bind:value={quotaSize}- />+ <Field label={$t('admin.quota_size_gib')} class="mt-4">+ <NumberInput bind:value={quotaSize} min="0" step="1" placeholder={$t('unlimited')} />{#if quotaSizeWarning}<Text size="small" color="danger">{$t('errors.quota_higher_than_disk_size')}</Text>{/if}- </div>+ </Field><Field label={$t('storage_label')} class="mt-4"><Input bind:value={storageLabel} />