Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: ability to toggle between the classic project and tree view ui (#1120)
Kyle Mendellb554af09edfd
diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 5bac1bced..b835c888b 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -1456,5 +1456,8 @@"common_mount": "mount","common_mounts": "mounts","common_image_id": "Image ID",- "common_entrypoint": "Entrypoint"+ "common_entrypoint": "Entrypoint",+ "classic": "Classic",+ "tree_view": "Tree View",+ "project_view_description": "Switch between classic side-by-side layout and tree view"}diff --git a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte b/frontend/src/routes/(app)/projects/[projectId]/+page.svelteindex 388fa58fc..7b4767868 100644--- a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte+++ b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte@@ -23,6 +23,7 @@import ServicesGrid from '../components/ServicesGrid.svelte';import CodePanel from '../components/CodePanel.svelte';import ProjectsLogsPanel from '../components/ProjectLogsPanel.svelte';+ import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';import { untrack } from 'svelte';import { projectService } from '$lib/services/project-service';@@ -82,6 +83,8 @@let envOpen = $state(true);let includeFilesPanelStates = $state<Record<string, boolean>>({});let selectedFile = $state<'compose' | 'env' | string>('compose');+ let layoutMode = $state<'classic' | 'tree'>('classic');+ let selectedIncludeTab = $state<string | null>(null);const tabItems = $derived<TabItem[]>([{@@ -110,13 +113,15 @@composeOpen: boolean;envOpen: boolean;autoScroll: boolean;+ layoutMode: 'classic' | 'tree';};const defaultComposeUIPrefs: ComposeUIPrefs = {tab: 'compose',composeOpen: true,envOpen: true,- autoScroll: true+ autoScroll: true,+ layoutMode: 'classic'};let prefs: PersistedState<ComposeUIPrefs> | null = null;@@ -137,6 +142,11 @@envOpen = cur.envOpen ?? defaultComposeUIPrefs.envOpen;autoScrollStackLogs = cur.autoScroll ?? defaultComposeUIPrefs.autoScroll;+ // Auto-detect layout mode based on includeFiles+ const hasIncludes = project?.includeFiles && project.includeFiles.length > 0;+ const defaultMode = hasIncludes ? 'tree' : 'classic';+ layoutMode = cur.layoutMode ?? defaultMode;+// Initialize include file statesif (project?.includeFiles) {const newIncludeState: Record<string, string> = {};@@ -202,7 +212,8 @@tab: selectedTab,composeOpen,envOpen,- autoScroll: autoScrollStackLogs+ autoScroll: autoScrollStackLogs,+ layoutMode};}@@ -301,87 +312,167 @@</Tabs.Content><Tabs.Content value="compose" class="h-full">- <div class="flex h-full flex-col gap-4 lg:flex-row">- <div- class="border-border bg-card flex w-full flex-col overflow-y-auto rounded-lg border lg:h-full lg:w-fit lg:max-w-xs lg:min-w-48"- >- <div class="border-border border-b p-3">- <h3 class="text-sm font-medium">Project Files</h3>+ <div class="mb-4">+ <SwitchWithLabel+ id="layout-mode-toggle"+ checked={layoutMode === 'tree'}+ label={layoutMode === 'tree' ? m.tree_view() : m.classic()}+ description={m.project_view_description()}+ onCheckedChange={(checked) => {+ layoutMode = checked ? 'tree' : 'classic';+ if (checked) {+ selectedFile = 'compose';+ selectedIncludeTab = null;+ }+ persistPrefs();+ }}+ />+ </div>++ {#if layoutMode === 'tree'}+ <div class="flex h-full flex-col gap-4 lg:flex-row">+ <div+ class="border-border bg-card flex w-full flex-col overflow-y-auto rounded-lg border lg:h-full lg:w-fit lg:max-w-xs lg:min-w-48"+ >+ <div class="border-border border-b p-3">+ <h3 class="text-sm font-medium">Project Files</h3>+ </div>+ <div class="p-2">+ <TreeView.Root class="p-2">+ <TreeView.File+ name="compose.yaml"+ onclick={() => (selectedFile = 'compose')}+ class={selectedFile === 'compose' ? 'bg-accent' : ''}+ >+ {#snippet icon()}+ <FileTextIcon class="size-4 text-blue-500" />+ {/snippet}+ </TreeView.File>++ <TreeView.File+ name=".env"+ onclick={() => (selectedFile = 'env')}+ class={selectedFile === 'env' ? 'bg-accent' : ''}+ >+ {#snippet icon()}+ <FileTextIcon class="size-4 text-green-500" />+ {/snippet}+ </TreeView.File>++ {#if project?.includeFiles && project.includeFiles.length > 0}+ <TreeView.Folder name="Includes">+ {#each project.includeFiles as includeFile}+ <TreeView.File+ name={includeFile.relativePath}+ onclick={() => (selectedFile = includeFile.relativePath)}+ class={selectedFile === includeFile.relativePath ? 'bg-accent' : ''}+ >+ {#snippet icon()}+ <FileTextIcon class="size-4 text-amber-500" />+ {/snippet}+ </TreeView.File>+ {/each}+ </TreeView.Folder>+ {/if}+ </TreeView.Root>+ </div></div>- <div class="p-2">- <TreeView.Root class="p-2">- <TreeView.File- name="compose.yaml"- onclick={() => (selectedFile = 'compose')}- class={selectedFile === 'compose' ? 'bg-accent' : ''}- >- {#snippet icon()}- <FileTextIcon class="size-4 text-blue-500" />- {/snippet}- </TreeView.File>-- <TreeView.File- name=".env"- onclick={() => (selectedFile = 'env')}- class={selectedFile === 'env' ? 'bg-accent' : ''}- >- {#snippet icon()}- <FileTextIcon class="size-4 text-green-500" />- {/snippet}- </TreeView.File>-- {#if project?.includeFiles && project.includeFiles.length > 0}- <TreeView.Folder name="Includes">- {#each project.includeFiles as includeFile}- <TreeView.File- name={includeFile.relativePath}- onclick={() => (selectedFile = includeFile.relativePath)}- class={selectedFile === includeFile.relativePath ? 'bg-accent' : ''}- >- {#snippet icon()}- <FileTextIcon class="size-4 text-amber-500" />- {/snippet}- </TreeView.File>- {/each}- </TreeView.Folder>++ <div class="flex h-full flex-1 flex-col">+ {#if selectedFile === 'compose'}+ <CodePanel+ bind:open={composeOpen}+ title="compose.yaml"+ language="yaml"+ bind:value={$inputs.composeContent.value}+ placeholder={m.compose_compose_placeholder()}+ error={$inputs.composeContent.error ?? undefined}+ />+ {:else if selectedFile === 'env'}+ <CodePanel+ bind:open={envOpen}+ title=".env"+ language="env"+ bind:value={$inputs.envContent.value}+ placeholder={m.compose_env_placeholder()}+ error={$inputs.envContent.error ?? undefined}+ />+ {:else}+ {@const includeFile = project?.includeFiles?.find((f) => f.relativePath === selectedFile)}+ {#if includeFile}+ <CodePanel+ bind:open={includeFilesPanelStates[includeFile.relativePath]}+ title={includeFile.relativePath}+ language="yaml"+ bind:value={includeFilesState[includeFile.relativePath]}+ placeholder="# Include file content"+ />{/if}- </TreeView.Root>+ {/if}</div></div>+ {:else}+ <div class="flex h-full flex-col gap-4">+ {#if project?.includeFiles && project.includeFiles.length > 0}+ <div class="border-border bg-card rounded-lg border">+ <div class="border-border scrollbar-hide flex gap-2 overflow-x-auto border-b p-2">+ {#each project.includeFiles as includeFile}+ <Button+ variant={selectedIncludeTab === includeFile.relativePath ? 'default' : 'ghost'}+ size="sm"+ class="flex-shrink-0"+ onclick={() => {+ selectedIncludeTab = selectedIncludeTab === includeFile.relativePath ? null : includeFile.relativePath;+ }}+ >+ <FileTextIcon class="mr-2 size-4 text-amber-500" />+ {includeFile.relativePath}+ </Button>+ {/each}+ </div>+ </div>+ {/if}- <div class="flex h-full flex-1 flex-col">- {#if selectedFile === 'compose'}- <CodePanel- bind:open={composeOpen}- title="compose.yaml"- language="yaml"- bind:value={$inputs.composeContent.value}- placeholder={m.compose_compose_placeholder()}- error={$inputs.composeContent.error ?? undefined}- />- {:else if selectedFile === 'env'}- <CodePanel- bind:open={envOpen}- title=".env"- language="env"- bind:value={$inputs.envContent.value}- placeholder={m.compose_env_placeholder()}- error={$inputs.envContent.error ?? undefined}- />- {:else}- {@const includeFile = project?.includeFiles?.find((f) => f.relativePath === selectedFile)}+ {#if selectedIncludeTab}+ {@const includeFile = project?.includeFiles?.find((f) => f.relativePath === selectedIncludeTab)}{#if includeFile}- <CodePanel- bind:open={includeFilesPanelStates[includeFile.relativePath]}- title={includeFile.relativePath}- language="yaml"- bind:value={includeFilesState[includeFile.relativePath]}- placeholder="# Include file content"- />+ <div class="flex-1">+ <CodePanel+ bind:open={includeFilesPanelStates[includeFile.relativePath]}+ title={includeFile.relativePath}+ language="yaml"+ bind:value={includeFilesState[includeFile.relativePath]}+ placeholder="# Include file content"+ />+ </div>{/if}+ {:else}+ <div class="grid h-full flex-1 grid-cols-1 gap-4 lg:grid-cols-5">+ <div class="flex h-full flex-col lg:col-span-3">+ <CodePanel+ bind:open={composeOpen}+ title="compose.yaml"+ language="yaml"+ bind:value={$inputs.composeContent.value}+ placeholder={m.compose_compose_placeholder()}+ error={$inputs.composeContent.error ?? undefined}+ />+ </div>++ <div class="flex h-full flex-col lg:col-span-2">+ <CodePanel+ bind:open={envOpen}+ title=".env"+ language="env"+ bind:value={$inputs.envContent.value}+ placeholder={m.compose_env_placeholder()}+ error={$inputs.envContent.error ?? undefined}+ />+ </div>+ </div>{/if}</div>- </div>+ {/if}</Tabs.Content><Tabs.Content value="logs" class="h-full">diff --git a/tests/spec/project.spec.ts b/tests/spec/project.spec.tsindex 2f488e673..f6d4dff1f 100644--- a/tests/spec/project.spec.ts+++ b/tests/spec/project.spec.ts@@ -278,25 +278,51 @@ test.describe('Project Detail Page', () => {const configTab = page.getByRole('tab', { name: /Configuration|Config/i });await configTab.click();+ // The project config editor supports two layouts:+ // - classic (default): side-by-side compose.yaml + .env panels+ // - tree view: file list on the left and a single code panel on the right+ await expect(page.getByRole('heading', { name: 'compose.yaml' })).toBeVisible();+const projectFilesHeading = page.getByRole('heading', { name: /Project Files/i });- await expect(projectFilesHeading).toBeVisible();+ const isTreeView = await projectFilesHeading.isVisible();- const composeFileButton = page.getByRole('button', { name: 'compose.yaml' }).first();- const envFileButton = page.getByRole('button', { name: '.env' }).first();+ if (isTreeView) {+ const composeFileButton = page.getByRole('button', { name: 'compose.yaml' }).first();+ const envFileButton = page.getByRole('button', { name: '.env' }).first();- await expect(composeFileButton).toBeVisible();- await expect(envFileButton).toBeVisible();+ await expect(composeFileButton).toBeVisible();+ await expect(envFileButton).toBeVisible();- // Switching files should update the visible code panel title- await envFileButton.click();- await expect(page.getByRole('heading', { name: '.env' })).toBeVisible();+ // Switching files should update the visible code panel title+ await envFileButton.click();+ await expect(page.getByRole('heading', { name: '.env' })).toBeVisible();- await composeFileButton.click();- await expect(page.getByRole('heading', { name: 'compose.yaml' })).toBeVisible();+ await composeFileButton.click();+ await expect(page.getByRole('heading', { name: 'compose.yaml' })).toBeVisible();++ const includesFolder = page.getByRole('button', { name: 'Includes' });+ if (await includesFolder.count()) {+ await expect(includesFolder.first()).toBeVisible();+ }+ } else {+ // Classic layout renders both editors at the same time.+ await expect(page.getByRole('heading', { name: '.env' })).toBeVisible();++ // Also validate that we can switch to tree view and see the file list.+ const layoutSwitch = page.getByRole('switch', { name: /Classic|Tree View/i });+ if (await layoutSwitch.count()) {+ await layoutSwitch.click();+ await expect(projectFilesHeading).toBeVisible();++ const composeFileButton = page.getByRole('button', { name: 'compose.yaml' }).first();+ const envFileButton = page.getByRole('button', { name: '.env' }).first();- const includesFolder = page.getByRole('button', { name: 'Includes' });- if (await includesFolder.count()) {- await expect(includesFolder.first()).toBeVisible();+ await expect(composeFileButton).toBeVisible();+ await expect(envFileButton).toBeVisible();++ await envFileButton.click();+ await expect(page.getByRole('heading', { name: '.env' })).toBeVisible();+ }}});diff --git a/tests/spec/volumes.spec.ts b/tests/spec/volumes.spec.tsindex 2dfb8dfad..9aa0eef58 100644--- a/tests/spec/volumes.spec.ts+++ b/tests/spec/volumes.spec.ts@@ -117,7 +117,18 @@ test.describe('Volumes Page', () => {await page.goto('/volumes');await page.waitForLoadState('networkidle');- const volumeRow = page.locator(`tr:has-text("${volumeInUse.name}")`);++ // Volume names can be truncated in the table (e.g. long hashes), so we anchor on the link title+ // which preserves the full name.+ const searchInput = page.getByPlaceholder('Search…');+ if (await searchInput.count()) {+ await searchInput.fill(volumeInUse.name);+ }++ const volumeLink = page.locator(`table a[title="${volumeInUse.name}"]`).first();+ await expect(volumeLink).toBeVisible();++ const volumeRow = volumeLink.locator('xpath=ancestor::tr[1]');await volumeRow.getByRole('button', { name: 'Open menu' }).click();await expect(page.getByRole('menuitem', { name: 'Remove' })).toBeDisabled();