Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix(templates): keep folder templates intact and require templates:create for download (#4473)
José M. Requena Plens6f866ff60aa9
diff --git a/.arcane.json b/.arcane.jsonindex a1e320594..df711e3f4 100644--- a/.arcane.json+++ b/.arcane.json@@ -1,5 +1,5 @@{- "version": "2.16.1",- "revision": "115aa7138d42918b950c0f227d1f7744615e4c66",- "buildTime": "2026-10-15T03:58:24Z"+ "version": "2.16.1",+ "revision": "115aa7138d42918b950c0f227d1f7744615e4c66",+ "buildTime": "2026-10-15T03:58:24Z"}diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0aa569c47..5ffa21207 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -32,6 +32,7 @@- use composite literals, drop DI nil checks and mappers ([cdfe49e](https://github.com/getarcaneapp/arcane/commit/cdfe49e8cbe0110e60e582aba3a4ce93c8fdb962) by @kmendell)**Full Changelog**: https://github.com/getarcaneapp/arcane/compare/v2.16.0...v2.16.1+## v2.16.0### New featuresdiff --git a/backend/internal/template/handler.go b/backend/internal/template/handler.goindex d4b1d5119..7364d8ff9 100644--- a/backend/internal/template/handler.go+++ b/backend/internal/template/handler.go@@ -223,6 +223,9 @@ func (h *TemplateHandler) UpdateTemplate(ctx context.Context, input *UpdateTemplif errors.Is(err, common.ErrTemplateNotFound) {return nil, huma.Error404NotFound("Template not found")}+ if errors.Is(err, common.ErrValidation) {+ return nil, huma.Error400BadRequest(err.Error())+ }return nil, huma.Error500InternalServerError("Failed to update template: " + err.Error())}diff --git a/backend/internal/template/module.go b/backend/internal/template/module.goindex 144462516..70647df82 100644--- a/backend/internal/template/module.go+++ b/backend/internal/template/module.go@@ -130,7 +130,7 @@ func RegisterTemplates(api huma.API, templateService *TemplateService) {Description: "Download a remote template to local storage",Tags: []string{"Templates"},Security: handlerutil.DefaultOperationSecurity(),- Middlewares: middleware.RequirePermission(api, authz.PermTemplatesRead),+ Middlewares: middleware.RequirePermission(api, authz.PermTemplatesCreate),}, h.DownloadTemplate)huma.Register(api, huma.Operation{diff --git a/backend/internal/template/service.go b/backend/internal/template/service.goindex 2206b7f05..8aee091d4 100644--- a/backend/internal/template/service.go+++ b/backend/internal/template/service.go@@ -49,6 +49,14 @@ type registryFetchMeta struct {Templates []ComposeTemplate}+// templateFileSnapshot is a folder template file's state before a save overwrote it.+type templateFileSnapshot struct {+ path string+ content string+ perm os.FileMode+ existed bool+}+type TemplateService struct {db *database.DBhttpClient *http.Client@@ -63,7 +71,8 @@ type TemplateService struct {registryFetchMeta map[string]*registryFetchMetaregistryErrors map[string]string // last fetch error per registry ID, cleared on success- fsSyncMu sync.Mutex+ // fsMu serializes folder template writes and deletes with the filesystem sync, and guards lastFsSync.+ fsMu sync.MutexlastFsSync time.Time}@@ -314,7 +323,11 @@ func (s *TemplateService) UpdateTemplate(ctx context.Context, id string, updatesif err := normalization.Normalize(updates); err != nil {return err}- return s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {+ s.fsMu.Lock()+ defer s.fsMu.Unlock()++ var restoreFiles func() error+ err := s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {var existing ComposeTemplateif err := tx.Where("id = ?", id).First(&existing).Error; err != nil {if errors.Is(err, gorm.ErrRecordNotFound) {@@ -327,8 +340,25 @@ func (s *TemplateService) UpdateTemplate(ctx context.Context, id string, updatesreturn errors.New("cannot update remote template")}- existing.Name = updates.Name- existing.Description = updates.Description+ // The filesystem sync re-imports folder templates, so edits must go to the folder.+ baseDir, folder, composePath, folderErr := s.importedTemplateFolder(ctx, &existing)+ if folderErr != nil {+ return folderErr+ }+ if composePath != "" {+ if updates.Name != normalization.Text(existing.Name, true, true) || updates.Description != normalization.Text(existing.Description, true, true) {+ return common.Classify(common.ErrValidation, errors.New("the name and description of a template from the templates directory cannot be changed"))+ }+ var writeErr error+ restoreFiles, writeErr = writeImportedTemplateFiles(filepath.Join(baseDir, folder), composePath, updates.Content, mo.PointerToOption(updates.EnvContent).OrEmpty())+ if writeErr != nil {+ return writeErr+ }+ } else {+ existing.Name = updates.Name+ existing.Description = updates.Description+ }+existing.Content = updates.Contentexisting.EnvContent = updates.EnvContentsetTemplateIconURL(&existing, projects.ResolveTemplateIconURL(ctx, existing.Content, mo.PointerToOption(existing.EnvContent).OrEmpty()))@@ -337,9 +367,18 @@ func (s *TemplateService) UpdateTemplate(ctx context.Context, id string, updates}return nil})+ if err != nil && restoreFiles != nil {+ if restoreErr := restoreFiles(); restoreErr != nil {+ return errors.Join(err, fmt.Errorf("failed to restore template files: %w", restoreErr))+ }+ }+ return err}func (s *TemplateService) DeleteTemplate(ctx context.Context, id string) error {+ s.fsMu.Lock()+ defer s.fsMu.Unlock()+return s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {var existing ComposeTemplateif err := tx.Where("id = ?", id).First(&existing).Error; err != nil {@@ -353,17 +392,13 @@ func (s *TemplateService) DeleteTemplate(ctx context.Context, id string) error {return errors.New("cannot delete remote template directly")}- baseDir, err := s.getTemplatesDirectory(ctx)+ baseDir, folder, composePath, err := s.importedTemplateFolder(ctx, &existing)if err != nil {- return fmt.Errorf("failed to get templates directory: %w", err)+ return err}-- templatePath := filepath.Join(baseDir, existing.Name)- if entry, statErr := acfs.Stat(ctx, baseDir, "/"+existing.Name, false); statErr == nil && entry.IsDirectory {- if _, detectComposeFileErr := projects.DetectComposeFile(ctx, "", templatePath); detectComposeFileErr == nil {- if removeAllErr := acfs.RemoveAll(ctx, baseDir, entry.Path); removeAllErr != nil {- return fmt.Errorf("failed to delete template directory: %w", removeAllErr)- }+ if composePath != "" {+ if removeAllErr := acfs.RemoveAll(ctx, baseDir, folder); removeAllErr != nil {+ return fmt.Errorf("failed to delete template directory: %w", removeAllErr)}}if deleteTemplateErr := tx.Delete(&existing).Error; deleteTemplateErr != nil {@@ -373,6 +408,83 @@ func (s *TemplateService) DeleteTemplate(ctx context.Context, id string) error {})}+// importedTemplateFolder returns the folder tpl was imported from, as a path logical to baseDir, and its compose file.+// composePath is empty when no folder belongs to tpl, including a folder that only shares its name.+func (s *TemplateService) importedTemplateFolder(ctx context.Context, tpl *ComposeTemplate) (baseDir, folder, composePath string, err error) {+ baseDir, err = s.getTemplatesDirectory(ctx)+ if err != nil {+ return "", "", "", fmt.Errorf("failed to get templates directory: %w", err)+ }++ entry, statErr := acfs.Stat(ctx, baseDir, "/"+tpl.Name, false)+ if statErr != nil || !entry.IsDirectory {+ return baseDir, "", "", nil+ }+ detected, detectErr := projects.DetectComposeFile(ctx, "", filepath.Join(baseDir, tpl.Name))+ if detectErr != nil || tpl.Description != "Imported from "+detected {+ return baseDir, "", "", nil+ }+ return baseDir, entry.Path, detected, nil+}++// writeImportedTemplateFiles writes content and env through any symlinks to the files projects.ReadFolderComposeTemplate reads.+// restore puts back every file it changed and is set even when err is.+func writeImportedTemplateFiles(folderPath, composePath, content, envContent string) (restore func() error, err error) {+ envPath := filepath.Join(folderPath, ".env.example")+ if _, statErr := os.Stat(envPath); statErr != nil {+ dotEnvPath := filepath.Join(folderPath, ".env")+ if _, dotEnvErr := os.Stat(dotEnvPath); dotEnvErr == nil {+ envPath = dotEnvPath+ } else if strings.TrimSpace(envContent) == "" {+ envPath = ""+ }+ }++ var written []templateFileSnapshot+ restore = func() error {+ var errs []error+ for _, prev := range slices.Backward(written) {+ if prev.existed {+ errs = append(errs, projects.WriteFileWithPerm(prev.path, prev.content, prev.perm))+ } else {+ errs = append(errs, os.Remove(prev.path))+ }+ }+ return errors.Join(errs...)+ }++ files := []struct{ path, content string }{+ {path: composePath, content: content},+ {path: envPath, content: envContent},+ }+ for _, file := range files {+ if file.path == "" {+ continue+ }+ prev := templateFileSnapshot{path: file.path, perm: utils.FilePerm}+ info, statErr := os.Stat(file.path)+ switch {+ case statErr == nil:+ target, resolveErr := filepath.EvalSymlinks(file.path)+ if resolveErr != nil {+ return restore, fmt.Errorf("failed to resolve template file: %w", resolveErr)+ }+ data, readErr := os.ReadFile(target)+ if readErr != nil {+ return restore, fmt.Errorf("failed to read template file: %w", readErr)+ }+ prev = templateFileSnapshot{path: target, content: string(data), perm: info.Mode().Perm(), existed: true}+ case !errors.Is(statErr, os.ErrNotExist):+ return restore, fmt.Errorf("failed to stat template file: %w", statErr)+ }+ if writeErr := projects.WriteFileWithPerm(prev.path, file.content, prev.perm); writeErr != nil {+ return restore, writeErr+ }+ written = append(written, prev)+ }+ return restore, nil+}+// readDefaultTemplate reads one of the default template files from the configured templates directory.func (s *TemplateService) readDefaultTemplate(ctx context.Context, fileName string) (string, error) {baseDir, err := s.getTemplatesDirectory(ctx)@@ -852,6 +964,14 @@ func (s *TemplateService) DownloadTemplate(ctx context.Context, remoteTemplate *}srcDesc := fmt.Sprintf("Imported from %s/compose.yaml", dir)+ composeContent, envContent, err := s.FetchTemplateContent(ctx, remoteTemplate)+ if err != nil {+ return nil, fmt.Errorf("failed to fetch template content for download: %w", err)+ }++ s.fsMu.Lock()+ defer s.fsMu.Unlock()+var resultTemplate *ComposeTemplateerr = s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {var existing ComposeTemplate@@ -860,10 +980,6 @@ func (s *TemplateService) DownloadTemplate(ctx context.Context, remoteTemplate *return fmt.Errorf("failed to check existing template: %w", findErr)}- composeContent, envContent, fetchErr := s.FetchTemplateContent(ctx, remoteTemplate)- if fetchErr != nil {- return fmt.Errorf("failed to fetch template content for download: %w", fetchErr)- }envPtr, writeErr := projects.WriteTemplateFiles(composePath, envPath, composeContent, envContent)if writeErr != nil {return writeErr@@ -953,8 +1069,8 @@ func (s *TemplateService) invalidateRemoteCache() {// SyncLocalTemplatesFromFilesystem imports template folders from the templates directory, at most once per fsSyncInterval.func (s *TemplateService) SyncLocalTemplatesFromFilesystem(ctx context.Context) (err error) {- s.fsSyncMu.Lock()- defer s.fsSyncMu.Unlock()+ s.fsMu.Lock()+ defer s.fsMu.Unlock()if !s.lastFsSync.IsZero() && time.Since(s.lastFsSync) < fsSyncInterval {return nil@@ -1080,6 +1196,11 @@ func (s *TemplateService) GetTemplateContentWithParsedData(ctx context.Context,if err != nil {return nil, fmt.Errorf("failed to fetch template content: %w", err)}+ // Folder ownership only locks fields in the editor, so a missing templates directory must not block the preview.+ _, _, folderComposePath, folderErr := s.importedTemplateFolder(ctx, composeTemplate)+ if folderErr != nil {+ slog.WarnContext(ctx, "failed to check template folder", "templateId", id, "error", folderErr)+ }if !composeTemplate.IsRemote {setTemplateIconURL(composeTemplate, projects.ResolveTemplateIconURL(ctx, composeContent, envContent))}@@ -1100,10 +1221,11 @@ func (s *TemplateService) GetTemplateContentWithParsedData(ctx context.Context,}return &tmpl.TemplateContent{- Template: outTemplate,- Content: composeContent,- EnvContent: envContent,- Services: services,- EnvVariables: envVars,+ Template: outTemplate,+ Content: composeContent,+ EnvContent: envContent,+ Services: services,+ EnvVariables: envVars,+ IsFolderTemplate: folderComposePath != "",}, nil}diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 61215ef1f..5c54d1c8f 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -1992,6 +1992,7 @@"templates_template_name_placeholder": "e.g. My Nginx Project","templates_template_name_required": "Template name is required","templates_template_description_placeholder": "Briefly describe this template",+ "templates_name_description_locked": "The name and description of a template from the templates directory cannot be changed.","compose_content_is_required": "Compose content is required","templates_save_template_failed": "Failed to save template","templates_create_template_failed": "Failed to create template",diff --git a/frontend/src/lib/components/dialogs/template-selection-dialog.svelte b/frontend/src/lib/components/dialogs/template-selection-dialog.svelteindex 223001d18..b5276ae3f 100644--- a/frontend/src/lib/components/dialogs/template-selection-dialog.svelte+++ b/frontend/src/lib/components/dialogs/template-selection-dialog.svelte@@ -28,6 +28,7 @@import { m } from '#lib/paraglide/messages.js';import { templateService } from '#lib/services/template-service.js';import type { Template } from '#lib/types/swarm.js';+ import { hasPermission } from '#lib/utils/auth.js';import { tryCatch } from '#lib/utils/try-catch.js';interface Props {@@ -41,6 +42,7 @@void open;const loadingStates = new SvelteSet<string>();+ const canCreateTemplate = $derived(hasPermission('templates:create'));let sortBy = $state<'name-asc' | 'name-desc'>('name-asc');let groupByRegistry = $state(true);let searchQuery = $state('');@@ -259,7 +261,7 @@{template.isRemote ? m.templates_remote_template_label() : m.templates_local_template_label()}</div><div class="flex gap-2">- {#if template.isRemote}+ {#if template.isRemote && canCreateTemplate}<ArcaneButtonaction="base"tone="outline"diff --git a/frontend/src/lib/types/swarm.ts b/frontend/src/lib/types/swarm.tsindex 5025117a9..8d7adafc4 100644--- a/frontend/src/lib/types/swarm.ts+++ b/frontend/src/lib/types/swarm.ts@@ -703,6 +703,7 @@ export interface TemplateContentData {envContent: string;services: string[];envVariables: EnvVariable[];+ isFolderTemplate: boolean;}export interface RemoteTemplate {diff --git a/frontend/src/routes/(app)/customize/templates/[id]/+page.svelte b/frontend/src/routes/(app)/customize/templates/[id]/+page.svelteindex b773d49c4..dd983a787 100644--- a/frontend/src/routes/(app)/customize/templates/[id]/+page.svelte+++ b/frontend/src/routes/(app)/customize/templates/[id]/+page.svelte@@ -26,6 +26,7 @@import { m } from '#lib/paraglide/messages.js';import { queryKeys } from '#lib/query/query-keys.js';import { templateService } from '#lib/services/template-service.js';+ import { hasPermission } from '#lib/utils/auth.js';import { formatDateTimeShort } from '#lib/utils/formatting.js';import { createForm } from '#lib/utils/settings.svelte.js';import {@@ -110,8 +111,12 @@originalCompose = validated.composeContent;originalEnv = validated.envContent ?? '';await Promise.all([- queryClient.invalidateQueries({ queryKey: queryKeys.templates.content(template.id) }),- queryClient.invalidateQueries({ queryKey: queryKeys.templates.all })+ queryClient.invalidateQueries({+ queryKey: queryKeys.templates.content(template.id)+ }),+ queryClient.invalidateQueries({+ queryKey: queryKeys.templates.all+ })]);await refreshAll();}@@ -145,7 +150,7 @@return data.allTemplates.find((t) => !t.isRemote && t.metadata?.remoteUrl === template.metadata?.remoteUrl);});- const canDownload = $derived(template.isRemote && !localVersionOfRemote);+ const canDownload = $derived(template.isRemote && !localVersionOfRemote && hasPermission('templates:create'));async function handleDownload() {if (status.isDownloading || !canDownload) return;@@ -159,8 +164,12 @@await goto(`/customize/templates/${downloadedTemplate.id}`, { replace: true });} else {await Promise.all([- queryClient.invalidateQueries({ queryKey: queryKeys.templates.content(template.id) }),- queryClient.invalidateQueries({ queryKey: queryKeys.templates.all })+ queryClient.invalidateQueries({+ queryKey: queryKeys.templates.content(template.id)+ }),+ queryClient.invalidateQueries({+ queryKey: queryKeys.templates.all+ })]);await refreshAll();}@@ -181,7 +190,9 @@if (status.isDeleting) return;openConfirmDialog({title: m.common_delete_title({ resource: m.resource_template() }),- message: m.common_delete_confirm({ resource: `${m.resource_template()} "${template.name}"` }),+ message: m.common_delete_confirm({+ resource: `${m.resource_template()} "${template.name}"`+ }),confirm: {label: m.templates_delete_template(),destructive: true,@@ -190,7 +201,11 @@const operationResult = await tryCatch((async () => {await templateService.deleteTemplate(template.id);- toast.success(m.common_delete_success({ resource: `${m.resource_template()} "${template.name}"` }));+ toast.success(+ m.common_delete_success({+ resource: `${m.resource_template()} "${template.name}"`+ })+ );await goto('/customize/templates');})());@@ -201,7 +216,9 @@toast.error(error instanceof Error? error.message- : m.common_delete_failed({ resource: `${m.resource_template()} "${template.name}"` })+ : m.common_delete_failed({+ resource: `${m.resource_template()} "${template.name}"`+ }));status.isDeleting = false;}@@ -255,7 +272,6 @@</script>{#if !template.isRemote}- <!-- Editor workspace for custom templates (same chrome as the create page) --><TemplateEditorWorkspacebind:inputsbind:validation@@ -265,6 +281,7 @@fileIdPrefix="templates:custom:{template.id}"{globalVariableMap}saving={status.saving}+ lockNameAndDescription={data.templateData.isFolderTemplate}onSubmit={handleSave}>{#snippet toolbarActions()}@@ -360,35 +377,55 @@<aside class="w-full shrink-0 space-y-6 lg:w-72 lg:border-l lg:border-border/50 lg:pl-8 xl:w-80"><div class="space-y-3">- <h3 class="text-xs font-semibold tracking-wide text-muted-foreground uppercase">{m.common_overview()}</h3>+ <h3 class="text-xs font-semibold tracking-wide text-muted-foreground uppercase">+ {m.common_overview()}+ </h3><dl class="space-y-2 text-sm">{#if template.registry?.name}<div class="flex items-center justify-between gap-4">- <dt class="shrink-0 text-muted-foreground">{m.common_registry()}</dt>- <dd class="min-w-0 text-right font-medium break-words">{template.registry.name}</dd>+ <dt class="shrink-0 text-muted-foreground">+ {m.common_registry()}+ </dt>+ <dd class="min-w-0 text-right font-medium break-words">+ {template.registry.name}+ </dd></div>{/if}{#if template.metadata?.version}<div class="flex items-center justify-between gap-4">- <dt class="shrink-0 text-muted-foreground">{m.common_version()}</dt>- <dd class="min-w-0 text-right font-medium break-words">{template.metadata.version}</dd>+ <dt class="shrink-0 text-muted-foreground">+ {m.common_version()}+ </dt>+ <dd class="min-w-0 text-right font-medium break-words">+ {template.metadata.version}+ </dd></div>{/if}{#if template.metadata?.author}<div class="flex items-center justify-between gap-4">- <dt class="shrink-0 text-muted-foreground">{m.common_author()}</dt>- <dd class="min-w-0 text-right font-medium break-words">{template.metadata.author}</dd>+ <dt class="shrink-0 text-muted-foreground">+ {m.common_author()}+ </dt>+ <dd class="min-w-0 text-right font-medium break-words">+ {template.metadata.author}+ </dd></div>{/if}{#if template.metadata?.updatedAt}<div class="flex items-center justify-between gap-4">- <dt class="shrink-0 text-muted-foreground">{m.common_updated()}</dt>- <dd class="min-w-0 text-right font-medium break-words">{formatDateTimeShort(template.metadata.updatedAt)}</dd>+ <dt class="shrink-0 text-muted-foreground">+ {m.common_updated()}+ </dt>+ <dd class="min-w-0 text-right font-medium break-words">+ {formatDateTimeShort(template.metadata.updatedAt)}+ </dd></div>{/if}{#if template.metadata?.documentationUrl}<div class="flex items-center justify-between gap-4">- <dt class="shrink-0 text-muted-foreground">{m.common_documentation()}</dt>+ <dt class="shrink-0 text-muted-foreground">+ {m.common_documentation()}+ </dt><dd class="min-w-0 text-right"><ahref={template.metadata.documentationUrl}@@ -429,11 +466,17 @@<div class="space-y-2.5">{#each envVars as envVar (envVar.key)}<div class="min-w-0">- <div class="font-mono text-xs font-medium break-words select-all">{envVar.key}</div>+ <div class="font-mono text-xs font-medium break-words select-all">+ {envVar.key}+ </div>{#if envVar.value}- <div class="font-mono text-xs break-words text-muted-foreground select-all">{envVar.value}</div>+ <div class="font-mono text-xs break-words text-muted-foreground select-all">+ {envVar.value}+ </div>{:else}- <div class="text-xs text-muted-foreground italic">{m.common_no_default_value()}</div>+ <div class="text-xs text-muted-foreground italic">+ {m.common_no_default_value()}+ </div>{/if}</div>{/each}@@ -443,7 +486,9 @@{#if template.metadata?.tags && template.metadata.tags.length > 0}<div class="space-y-3 border-t border-border/50 pt-6">- <h3 class="text-xs font-semibold tracking-wide text-muted-foreground uppercase">{m.common_tags()}</h3>+ <h3 class="text-xs font-semibold tracking-wide text-muted-foreground uppercase">+ {m.common_tags()}+ </h3><div class="flex flex-wrap gap-1">{#each template.metadata.tags as tag (tag)}<Badge variant="outline">{tag}</Badge>diff --git a/frontend/src/routes/(app)/customize/templates/components/template-card.svelte b/frontend/src/routes/(app)/customize/templates/components/template-card.svelteindex 5c0356c9c..4927ef169 100644--- a/frontend/src/routes/(app)/customize/templates/components/template-card.svelte+++ b/frontend/src/routes/(app)/customize/templates/components/template-card.svelte@@ -28,7 +28,7 @@const MAX_TAGS = 4;- const canReadTemplate = $derived(hasPermission('templates:read'));+ const canCreateTemplate = $derived(hasPermission('templates:create'));const canDeleteTemplate = $derived(hasPermission('templates:delete'));const registryName = $derived(template.registry?.name ?? (template.isRemote ? m.templates_unknown_registry() : m.templates_local_templates())@@ -72,11 +72,11 @@</DropdownMenu.Item></IfPermitted>- {#if (template.isRemote && canReadTemplate) || (!template.isRemote && canDeleteTemplate)}+ {#if (template.isRemote && canCreateTemplate) || (!template.isRemote && canDeleteTemplate)}<DropdownMenu.Separator />{/if}- {#if template.isRemote && canReadTemplate}+ {#if template.isRemote && canCreateTemplate}<DropdownMenu.Item onclick={() => onDownload(template)} disabled={downloading}>{#if downloading}<Spinner class="size-4" />diff --git a/frontend/src/routes/(app)/customize/templates/components/template-editor-workspace.svelte b/frontend/src/routes/(app)/customize/templates/components/template-editor-workspace.svelteindex 214e5c61c..235467284 100644--- a/frontend/src/routes/(app)/customize/templates/components/template-editor-workspace.svelte+++ b/frontend/src/routes/(app)/customize/templates/components/template-editor-workspace.svelte@@ -36,6 +36,7 @@fileIdPrefix,globalVariableMap,saving = false,+ lockNameAndDescription = false,onSubmit,toolbarActions}: {@@ -47,12 +48,14 @@fileIdPrefix: string;globalVariableMap: Record<string, string>;saving?: boolean;+ lockNameAndDescription?: boolean;onSubmit: () => void;toolbarActions: Snippet;} = $props();let nameInputRef = $state<HTMLInputElement | null>(null);const enableDiff = $derived(originalCompose !== undefined);+ const lockedMessage = $derived(lockNameAndDescription ? m.templates_name_description_locked() : undefined);</script><div class="flex h-full min-h-0 flex-col bg-background">@@ -77,7 +80,8 @@error={inputs.name.error ?? undefined}originalValue={originalName}placeholder={m.templates_template_name_placeholder()}- canEdit={!saving}+ canEdit={!saving && !lockNameAndDescription}+ disabledMessage={lockedMessage}class="hidden sm:block"/></div>@@ -100,7 +104,8 @@error={inputs.name.error ?? undefined}originalValue={originalName}placeholder={m.templates_template_name_placeholder()}- canEdit={!saving}+ canEdit={!saving && !lockNameAndDescription}+ disabledMessage={lockedMessage}/></div>@@ -110,7 +115,8 @@input={inputs.description}label={m.common_description()}placeholder={m.templates_template_description_placeholder()}- disabled={saving}+ description={lockedMessage}+ disabled={saving || lockNameAndDescription}/></div></div>diff --git a/types/template/template.go b/types/template/template.goindex cb3c716b8..db7f592ee 100644--- a/types/template/template.go+++ b/types/template/template.go@@ -152,6 +152,12 @@ type TemplateContent struct {//// Required: trueEnvVariables []env.Variable `json:"envVariables"`++ // IsFolderTemplate indicates the template belongs to a folder in the templates directory,+ // so its name and description cannot be changed.+ //+ // Required: true+ IsFolderTemplate bool `json:"isFolderTemplate"`}// Template represents a Docker Compose template.