Skip to content

Modern Docker Management, Designed for Everyone

fix: project save button not showing in tree view (#2163)

Kyle Mendell8c7507643557
diff --git a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
index 909401953..a868fabd4 100644
--- a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
+++ b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
@@ -123,14 +123,20 @@
let composeValidationReady = $state(false);
let envValidationReady = $state(false);
let includeFilesValidationReady = $state<Record<string, boolean>>({});
+ let composeHasChanges = $derived($inputs.composeContent.value !== originalComposeContent);
+ let envHasChanges = $derived($inputs.envContent.value !== originalEnvContent);
+ let changedIncludeFilePaths = $derived.by(() =>
+ Object.keys(includeFilesState).filter(
+ (relativePath) => includeFilesState[relativePath] !== originalIncludeFiles[relativePath]
+ )
+ );
let hasAnyErrors = $derived(
- !composeValidationReady ||
- !envValidationReady ||
- Object.values(includeFilesValidationReady).some((isReady) => !isReady) ||
- composeHasErrors ||
- envHasErrors ||
- Object.values(includeFilesHasErrors).some((hasError) => hasError)
+ (composeHasChanges && (!composeValidationReady || composeHasErrors)) ||
+ (envHasChanges && (!envValidationReady || envHasErrors)) ||
+ changedIncludeFilePaths.some(
+ (relativePath) => !includeFilesValidationReady[relativePath] || !!includeFilesHasErrors[relativePath]
+ )
);
let canSave = $derived(hasChanges && !hasAnyErrors);
@@ -334,9 +340,14 @@
let savedProject = updatedProject;
for (const relativePath of Object.keys(includeFilesState)) {
- if (includeFilesState[relativePath] !== originalIncludeFiles[relativePath]) {
+ const includeFileContent = includeFilesState[relativePath];
+ if (includeFileContent === undefined) {
+ continue;
+ }
+
+ if (includeFileContent !== originalIncludeFiles[relativePath]) {
const includeResult = await tryCatch(
- projectService.updateProjectIncludeFile(projectId, relativePath, includeFilesState[relativePath])
+ projectService.updateProjectIncludeFile(projectId, relativePath, includeFileContent)
);
if (includeResult.error) {
toast.error(includeResult.error.message || m.common_update_failed({ resource: relativePath }));
@@ -529,7 +540,7 @@
{#snippet headerActions()}
<div class="flex items-center gap-2">
- {#if hasChanges && !hasAnyErrors}
+ {#if hasChanges}
<ArcaneButton
action="save"
loading={isLoading.saving}
@@ -715,6 +726,12 @@
bind:value={$inputs.composeContent.value}
error={$inputs.composeContent.error ?? undefined}
readOnly={!canEditCompose}
+ bind:hasErrors={composeHasErrors}
+ bind:validationReady={composeValidationReady}
+ fileId={`project:${projectId}:compose`}
+ originalValue={originalComposeContent}
+ enableDiff={true}
+ editorContext={codeEditorContext}
/>
{:else if selectedFile === 'env'}
<CodePanel
@@ -723,6 +740,13 @@
language="env"
bind:value={$inputs.envContent.value}
error={$inputs.envContent.error ?? undefined}
+ readOnly={!canEditEnv}
+ bind:hasErrors={envHasErrors}
+ bind:validationReady={envValidationReady}
+ fileId={`project:${projectId}:env`}
+ originalValue={originalEnvContent}
+ enableDiff={true}
+ editorContext={codeEditorContext}
/>
{:else if selectedFile.startsWith('dir:')}
{@const dirRelPath = selectedFile.slice(4)}
@@ -744,6 +768,12 @@
title={includeFile.relativePath}
language="yaml"
bind:value={includeFilesState[includeFile.relativePath]}
+ bind:hasErrors={includeFilesHasErrors[includeFile.relativePath]}
+ bind:validationReady={includeFilesValidationReady[includeFile.relativePath]}
+ fileId={`project:${projectId}:include:${includeFile.relativePath}`}
+ originalValue={originalIncludeFiles[includeFile.relativePath]}
+ enableDiff={true}
+ editorContext={codeEditorContext}
/>
{/if}
{/if}
diff --git a/frontend/src/routes/(app)/projects/components/CodePanel.svelte b/frontend/src/routes/(app)/projects/components/CodePanel.svelte
index 0b3f02630..ba000fe3d 100644
--- a/frontend/src/routes/(app)/projects/components/CodePanel.svelte
+++ b/frontend/src/routes/(app)/projects/components/CodePanel.svelte
@@ -10,9 +10,9 @@
let {
title,
- open = $bindable(),
+ open = $bindable(true),
language,
- value = $bindable(),
+ value = $bindable(''),
error,
autoHeight = false,
readOnly = false,
@@ -38,9 +38,9 @@
commandPaletteOpen = $bindable(false)
}: {
title: string;
- open: boolean;
+ open?: boolean;
language: CodeLanguage;
- value: string;
+ value?: string;
error?: string;
autoHeight?: boolean;
readOnly?: boolean;
diff --git a/tests/spec/project.spec.ts b/tests/spec/project.spec.ts
index fe9cad8e3..97e26c860 100644
--- a/tests/spec/project.spec.ts
+++ b/tests/spec/project.spec.ts
@@ -898,6 +898,72 @@ test.describe('Project Detail Page', () => {
}
});
+ test('should enable Save when editing the initial file in restored tree view', async ({
+ page
+ }) => {
+ const regularProject = realProjects.find((p) => !p.gitOpsManagedBy);
+ test.skip(!regularProject, 'No regular (non-GitOps) projects found');
+
+ await page.goto(`/projects/${regularProject!.id || regularProject!.name}`);
+ await page.waitForLoadState('networkidle');
+
+ const configTab = page.getByRole('tab', { name: /Configuration|Config/i });
+ await configTab.click();
+ await page.waitForLoadState('networkidle');
+
+ let layoutSwitch = page.getByRole('switch', {
+ name: /Classic|Tree View/i
+ });
+ test.skip(
+ (await layoutSwitch.count()) === 0,
+ 'No layout switch available for project configuration'
+ );
+
+ const projectFilesHeading = page.getByRole('heading', {
+ name: /Project Files/i
+ });
+
+ if (!(await projectFilesHeading.isVisible().catch(() => false))) {
+ await layoutSwitch.click();
+ await expect(projectFilesHeading).toBeVisible();
+ }
+
+ await page.reload();
+ await page.waitForLoadState('networkidle');
+
+ const restoredConfigTab = page.getByRole('tab', { name: /Configuration|Config/i });
+ if ((await restoredConfigTab.getAttribute('aria-selected')) !== 'true') {
+ await restoredConfigTab.click();
+ await page.waitForLoadState('networkidle');
+ }
+
+ await expect(projectFilesHeading).toBeVisible();
+ await expect(page.getByRole('heading', { name: 'compose.yaml' })).toBeVisible();
+
+ const treeComposeEditor = page.locator('.cm-editor:visible').first();
+ await expect(treeComposeEditor).toBeVisible();
+
+ const marker = `ARCANE_TREE_SAVE_${Date.now()}`;
+ const originalCompose = await getCodeMirrorValue(treeComposeEditor);
+ const updatedCompose = `${originalCompose.trimEnd()}\n# ${marker}\n`;
+ await setCodeMirrorValue(page, treeComposeEditor, updatedCompose);
+
+ const saveButton = page.getByRole('button', { name: 'Save', exact: true }).first();
+ await expect(saveButton).toBeVisible();
+ await expect(saveButton).toBeEnabled();
+
+ const envFileButton = page.getByRole('button', { name: '.env' }).first();
+ await expect(envFileButton).toBeVisible();
+
+ layoutSwitch = page.getByRole('switch', {
+ name: /Classic|Tree View/i
+ });
+ await layoutSwitch.click();
+ await expect(page.getByRole('heading', { name: 'compose.yaml' })).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Save', exact: true }).first()).toBeVisible();
+ await expect(page.getByRole('button', { name: 'Save', exact: true }).first()).toBeEnabled();
+ });
+
test('should show logs tab for running projects', async ({ page }) => {
test.skip(!realProjects.length, 'No projects available for logs test');