Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: only validate project name if it has changed (#2720)
Kyle Mendell9094cd7d63a3
diff --git a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte b/frontend/src/routes/(app)/projects/[projectId]/+page.svelteindex c7d8935d9..6150a3fba 100644--- a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte+++ b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte@@ -75,14 +75,22 @@refetchOnMount: false}));- const formSchema = z.object({- name: z- .string()- .min(1, m.compose_project_name_required())- .regex(/^[a-z0-9_-]+$/i, m.compose_project_name_invalid_with_underscores()),- composeContent: z.string().min(1, m.compose_compose_content_required()),- envContent: z.string().optional().default('')- });+ const formSchema = z+ .object({+ name: z.string().min(1, m.compose_project_name_required()),+ composeContent: z.string().min(1, m.compose_compose_content_required()),+ envContent: z.string().optional().default('')+ })+ .superRefine((data, ctx) => {+ const currentServerName = project?.name ?? '';+ if (data.name !== currentServerName && !/^[a-z0-9_-]+$/i.test(data.name)) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ path: ['name'],+ message: m.compose_project_name_invalid_with_underscores()+ });+ }+ });const initialFormData = untrack(() => ({name: data.editorState.originalName,diff --git a/frontend/src/routes/(app)/projects/components/EditableName.svelte b/frontend/src/routes/(app)/projects/components/EditableName.svelteindex 2ee0f6531..9172cc8a2 100644--- a/frontend/src/routes/(app)/projects/components/EditableName.svelte+++ b/frontend/src/routes/(app)/projects/components/EditableName.svelte@@ -97,7 +97,9 @@<h1 class="m-0 w-full"><buttontype="button"- class="hover:bg-muted/50 focus:ring-ring min-h-[32px] w-full rounded bg-transparent px-1 py-1 text-center text-base font-semibold transition-colors focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"+ class="hover:bg-muted/50 focus:ring-ring min-h-[32px] w-full rounded bg-transparent px-1 py-1 text-center text-base font-semibold transition-colors focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 {error+ ? 'border border-destructive'+ : ''}"title={canEdit ? `${value || placeholder} (tap to edit)` : value || placeholder}onclick={beginEdit}disabled={!canEdit}@@ -126,9 +128,11 @@<h1 class="m-0 max-w-[360px]"><buttontype="button"- class="w-full truncate bg-transparent px-0 py-0 text-left text-lg leading-none font-semibold {!value && placeholder- ? 'text-muted-foreground'- : ''}"+ class={cn(+ 'w-full truncate bg-transparent px-0 py-0 text-left text-lg leading-none font-semibold',+ !value && placeholder && 'text-muted-foreground',+ error && 'rounded border border-destructive px-1'+ )}title={value || placeholder}onclick={beginEdit}disabled={!canEdit}@@ -163,6 +167,6 @@{/if}</div>-{#if isEditing && error}+{#if error}<p class="text-destructive mt-1 text-xs">{error}</p>{/if}