Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
refactor: cleanup svelte components (#681)
Kyle Mendell8d3c95e9b6a1
diff --git a/backend/internal/dto/image_dto.go b/backend/internal/dto/image_dto.goindex e5c90e8ba..58abb7597 100644--- a/backend/internal/dto/image_dto.go+++ b/backend/internal/dto/image_dto.go@@ -94,10 +94,7 @@ func NewImageDetailSummaryDto(src *image.InspectResponse) ImageDetailSummaryDtoout.Id = src.IDout.RepoTags = append(out.RepoTags, src.RepoTags...)out.RepoDigests = append(out.RepoDigests, src.RepoDigests...)- out.Parent = src.Parentout.Comment = src.Comment- out.Created = src.Created- out.DockerVersion = src.DockerVersionout.Author = src.Authorif src.Config != nil {diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 016b0bb58..2b24b25c8 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -1263,5 +1263,6 @@"customize_secret_variables": "Secret Variables","customize_variable_templates": "Variable Templates","duplicate": "Duplicate",- "cancel": "Cancel"+ "cancel": "Cancel",+ "compose_project_name_placeholder": "My New Project"}diff --git a/frontend/src/lib/components/dialogs/docker-info-dialog.svelte b/frontend/src/lib/components/dialogs/docker-info-dialog.svelteindex 589669b10..2c0c2061e 100644--- a/frontend/src/lib/components/dialogs/docker-info-dialog.svelte+++ b/frontend/src/lib/components/dialogs/docker-info-dialog.svelte@@ -8,30 +8,29 @@import CpuIcon from '@lucide/svelte/icons/cpu';import HardDriveIcon from '@lucide/svelte/icons/hard-drive';import type { DockerInfo } from '$lib/types/docker-info.type';- import { toast } from 'svelte-sonner';+ import { UseClipboard } from '$lib/hooks/use-clipboard.svelte';import { m } from '$lib/paraglide/messages';import bytes from 'bytes';- let {- open = $bindable(),- dockerInfo- }: {+ interface Props {open: boolean;dockerInfo: DockerInfo | null;- } = $props();+ }++ let { open = $bindable(), dockerInfo }: Props = $props();++ const clipboard = new UseClipboard();- async function copy(text?: string) {+ const shortGitCommit = $derived(dockerInfo?.gitCommit?.slice(0, 8) ?? '-');+ const formattedMemory = $derived(dockerInfo?.memTotal ? bytes.format(dockerInfo.memTotal) : '-');++ function handleCopy(text?: string) {if (!text) return;- try {- await navigator.clipboard.writeText(text);- toast.success(m.common_copied());- } catch {- toast.error(m.common_copy_failed());- }+ clipboard.copy(text);}- function formatMemory(bytes_val: number): string {- return bytes.format(bytes_val) ?? '-';+ function handleClose() {+ open = false;}</script>@@ -46,141 +45,156 @@</Dialog.Header><div class="min-h-0 flex-1 space-y-4 overflow-y-auto py-4">- <div>- <h3 class="mb-2 flex items-center gap-2 text-sm font-semibold">- <ServerIcon class="size-4" />- {m.docker_info_version_section()}- </h3>- <div class="bg-muted/50 space-y-1.5 rounded-lg p-3">- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_version_label()}</span>- <Badge variant="outline">{dockerInfo?.version ?? '-'}</Badge>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_api_version_label()}</span>- <span class="font-mono text-sm">{dockerInfo?.apiVersion ?? '-'}</span>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_server_version_label()}</span>- <span class="font-mono text-sm">{dockerInfo?.serverVersion ?? '-'}</span>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_git_commit_label()}</span>- <div class="flex items-center gap-2">- <span class="font-mono text-sm">{dockerInfo?.gitCommit?.slice(0, 8) ?? '-'}</span>- {#if dockerInfo?.gitCommit}- <Button variant="ghost" size="icon" class="size-6" onclick={() => copy(dockerInfo?.gitCommit)}>- <CopyIcon class="size-3" />- </Button>- {/if}- </div>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_go_version_label()}</span>- <span class="font-mono text-sm">{dockerInfo?.goVersion ?? '-'}</span>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_build_time_label()}</span>- <span class="text-sm">{dockerInfo?.buildTime ?? '-'}</span>- </div>- </div>- </div>+ {@render versionSection()}+ {@render systemSection()}+ {@render driversSection()}+ {@render statsSection()}+ </div>++ <Dialog.Footer class="flex-shrink-0 border-t pt-3">+ <Button variant="outline" onclick={handleClose}>+ {m.common_close()}+ </Button>+ </Dialog.Footer>+ </Dialog.Content>+</Dialog.Root>- <div>- <h3 class="mb-2 flex items-center gap-2 text-sm font-semibold">- <CpuIcon class="size-4" />- {m.docker_info_system_section()}- </h3>- <div class="bg-muted/50 space-y-1.5 rounded-lg p-3">- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_os_label()}</span>- <span class="font-mono text-sm">{dockerInfo?.operatingSystem ?? '-'}</span>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_os_type_label()}</span>- <span class="text-sm">{dockerInfo?.os ?? '-'}</span>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_os_version_label()}</span>- <span class="font-mono text-sm">{dockerInfo?.osVersion ?? '-'}</span>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_architecture_label()}</span>- <Badge>{dockerInfo?.architecture ?? '-'}</Badge>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_kernel_version_label()}</span>- <span class="font-mono text-sm">{dockerInfo?.kernelVersion ?? '-'}</span>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_cpus_label()}</span>- <Badge variant="secondary">{dockerInfo?.cpus ?? 0}</Badge>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_memory_label()}</span>- <Badge variant="secondary">{formatMemory(dockerInfo?.memTotal ?? 0)}</Badge>- </div>+{#snippet versionSection()}+ <div>+ <h3 class="mb-2 flex items-center gap-2 text-sm font-semibold">+ <ServerIcon class="size-4" />+ {m.docker_info_version_section()}+ </h3>+ <div class="bg-muted/50 space-y-1.5 rounded-lg p-3">+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_version_label()}</span>+ <Badge variant="outline">{dockerInfo?.version ?? '-'}</Badge>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_api_version_label()}</span>+ <span class="font-mono text-sm">{dockerInfo?.apiVersion ?? '-'}</span>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_server_version_label()}</span>+ <span class="font-mono text-sm">{dockerInfo?.serverVersion ?? '-'}</span>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_git_commit_label()}</span>+ <div class="flex items-center gap-2">+ <span class="font-mono text-sm">{shortGitCommit}</span>+ {#if dockerInfo?.gitCommit}+ <Button variant="ghost" size="icon" class="size-6" onclick={() => handleCopy(dockerInfo?.gitCommit)}>+ <CopyIcon class="size-3" />+ </Button>+ {/if}</div></div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_go_version_label()}</span>+ <span class="font-mono text-sm">{dockerInfo?.goVersion ?? '-'}</span>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_build_time_label()}</span>+ <span class="text-sm">{dockerInfo?.buildTime ?? '-'}</span>+ </div>+ </div>+ </div>+{/snippet}- <div>- <h3 class="mb-2 flex items-center gap-2 text-sm font-semibold">- <HardDriveIcon class="size-4" />- {m.docker_info_drivers_section()}- </h3>- <div class="bg-muted/50 space-y-1.5 rounded-lg p-3">- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_storage_driver_label()}</span>- <Badge variant="outline">{dockerInfo?.storageDriver ?? '-'}</Badge>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_logging_driver_label()}</span>- <span class="text-sm">{dockerInfo?.loggingDriver ?? '-'}</span>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_cgroup_driver_label()}</span>- <span class="text-sm">{dockerInfo?.cgroupDriver ?? '-'}</span>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_cgroup_version_label()}</span>- <span class="text-sm">{dockerInfo?.cgroupVersion ?? '-'}</span>- </div>- </div>+{#snippet systemSection()}+ <div>+ <h3 class="mb-2 flex items-center gap-2 text-sm font-semibold">+ <CpuIcon class="size-4" />+ {m.docker_info_system_section()}+ </h3>+ <div class="bg-muted/50 space-y-1.5 rounded-lg p-3">+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_os_label()}</span>+ <span class="font-mono text-sm">{dockerInfo?.operatingSystem ?? '-'}</span>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_os_type_label()}</span>+ <span class="text-sm">{dockerInfo?.os ?? '-'}</span></div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_os_version_label()}</span>+ <span class="font-mono text-sm">{dockerInfo?.osVersion ?? '-'}</span>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_architecture_label()}</span>+ <Badge>{dockerInfo?.architecture ?? '-'}</Badge>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_kernel_version_label()}</span>+ <span class="font-mono text-sm">{dockerInfo?.kernelVersion ?? '-'}</span>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_cpus_label()}</span>+ <Badge variant="secondary">{dockerInfo?.cpus ?? 0}</Badge>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_memory_label()}</span>+ <Badge variant="secondary">{formattedMemory}</Badge>+ </div>+ </div>+ </div>+{/snippet}- <div>- <h3 class="mb-2 text-sm font-semibold">{m.docker_info_stats_section()}</h3>- <div class="bg-muted/50 space-y-1.5 rounded-lg p-3">- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_total_containers_label()}</span>- <Badge variant="secondary">{dockerInfo?.containers ?? 0}</Badge>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_running_label()}</span>- <Badge class="border-emerald-500/30 bg-emerald-500/15 text-emerald-600">- {dockerInfo?.containersRunning ?? 0}- </Badge>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_paused_label()}</span>- <Badge class="border-amber-500/30 bg-amber-500/15 text-amber-600">- {dockerInfo?.containersPaused ?? 0}- </Badge>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_stopped_label()}</span>- <Badge variant="outline">{dockerInfo?.containersStopped ?? 0}</Badge>- </div>- <div class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{m.docker_info_images_label()}</span>- <Badge variant="outline">{dockerInfo?.images ?? 0}</Badge>- </div>- </div>+{#snippet driversSection()}+ <div>+ <h3 class="mb-2 flex items-center gap-2 text-sm font-semibold">+ <HardDriveIcon class="size-4" />+ {m.docker_info_drivers_section()}+ </h3>+ <div class="bg-muted/50 space-y-1.5 rounded-lg p-3">+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_storage_driver_label()}</span>+ <Badge variant="outline">{dockerInfo?.storageDriver ?? '-'}</Badge>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_logging_driver_label()}</span>+ <span class="text-sm">{dockerInfo?.loggingDriver ?? '-'}</span>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_cgroup_driver_label()}</span>+ <span class="text-sm">{dockerInfo?.cgroupDriver ?? '-'}</span>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_cgroup_version_label()}</span>+ <span class="text-sm">{dockerInfo?.cgroupVersion ?? '-'}</span></div></div>+ </div>+{/snippet}- <Dialog.Footer class="flex-shrink-0 border-t pt-3">- <Button variant="outline" onclick={() => (open = false)}>{m.common_close()}</Button>- </Dialog.Footer>- </Dialog.Content>-</Dialog.Root>+{#snippet statsSection()}+ <div>+ <h3 class="mb-2 text-sm font-semibold">{m.docker_info_stats_section()}</h3>+ <div class="bg-muted/50 space-y-1.5 rounded-lg p-3">+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_total_containers_label()}</span>+ <Badge variant="secondary">{dockerInfo?.containers ?? 0}</Badge>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_running_label()}</span>+ <Badge class="border-emerald-500/30 bg-emerald-500/15 text-emerald-600">+ {dockerInfo?.containersRunning ?? 0}+ </Badge>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_paused_label()}</span>+ <Badge class="border-amber-500/30 bg-amber-500/15 text-amber-600">+ {dockerInfo?.containersPaused ?? 0}+ </Badge>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_stopped_label()}</span>+ <Badge variant="outline">{dockerInfo?.containersStopped ?? 0}</Badge>+ </div>+ <div class="flex items-center justify-between">+ <span class="text-muted-foreground text-sm">{m.docker_info_images_label()}</span>+ <Badge variant="outline">{dockerInfo?.images ?? 0}</Badge>+ </div>+ </div>+ </div>+{/snippet}diff --git a/frontend/src/lib/components/dialogs/event-details-dialog.svelte b/frontend/src/lib/components/dialogs/event-details-dialog.svelteindex 6b57589b9..353106eb9 100644--- a/frontend/src/lib/components/dialogs/event-details-dialog.svelte+++ b/frontend/src/lib/components/dialogs/event-details-dialog.svelte@@ -12,201 +12,195 @@import ServerIcon from '@lucide/svelte/icons/server';import TagIcon from '@lucide/svelte/icons/tag';import type { Event } from '$lib/types/event.type';- import { toast } from 'svelte-sonner';+ import { UseClipboard } from '$lib/hooks/use-clipboard.svelte';import { m } from '$lib/paraglide/messages';- let {- open = $bindable(),- event- }: {+ type Severity = 'success' | 'warning' | 'error' | 'info';++ interface Props {open: boolean;event: Event | null;- } = $props();+ }++ let { open = $bindable(), event }: Props = $props();++ const clipboard = new UseClipboard();++ const hasMetadata = $derived(!!event?.metadata && Object.keys(event.metadata ?? {}).length > 0);+ const eventJson = $derived.by(() => JSON.stringify(event ?? {}, null, 2));+ const metadataJson = $derived.by(() => JSON.stringify(event?.metadata ?? {}, null, 2));+ const formattedTimestamp = $derived(event?.timestamp ? formatDate(event.timestamp) : null);+ const severity = $derived((event?.severity ?? 'info') as Severity);- function formatDate(ts?: string) {- if (!ts) return '-';+ function formatDate(timestamp: string): string {try {- return new Date(ts).toLocaleString();+ return new Date(timestamp).toLocaleString();} catch {- return ts;+ return timestamp;}}- async function copy(text?: string) {- if (!text) return;- try {- await navigator.clipboard.writeText(text);- toast.success(m.common_copied());- } catch {- toast.error(m.common_copy_failed());- }+ function getSeverityIconClass(sev: Severity): string {+ const baseClasses: Record<Severity, string> = {+ success: 'text-emerald-600 dark:text-emerald-400',+ warning: 'text-amber-600 dark:text-amber-400',+ error: 'text-red-600 dark:text-red-400',+ info: 'text-blue-600 dark:text-blue-400'+ };+ return baseClasses[sev];}- const hasMetadata = $derived(!!event?.metadata && Object.keys(event.metadata ?? {}).length > 0);- const jsonPretty = $derived(() => JSON.stringify(event ?? {}, null, 2));- const metadataPretty = $derived(() => JSON.stringify(event?.metadata ?? {}, null, 2));-- function sevColor(sev?: string) {- switch (sev) {- case 'success':- return 'text-emerald-600 dark:text-emerald-400';- case 'warning':- return 'text-amber-600 dark:text-amber-400';- case 'error':- return 'text-red-600 dark:text-red-400';- default:- return 'text-blue-600 dark:text-blue-400';- }+ function getSeverityBadgeClass(sev: Severity): string {+ const baseClasses: Record<Severity, string> = {+ success: 'bg-emerald-500/15 text-emerald-600 border-emerald-500/30 dark:text-emerald-300',+ warning: 'bg-amber-500/15 text-amber-700 border-amber-500/30 dark:text-amber-300',+ error: 'bg-red-500/15 text-red-600 border-red-500/30 dark:text-red-300',+ info: 'bg-blue-500/15 text-blue-700 border-blue-500/30 dark:text-blue-300'+ };+ return baseClasses[sev];}- function sevBadge(sev?: string) {- switch (sev) {- case 'success':- return 'bg-emerald-500/15 text-emerald-600 border-emerald-500/30 dark:text-emerald-300';- case 'warning':- return 'bg-amber-500/15 text-amber-700 border-amber-500/30 dark:text-amber-300';- case 'error':- return 'bg-red-500/15 text-red-600 border-red-500/30 dark:text-red-300';- default:- return 'bg-blue-500/15 text-blue-700 border-blue-500/30 dark:text-blue-300';- }++ function handleCopy(text?: string) {+ if (!text) return;+ clipboard.copy(text);+ }++ function handleClose() {+ open = false;}</script><Dialog.Root bind:open><Dialog.Content class="bg-card flex max-h-[90vh] flex-col rounded-xl border shadow-xl sm:max-w-[980px]">- <!-- Header --><Dialog.Header class="flex-shrink-0 border-b p-4">- <div class="flex items-start gap-3">- <div class="mt-0.5">- {#if event?.severity === 'success'}- <CheckCircle2Icon class={sevColor(event?.severity) + ' size-6'} />- {:else if event?.severity === 'warning'}- <TriangleAlertIcon class={sevColor(event?.severity) + ' size-6'} />- {:else if event?.severity === 'error'}- <XCircleIcon class={sevColor(event?.severity) + ' size-6'} />- {:else}- <InfoIcon class={sevColor(event?.severity) + ' size-6'} />- {/if}- </div>- <div class="min-w-0 flex-1">- <Dialog.Title class="text-xl font-semibold">- {event?.title ?? m.events_details_title()}- </Dialog.Title>- {#if event?.description}- <Dialog.Description class="text-muted-foreground mt-1 text-sm">- {event.description}- </Dialog.Description>- {/if}- <div class="mt-3 flex flex-wrap items-center gap-2">- <Badge class={'border ' + sevBadge(event?.severity)}>- {event?.severity ?? m.common_unknown()}- </Badge>- <Badge variant="outline" class="gap-1">- <TagIcon class="size-3" />- {event?.type ?? m.common_unknown()}- </Badge>- {#if event?.environmentId}- <Badge variant="outline" class="gap-1">- <ServerIcon class="size-3" />- {m.events_environment_label()}: {event.environmentId ?? m.common_unknown()}- </Badge>- {/if}- {#if event?.timestamp}- <span class="text-muted-foreground inline-flex items-center gap-1 text-xs">- <ClockIcon class="size-3" />- {formatDate(event.timestamp)}- </span>- {/if}- </div>- </div>- </div>+ {@render headerContent()}</Dialog.Header><div class="min-h-0 flex-1 space-y-4 overflow-y-auto p-4">- <div class="grid gap-4 md:grid-cols-2 lg:grid-cols-3">- <div class="rounded-lg border p-3">- <div class="text-muted-foreground text-xs">{m.events_resource_id_label()}</div>- <div class="mt-1 flex items-center justify-between gap-2">- <div class="break-all text-sm">{event?.resourceType || '-'}</div>- <Button- variant="ghost"- size="icon"- class="size-7"- onclick={() => copy(event?.resourceType)}- title={m.events_copy_resource_id_title()}- >- <CopyIcon class="size-4" />- </Button>- </div>- </div>-- <div class="rounded-lg border p-3">- <div class="text-muted-foreground text-xs">{m.events_resource_name_label()}</div>- <div class="mt-1 flex items-center justify-between gap-2">- <div class="break-all text-sm">{event?.resourceName || '-'}</div>- <Button- variant="ghost"- size="icon"- class="size-7"- onclick={() => copy(event?.resourceName)}- title={m.events_copy_resource_name_title()}- >- <CopyIcon class="size-4" />- </Button>- </div>- </div>-- <div class="rounded-lg border p-3">- <div class="text-muted-foreground text-xs">{m.common_user()}</div>- <div class="mt-1 flex items-center gap-2 text-sm">- <UserIcon class="text-muted-foreground size-4" />- {event?.username ?? m.common_unknown()}- </div>- </div>- </div>+ {@render infoCards()}+ {@render metadataSection()}+ {@render rawEventSection()}+ </div>++ <Dialog.Footer class="flex flex-shrink-0 items-center justify-end gap-2 border-t p-3">+ <Button variant="outline" onclick={handleClose}>+ {m.common_close()}+ </Button>+ </Dialog.Footer>+ </Dialog.Content>+</Dialog.Root>- <div class="rounded-lg border">- <div class="flex items-center justify-between border-b px-3 py-2">- <h3 class="text-sm font-medium">{m.events_metadata_title()}</h3>- <Button- variant="outline"- size="sm"- onclick={() => copy(metadataPretty())}- disabled={!hasMetadata}- title="Copy metadata JSON"- >- <CopyIcon class="mr-2 size-3" />- {m.common_copy_json()}- </Button>- </div>- {#if hasMetadata}- <pre class="bg-muted/40 max-h-[40vh] overflow-auto p-3 text-xs leading-relaxed">-<code class="font-mono">{metadataPretty()}</code>-</pre>- {:else}- <div class="text-muted-foreground p-3 text-xs">{m.events_no_metadata_provided()}</div>+{#snippet headerContent()}+ <div class="flex items-start gap-3">+ <div class="mt-0.5">+ {#if severity === 'success'}+ <CheckCircle2Icon class={getSeverityIconClass(severity) + ' size-6'} />+ {:else if severity === 'warning'}+ <TriangleAlertIcon class={getSeverityIconClass(severity) + ' size-6'} />+ {:else if severity === 'error'}+ <XCircleIcon class={getSeverityIconClass(severity) + ' size-6'} />+ {:else}+ <InfoIcon class={getSeverityIconClass(severity) + ' size-6'} />+ {/if}+ </div>+ <div class="min-w-0 flex-1">+ <Dialog.Title class="text-xl font-semibold">+ {event?.title ?? m.events_details_title()}+ </Dialog.Title>+ {#if event?.description}+ <Dialog.Description class="text-muted-foreground mt-1 text-sm">+ {event.description}+ </Dialog.Description>+ {/if}+ <div class="mt-3 flex flex-wrap items-center gap-2">+ <Badge class={`border ${getSeverityBadgeClass(severity)}`}>+ {event?.severity ?? m.common_unknown()}+ </Badge>+ <Badge variant="outline" class="gap-1">+ <TagIcon class="size-3" />+ {event?.type ?? m.common_unknown()}+ </Badge>+ {#if event?.environmentId}+ <Badge variant="outline" class="gap-1">+ <ServerIcon class="size-3" />+ {m.events_environment_label()}: {event.environmentId}+ </Badge>+ {/if}+ {#if formattedTimestamp}+ <span class="text-muted-foreground inline-flex items-center gap-1 text-xs">+ <ClockIcon class="size-3" />+ {formattedTimestamp}+ </span>{/if}</div>+ </div>+ </div>+{/snippet}++{#snippet infoCards()}+ <div class="grid gap-4 md:grid-cols-2 lg:grid-cols-3">+ {@render infoCard(m.events_resource_id_label(), event?.resourceId, m.events_copy_resource_id_title())}+ {@render infoCard(m.events_resource_name_label(), event?.resourceName, m.events_copy_resource_name_title())}- <div class="rounded-lg border">- <div class="flex items-center justify-between border-b px-3 py-2">- <h3 class="text-sm font-medium">{m.events_raw_event_title()}</h3>- <Button variant="outline" size="sm" onclick={() => copy(jsonPretty())} title={m.events_copy_full_event_json_title()}>- <CopyIcon class="mr-2 size-3" />- {m.common_copy_json()}- </Button>- </div>- <pre class="bg-muted/40 max-h-[40vh] overflow-auto p-3 text-xs leading-relaxed">-<code class="font-mono">{jsonPretty()}</code>-</pre>+ <div class="rounded-lg border p-3">+ <div class="text-muted-foreground text-xs">{m.common_user()}</div>+ <div class="mt-1 flex items-center gap-2 text-sm">+ <UserIcon class="text-muted-foreground size-4" />+ {event?.username ?? m.common_unknown()}</div></div>+ </div>+{/snippet}- <Dialog.Footer class="flex flex-shrink-0 items-center justify-end gap-2 border-t p-3">- <Button variant="outline" onclick={() => (open = false)}>{m.common_close()}</Button>- </Dialog.Footer>- </Dialog.Content>-</Dialog.Root>+{#snippet infoCard(label: string, value: string | undefined, copyTitle: string)}+ <div class="rounded-lg border p-3">+ <div class="text-muted-foreground text-xs">{label}</div>+ <div class="mt-1 flex items-center justify-between gap-2">+ <div class="break-all text-sm">{value || '-'}</div>+ <Button variant="ghost" size="icon" class="size-7" onclick={() => handleCopy(value)} title={copyTitle}>+ <CopyIcon class="size-4" />+ </Button>+ </div>+ </div>+{/snippet}++{#snippet metadataSection()}+ <div class="rounded-lg border">+ <div class="flex items-center justify-between border-b px-3 py-2">+ <h3 class="text-sm font-medium">{m.events_metadata_title()}</h3>+ <Button+ variant="outline"+ size="sm"+ onclick={() => handleCopy(metadataJson)}+ disabled={!hasMetadata}+ title="Copy metadata JSON"+ >+ <CopyIcon class="mr-2 size-3" />+ {m.common_copy_json()}+ </Button>+ </div>+ {#if hasMetadata}+ <pre class="bg-muted/40 max-h-[40vh] overflow-auto p-3 text-xs leading-relaxed"><code class="font-mono">{metadataJson}</code+ ></pre>+ {:else}+ <div class="text-muted-foreground p-3 text-xs">{m.events_no_metadata_provided()}</div>+ {/if}+ </div>+{/snippet}++{#snippet rawEventSection()}+ <div class="rounded-lg border">+ <div class="flex items-center justify-between border-b px-3 py-2">+ <h3 class="text-sm font-medium">{m.events_raw_event_title()}</h3>+ <Button variant="outline" size="sm" onclick={() => handleCopy(eventJson)} title={m.events_copy_full_event_json_title()}>+ <CopyIcon class="mr-2 size-3" />+ {m.common_copy_json()}+ </Button>+ </div>+ <pre class="bg-muted/40 max-h-[40vh] overflow-auto p-3 text-xs leading-relaxed"><code class="font-mono">{eventJson}</code+ ></pre>+ </div>+{/snippet}<style>/* Lock background scroll while dialog is open; no animations/effects */diff --git a/frontend/src/lib/components/dialogs/oidc-config-dialog.svelte b/frontend/src/lib/components/dialogs/oidc-config-dialog.svelteindex 6a546a8d5..9d066e83e 100644--- a/frontend/src/lib/components/dialogs/oidc-config-dialog.svelte+++ b/frontend/src/lib/components/dialogs/oidc-config-dialog.svelte@@ -1,88 +1,84 @@<script lang="ts">import { Button } from '$lib/components/ui/button/index.js';import { Input } from '$lib/components/ui/input/index.js';+ import { Label } from '$lib/components/ui/label/index.js';+ import * as Dialog from '$lib/components/ui/dialog/index.js';import KeyIcon from '@lucide/svelte/icons/key';import TriangleAlertIcon from '@lucide/svelte/icons/triangle-alert';import InfoIcon from '@lucide/svelte/icons/info';import CopyIcon from '@lucide/svelte/icons/copy';- import * as Dialog from '$lib/components/ui/dialog/index.js';- import { Label } from '$lib/components/ui/label/index.js';- import { toast } from 'svelte-sonner';- import type { Settings } from '$lib/types/settings.type';- import type { OidcStatusInfo } from '$lib/types/settings.type';import { m } from '$lib/paraglide/messages';+ import type { Settings, OidcStatusInfo } from '$lib/types/settings.type';+ import { UseClipboard } from '$lib/hooks/use-clipboard.svelte';- interface OidcForm {+ interface OidcConfig {clientId: string;clientSecret: string;issuerUrl: string;scopes: string;- adminClaim?: string;- adminValue?: string;+ adminClaim: string;+ adminValue: string;}- let {- open = $bindable(),- currentSettings,- oidcStatus,- oidcForm = $bindable(),- onSave- }: {+ interface Props {open: boolean;currentSettings: Settings;oidcStatus: OidcStatusInfo;- oidcForm: OidcForm;+ oidcForm: OidcConfig;onSave: () => void;- } = $props();+ }- let isOidcViewMode = $derived(oidcStatus.envForced && oidcStatus.envConfigured);- let redirectUri = $derived(`${globalThis?.location?.origin ?? ''}/auth/oidc/callback`);+ let { open = $bindable(), currentSettings, oidcStatus, oidcForm = $bindable(), onSave }: Props = $props();- let parsedOidcConfig = $derived(() => {- if (!currentSettings.authOidcConfig) {- return {- clientId: '',- clientSecret: '',- issuerUrl: '',- scopes: 'openid email profile',- adminClaim: '',- adminValue: ''- };- }+ const DEFAULT_CONFIG: OidcConfig = {+ clientId: '',+ clientSecret: '',+ issuerUrl: '',+ scopes: 'openid email profile',+ adminClaim: '',+ adminValue: ''+ };++ const isViewMode = $derived(oidcStatus.envForced && oidcStatus.envConfigured);+ const isWarningMode = $derived(oidcStatus.envForced && !oidcStatus.envConfigured);+ const redirectUri = $derived(`${globalThis?.location?.origin ?? ''}/auth/oidc/callback`);++ const parsedConfig = $derived.by(() => {+ if (!currentSettings.authOidcConfig) return DEFAULT_CONFIG;try {- return JSON.parse(currentSettings.authOidcConfig);+ return JSON.parse(currentSettings.authOidcConfig) as OidcConfig;} catch (error) {console.warn('Failed to parse OIDC config:', error);- return {- clientId: '',- clientSecret: '',- issuerUrl: '',- scopes: 'openid email profile',- adminClaim: '',- adminValue: ''- };+ return DEFAULT_CONFIG;}});- const statusItems = $derived([- { label: m.oidc_status_env_forced(), value: oidcStatus.envForced, hint: m.oidc_status_env_forced_hint() },- { label: m.oidc_status_env_configured(), value: oidcStatus.envConfigured, hint: m.oidc_status_env_configured_hint() }- ]);+ const dialogTitle = $derived(+ isViewMode+ ? m.security_oidc_configured_forced_view()+ : isWarningMode+ ? m.security_server_forces_oidc_missing_env()+ : m.security_manage_oidc_config()+ );++ const dialogDescription = $derived(+ isViewMode+ ? m.oidc_viewmode_description()+ : isWarningMode+ ? m.security_server_forces_oidc_missing_env()+ : m.oidc_configure_description()+ );- function chipClass(v: boolean) {- return v- ? 'bg-emerald-500/10 text-emerald-500 ring-1 ring-emerald-500/20'- : 'bg-muted text-muted-foreground ring-1 ring-border';+ const clipboard = new UseClipboard();++ function handleCopy(text?: string) {+ if (!text) return;+ clipboard.copy(text);}- async function copyToClipboard(text: string) {- try {- await navigator.clipboard.writeText(text);- toast.success(m.common_copied());- } catch {- toast.error(m.common_copy_failed());- }+ function handleClose() {+ open = false;}</script>@@ -93,226 +89,186 @@<span class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-md ring-1"><KeyIcon class="size-4" /></span>- {#if isOidcViewMode}- {m.security_oidc_configured_forced_view()}- {:else if oidcStatus.envForced && !oidcStatus.envConfigured}- {m.security_server_forces_oidc_missing_env()}- {:else}- {m.security_manage_oidc_config()}- {/if}+ {dialogTitle}</Dialog.Title><Dialog.Description class="text-sm leading-relaxed">- {#if isOidcViewMode}- {m.oidc_viewmode_description()}- {:else if oidcStatus.envForced && !oidcStatus.envConfigured}- {m.security_server_forces_oidc_missing_env()}- {:else}- {m.oidc_configure_description()}- {/if}+ {dialogDescription}</Dialog.Description></Dialog.Header><div class="min-h-0 flex-1 overflow-y-auto py-4">- <div class="grid gap-6 lg:grid-cols-[1fr_18rem]">- <!-- Main column -->- <div class="space-y-6">- {#if isOidcViewMode}- <div class="bg-card/50 rounded-lg border p-4">- <h3 class="text-base font-semibold">{m.oidc_server_env_config_title()}</h3>- <p class="text-muted-foreground mb-4 mt-1 text-sm">{m.oidc_server_env_config_description()}</p>-- {#if currentSettings.authOidcEnabled}- <div class="divide-border/60 divide-y text-sm">- <div class="flex items-center justify-between py-2">- <span class="font-medium">{m.oidc_client_id_label()}</span>- <code class="bg-muted rounded px-2 py-1 text-xs">{parsedOidcConfig().clientId || m.common_unknown()}</code>- </div>- <div class="flex items-center justify-between py-2">- <span class="font-medium">{m.oidc_issuer_url_label()}</span>- <code class="bg-muted rounded px-2 py-1 text-xs">{parsedOidcConfig().issuerUrl || m.common_unknown()}</code>- </div>- <div class="flex items-center justify-between py-2">- <span class="font-medium">{m.oidc_client_secret_label()}</span>- <span class="text-muted-foreground text-xs italic">{m.oidc_client_secret_hidden()}</span>- </div>- <div class="flex items-center justify-between py-2">- <code class="bg-muted rounded px-2 py-1 text-xs">{parsedOidcConfig().scopes || 'openid email profile'}</code>- <span class="font-medium">{m.oidc_scopes_label()}</span>+ <div class="space-y-6">+ {#if isViewMode}+ {@render viewModeContent()}+ {:else}+ {@render editModeContent()}+ {/if}- <code class="bg-muted rounded px-2 py-1 text-xs"- >{parsedOidcConfig().scopes || m.oidc_scopes_placeholder()}</code- >- </div>- <div class="flex items-center justify-between py-2">- <span class="font-medium">{m.oidc_admin_claim_label()}</span>+ {#if isWarningMode}+ {@render warningBanner()}+ {/if}- <code class="bg-muted rounded px-2 py-1 text-xs">{parsedOidcConfig().adminClaim || m.common_unknown()}</code>- </div>- <div class="flex items-center justify-between py-2">- <span class="font-medium">{m.oidc_admin_value_label()}</span>+ {@render redirectUriSection()}+ </div>+ </div>- <code class="bg-muted rounded px-2 py-1 text-xs">{parsedOidcConfig().adminValue || m.common_unknown()}</code>- </div>- </div>- {:else}- <div class="py-6 text-center">- <TriangleAlertIcon class="text-destructive mx-auto mb-2 size-8" />- <p class="text-destructive text-sm font-medium">{m.oidc_env_config_missing()}</p>- </div>- {/if}+ <Dialog.Footer class="flex flex-shrink-0 gap-3 border-t pt-4">+ <Button variant="outline" onclick={handleClose} class="flex-1 sm:flex-none">+ {m.common_close()}+ </Button>+ {#if !isViewMode}+ <Button onclick={onSave} class="flex-1 sm:flex-none">+ <KeyIcon class="mr-2 size-4" />+ {m.common_save()}+ </Button>+ {/if}+ </Dialog.Footer>+ </Dialog.Content>+</Dialog.Root>- <div class="bg-muted/40 mt-4 rounded-md p-3">- <p class="text-muted-foreground text-xs">{m.oidc_env_changes_note()}</p>- </div>- </div>- {:else}- <!-- Editable form -->- <div class="bg-card/50 rounded-lg border p-4">- <h3 class="text-base font-semibold">{m.oidc_basic_configuration_title()}</h3>- <p class="text-muted-foreground mb-4 mt-1 text-sm">{m.oidc_basic_description()}</p>+{#snippet viewModeContent()}+ <div class="bg-card/50 rounded-lg border p-4">+ <h3 class="text-base font-semibold">{m.oidc_server_env_config_title()}</h3>+ <p class="text-muted-foreground mb-4 mt-1 text-sm">{m.oidc_server_env_config_description()}</p>- <div class="space-y-4">- <div class="space-y-2">- <Label for="oidcClientId" class="text-sm font-medium">{m.oidc_client_id_label()}</Label>- <Input- id="oidcClientId"- bind:value={oidcForm.clientId}- placeholder={m.oidc_client_id_placeholder()}- class="font-mono text-sm"- />- </div>+ {#if currentSettings.authOidcEnabled}+ <div class="divide-border/60 divide-y text-sm">+ {@render configRow(m.oidc_client_id_label(), parsedConfig.clientId)}+ {@render configRow(m.oidc_issuer_url_label(), parsedConfig.issuerUrl)}+ <div class="flex items-center justify-between py-2">+ <span class="font-medium">{m.oidc_client_secret_label()}</span>+ <span class="text-muted-foreground text-xs italic">{m.oidc_client_secret_hidden()}</span>+ </div>+ {@render configRow(m.oidc_scopes_label(), parsedConfig.scopes || m.oidc_scopes_placeholder())}+ {@render configRow(m.oidc_admin_claim_label(), parsedConfig.adminClaim)}+ {@render configRow(m.oidc_admin_value_label(), parsedConfig.adminValue)}+ </div>+ {:else}+ <div class="py-6 text-center">+ <TriangleAlertIcon class="text-destructive mx-auto mb-2 size-8" />+ <p class="text-destructive text-sm font-medium">{m.oidc_env_config_missing()}</p>+ </div>+ {/if}- <div class="space-y-2">- <Label for="oidcClientSecret" class="text-sm font-medium">{m.oidc_client_secret_label()}</Label>- <Input- id="oidcClientSecret"- type="password"- bind:value={oidcForm.clientSecret}- placeholder={m.oidc_client_secret_placeholder()}- class="font-mono text-sm"- />- </div>+ <div class="bg-muted/40 mt-4 rounded-md p-3">+ <p class="text-muted-foreground text-xs">{m.oidc_env_changes_note()}</p>+ </div>+ </div>+{/snippet}- <div class="space-y-2">- <Label for="oidcIssuerUrl" class="text-sm font-medium">{m.oidc_issuer_url_label()}</Label>- <Input- id="oidcIssuerUrl"- bind:value={oidcForm.issuerUrl}- placeholder={m.oidc_issuer_url_placeholder()}- class="font-mono text-sm"- />- <p class="text-muted-foreground text-xs">{m.oidc_issuer_url_description()}</p>- </div>+{#snippet configRow(label: string, value: string)}+ <div class="flex items-center justify-between py-2">+ <span class="font-medium">{label}</span>+ <code class="bg-muted rounded px-2 py-1 text-xs">{value || m.common_unknown()}</code>+ </div>+{/snippet}- <div class="space-y-2">- <Label for="oidcScopes" class="text-sm font-medium">{m.oidc_scopes_label()}</Label>- <Input- id="oidcScopes"- bind:value={oidcForm.scopes}- placeholder={m.oidc_scopes_placeholder()}- class="font-mono text-sm"- />- </div>+{#snippet editModeContent()}+ <div class="bg-card/50 rounded-lg border p-4">+ <h3 class="text-base font-semibold">{m.oidc_basic_configuration_title()}</h3>+ <p class="text-muted-foreground mb-4 mt-1 text-sm">{m.oidc_basic_description()}</p>- <div class="pt-2">- <h4 class="text-sm font-semibold">{m.oidc_admin_role_mapping_title()}</h4>- <p class="text-muted-foreground mb-3 text-xs">{m.oidc_admin_role_mapping_description()}</p>- <div class="grid gap-3 sm:grid-cols-2">- <div class="space-y-2">- <Label for="oidcAdminClaim" class="text-sm font-medium">{m.oidc_admin_claim_label()}</Label>- <Input- id="oidcAdminClaim"- bind:value={oidcForm.adminClaim}- placeholder={m.oidc_admin_claim_placeholder()}- class="font-mono text-sm"- />- </div>- <div class="space-y-2">- <Label for="oidcAdminValue" class="text-sm font-medium">{m.oidc_admin_value_label()}</Label>- <Input- id="oidcAdminValue"- bind:value={oidcForm.adminValue}- placeholder={m.oidc_admin_value_placeholder()}- class="font-mono text-sm"- />- <p class="text-muted-foreground text-[11px]">{m.oidc_admin_value_help()}</p>- </div>- </div>- </div>- </div>- </div>+ <div class="space-y-4">+ <div class="space-y-2">+ <Label for="oidcClientId" class="text-sm font-medium">{m.oidc_client_id_label()}</Label>+ <Input+ id="oidcClientId"+ type="text"+ placeholder={m.oidc_client_id_placeholder()}+ bind:value={oidcForm.clientId}+ class="font-mono text-sm"+ />+ </div>- {#if oidcStatus.envForced && !oidcStatus.envConfigured}- <div class="border-destructive/50 bg-destructive/5 rounded-lg border p-4">- <div class="mb-2 flex items-center gap-2">- <TriangleAlertIcon class="text-destructive size-4" />- <h3 class="text-destructive text-base font-semibold">{m.oidc_server_override_warning_title()}</h3>- </div>- <p class="text-destructive/80 text-sm">{m.security_server_forces_oidc_missing_env()}</p>- </div>- {/if}- {/if}+ <div class="space-y-2">+ <Label for="oidcClientSecret" class="text-sm font-medium">{m.oidc_client_secret_label()}</Label>+ <Input+ id="oidcClientSecret"+ type="password"+ placeholder={m.oidc_client_secret_placeholder()}+ bind:value={oidcForm.clientSecret}+ class="font-mono text-sm"+ />+ </div>- <!-- Redirect URI -->- <div class="bg-card/50 rounded-lg border p-4">- <div class="mb-3 flex items-center gap-2">- <InfoIcon class="size-4 text-blue-600" />- <h3 class="text-base font-semibold">{m.oidc_redirect_uri_title()}</h3>- </div>- <p class="text-muted-foreground mb-3 text-sm">{m.oidc_redirect_uri_description()}</p>- <div class="flex items-center gap-2">- <code class="bg-muted flex-1 break-all rounded p-2 font-mono text-xs">{redirectUri}</code>- <Button- size="sm"- variant="outline"- onclick={() => copyToClipboard(redirectUri)}- class="flex-shrink-0"- title={m.common_copy()}- >- <CopyIcon class="size-3" />- </Button>- </div>- </div>- </div>+ <div class="space-y-2">+ <Label for="oidcIssuerUrl" class="text-sm font-medium">{m.oidc_issuer_url_label()}</Label>+ <Input+ id="oidcIssuerUrl"+ type="text"+ placeholder={m.oidc_issuer_url_placeholder()}+ bind:value={oidcForm.issuerUrl}+ class="font-mono text-sm"+ />+ <p class="text-muted-foreground text-xs">{m.oidc_issuer_url_description()}</p>+ </div>- <!-- Side panel (lg+) -->- <aside class="hidden lg:block">- <div class="sticky top-4 space-y-4">- <div class="bg-card/50 rounded-lg border p-4">- <h3 class="text-sm font-semibold">{m.oidc_status_title()}</h3>- <ul class="mt-3 space-y-2">- {#each statusItems as s (s.label)}- <li class="flex items-center justify-between">- <span class="text-muted-foreground text-sm">{s.label}</span>- <span class={'rounded px-2 py-0.5 text-xs ring-1 ' + chipClass(s.value)}- >{s.value ? m.common_yes() : m.common_no()}</span- >- </li>- {/each}- </ul>- </div>+ <div class="space-y-2">+ <Label for="oidcScopes" class="text-sm font-medium">{m.oidc_scopes_label()}</Label>+ <Input+ id="oidcScopes"+ type="text"+ placeholder={m.oidc_scopes_placeholder()}+ bind:value={oidcForm.scopes}+ class="font-mono text-sm"+ />+ </div>- <div class="bg-card/50 rounded-lg border p-4">- <h3 class="text-sm font-semibold">{m.oidc_tips_title()}</h3>- <ul class="text-muted-foreground mt-3 list-disc space-y-1 pl-5 text-xs">- <li>{m.oidc_tip_1()}</li>- <li>{m.oidc_tip_2()}</li>- <li>{m.oidc_tip_3()}</li>- </ul>- </div>+ <div class="pt-2">+ <h4 class="text-sm font-semibold">{m.oidc_admin_role_mapping_title()}</h4>+ <p class="text-muted-foreground mb-3 text-xs">{m.oidc_admin_role_mapping_description()}</p>+ <div class="grid gap-3 sm:grid-cols-2">+ <div class="space-y-2">+ <Label for="oidcAdminClaim" class="text-sm font-medium">{m.oidc_admin_claim_label()}</Label>+ <Input+ id="oidcAdminClaim"+ type="text"+ placeholder={m.oidc_admin_claim_placeholder()}+ bind:value={oidcForm.adminClaim}+ class="font-mono text-sm"+ />+ </div>+ <div class="space-y-2">+ <Label for="oidcAdminValue" class="text-sm font-medium">{m.oidc_admin_value_label()}</Label>+ <Input+ id="oidcAdminValue"+ type="text"+ placeholder={m.oidc_admin_value_placeholder()}+ bind:value={oidcForm.adminValue}+ class="font-mono text-sm"+ />+ <p class="text-muted-foreground text-[11px]">{m.oidc_admin_value_help()}</p></div>- </aside>+ </div></div></div>+ </div>+{/snippet}- <Dialog.Footer class="flex flex-shrink-0 gap-3 border-t pt-4">- <Button variant="outline" onclick={() => (open = false)} class="flex-1 sm:flex-none">{m.common_close()}</Button>- {#if !isOidcViewMode}- <Button onclick={onSave} class="flex-1 sm:flex-none">- <KeyIcon class="mr-2 size-4" />- {m.common_save()}- </Button>- {/if}- </Dialog.Footer>- </Dialog.Content>-</Dialog.Root>+{#snippet warningBanner()}+ <div class="border-destructive/50 bg-destructive/5 rounded-lg border p-4">+ <div class="mb-2 flex items-center gap-2">+ <TriangleAlertIcon class="text-destructive size-4" />+ <h3 class="text-destructive text-base font-semibold">+ {m.oidc_server_override_warning_title()}+ </h3>+ </div>+ <p class="text-destructive/80 text-sm">{m.security_server_forces_oidc_missing_env()}</p>+ </div>+{/snippet}++{#snippet redirectUriSection()}+ <div class="bg-card/50 rounded-lg border p-4">+ <div class="mb-3 flex items-center gap-2">+ <InfoIcon class="size-4 text-blue-600" />+ <h3 class="text-base font-semibold">{m.oidc_redirect_uri_title()}</h3>+ </div>+ <p class="text-muted-foreground mb-3 text-sm">{m.oidc_redirect_uri_description()}</p>+ <div class="flex items-center gap-2">+ <code class="bg-muted flex-1 break-all rounded p-2 font-mono text-xs">{redirectUri}</code>+ <Button size="sm" variant="outline" onclick={() => handleCopy(redirectUri)} class="flex-shrink-0" title={m.common_copy()}>+ <CopyIcon class="size-3" />+ </Button>+ </div>+ </div>+{/snippet}diff --git a/frontend/src/lib/components/dialogs/template-selection-dialog.svelte b/frontend/src/lib/components/dialogs/template-selection-dialog.svelteindex 5580bc29f..a978aba91 100644--- a/frontend/src/lib/components/dialogs/template-selection-dialog.svelte+++ b/frontend/src/lib/components/dialogs/template-selection-dialog.svelte@@ -31,81 +31,69 @@let { open = $bindable(), templates = [], onSelect, onDownloadSuccess }: Props = $props();- let loadingStates = $state(new Map<string, boolean>());- const allTemplates = $derived(templates ?? []);-+ let loadingStates = $state<Set<string>>(new Set());let sortBy = $state<'name-asc' | 'name-desc'>('name-asc');let groupByRegistry = $state(true);- function normalizeTags(template: Template): string[] {- const raw = template.metadata?.tags;- let list: unknown = raw;-- if (typeof raw === 'string') {- const s = raw.trim();- if (s.startsWith('[')) {- try {- list = JSON.parse(s);- } catch {- list = s.split(',').map((t) => t.trim());- }- } else {- list = s.split(',').map((t) => t.trim());- }- }+ const allTemplates = $derived(templates ?? []);- const arr = Array.isArray(list) ? list : [];- return arr- .map((t) => String(t).trim())- .filter(Boolean)- .map((t) => t.replace(/^["']|["']$/g, '')) // strip quotes- .map((t) => t.charAt(0).toUpperCase() + t.slice(1)); // capitalize first letter- }+ const sortedTemplates = $derived.by(() => {+ const sorted = [...allTemplates];+ sorted.sort((a, b) => (sortBy === 'name-asc' ? a.name.localeCompare(b.name) : b.name.localeCompare(a.name)));+ return sorted;+ });- function getRegistryName(t: Template): string {- return t.registry?.name ?? (t.isRemote ? m.templates_remote() : m.templates_local());- }+ const groupedTemplates = $derived.by(() => {+ if (!groupByRegistry) return [];- function sortTemplates(items: Template[]): Template[] {- const sorted = [...items];- if (sortBy === 'name-asc') {- sorted.sort((a, b) => a.name.localeCompare(b.name));- } else {- sorted.sort((a, b) => b.name.localeCompare(a.name));+ const groups = new Map<string, Template[]>();+ for (const template of sortedTemplates) {+ const key = template.registry?.name ?? (template.isRemote ? m.templates_remote() : m.templates_local());+ const items = groups.get(key) ?? [];+ items.push(template);+ groups.set(key, items);}- return sorted;- }- type Group = { key: string; name: string; items: Template[] };+ return Array.from(groups.entries())+ .map(([name, items]) => ({ name, items }))+ .sort((a, b) => a.name.localeCompare(b.name));+ });const filters = {'name-asc': m.templates_sort_name_asc(),'name-desc': m.templates_sort_name_desc()};- const grouped: Group[] = $derived(- !groupByRegistry- ? []- : Array.from(- allTemplates.reduce((map, t) => {- const key = getRegistryName(t);- const arr = map.get(key) ?? [];- arr.push(t);- map.set(key, arr);- return map;- }, new Map<string, Template[]>())- )- .map(([key, items]) => ({- key,- name: key,- items: sortTemplates(items)- }))- .sort((a, b) => a.name.localeCompare(b.name))- );+ function normalizeTags(tags: unknown): string[] {+ if (!tags) return [];++ let list: unknown = tags;+ if (typeof tags === 'string') {+ const trimmed = tags.trim();+ if (trimmed.startsWith('[')) {+ try {+ list = JSON.parse(trimmed);+ } catch {+ list = trimmed.split(',');+ }+ } else {+ list = trimmed.split(',');+ }+ }++ return (Array.isArray(list) ? list : [])+ .map((t) =>+ String(t)+ .trim()+ .replace(/^["']|["']$/g, '')+ )+ .filter(Boolean)+ .map((t) => t.charAt(0).toUpperCase() + t.slice(1));+ }async function handleSelect(template: Template) {- loadingStates.set(template.id, true);- loadingStates = new Map(loadingStates);+ const loadingKey = template.id;+ loadingStates.add(loadingKey);try {const details = await templateService.getTemplateContent(template.id);@@ -113,12 +101,11 @@toast.error(m.templates_load_failed());return;}- const compose = typeof details.content === 'string' ? details.content : '';- const env = typeof details.envContent === 'string' ? details.envContent : '';+onSelect({...details.template,- content: compose,- envContent: env+ content: details.content,+ envContent: details.envContent});open = false;toast.success(m.templates_loaded_success({ name: template.name }));@@ -126,21 +113,18 @@console.error('Error loading template:', error);toast.error(error instanceof Error ? error.message : m.templates_load_failed());} finally {- loadingStates.delete(template.id);- loadingStates = new Map(loadingStates);+ loadingStates.delete(loadingKey);}}async function handleDownload(template: Template) {if (!template.isRemote) return;- const templateId = template.id;- loadingStates.set(`download-${templateId}`, true);- loadingStates = new Map(loadingStates);+ const loadingKey = `download-${template.id}`;+ loadingStates.add(loadingKey);try {- const result = await templateService.download(templateId);-+ const result = await templateService.download(template.id);if (result) {toast.success(m.templates_downloaded_success({ name: template.name }));onDownloadSuccess?.();@@ -149,16 +133,91 @@}} catch (error) {console.error('Error downloading template:', error);- let errorMessage = m.templates_download_failed();- if (error instanceof Error) errorMessage = error.message;- toast.error(errorMessage);+ toast.error(error instanceof Error ? error.message : m.templates_download_failed());} finally {- loadingStates.delete(`download-${templateId}`);- loadingStates = new Map(loadingStates);+ loadingStates.delete(loadingKey);}}</script>+{#snippet templateCard(template: Template, showRegistry: boolean = false)}+ <Card class="hover:bg-muted/50 hover:border-primary/20 border transition-colors">+ <div class="p-4">+ <div class="mb-2 flex items-start justify-between gap-2">+ <h4 class="truncate pr-2 font-semibold">{template.name}</h4>+ <div class="ml-2 flex flex-shrink-0 flex-wrap items-center gap-1">+ {#if template.metadata?.version}+ <Badge variant="outline" class="text-xs">v{template.metadata.version}</Badge>+ {/if}+ {#if template.metadata?.envUrl || template.envContent}+ <Badge variant="secondary" class="text-xs">+ <SettingsIcon class="mr-1 size-3" />+ ENV+ </Badge>+ {/if}+ </div>+ </div>++ {#if showRegistry}+ <div class="mb-2">+ <Badge variant="secondary" class="text-xs">+ {#if template.isRemote}+ <GlobeIcon class="mr-1 size-3" />+ {:else}+ <FolderOpenIcon class="mr-1 size-3" />+ {/if}+ {template.registry?.name ?? (template.isRemote ? m.templates_remote() : m.templates_local())}+ </Badge>+ </div>+ {/if}++ <p class="text-muted-foreground mb-3 line-clamp-2 text-sm">+ {template.description}+ </p>++ {#if normalizeTags(template.metadata?.tags).length > 0}+ <div class="mb-3 flex flex-wrap gap-1">+ {#each normalizeTags(template.metadata?.tags) as tag}+ <Badge variant="outline" class="text-[10px]">{tag}</Badge>+ {/each}+ </div>+ {/if}++ <div class="flex items-center justify-between gap-2">+ <div class="text-muted-foreground text-xs">+ {template.isRemote ? m.templates_remote_template_label() : m.templates_local_template_label()}+ </div>+ <div class="flex gap-2">+ {#if template.isRemote}+ <Button+ variant="outline"+ size="sm"+ onclick={() => handleDownload(template)}+ disabled={loadingStates.has(`download-${template.id}`)}+ >+ {#if loadingStates.has(`download-${template.id}`)}+ <Spinner class="mr-1 size-3" />+ {m.templates_downloading()}+ {:else}+ <DownloadIcon class="mr-1 size-3" />+ {m.templates_download()}+ {/if}+ </Button>+ {/if}+ <Button size="sm" onclick={() => handleSelect(template)} disabled={loadingStates.has(template.id)}>+ {#if loadingStates.has(template.id)}+ <Spinner class="mr-1 size-3" />+ {m.templates_loading()}+ {:else}+ {m.templates_use_now()}+ {/if}+ </Button>+ </div>+ </div>+ </div>+ </Card>+{/snippet}+<Dialog.Root bind:open><Dialog.Content class="max-h-screen overflow-y-auto sm:max-w-[900px]"><Dialog.Header>@@ -195,7 +254,7 @@<div class="py-2"><ScrollArea class="max-h-[65vh]">- {#if (allTemplates?.length ?? 0) === 0}+ {#if allTemplates.length === 0}<div class="text-muted-foreground py-10 text-center"><FileTextIcon class="mx-auto mb-4 size-12 opacity-50" /><p class="mb-2">{m.templates_no_templates()}</p>@@ -205,9 +264,9 @@{m.templates_add_registry_prompt_part2()}</p></div>- {:else if groupByRegistry && grouped.length}+ {:else if groupByRegistry && groupedTemplates.length > 0}<div class="space-y-3">- {#each grouped as group}+ {#each groupedTemplates as group}<Collapsible.Root class="w-full"><Card class="border-2"><Collapsible.Trigger class="flex w-full items-center justify-between px-4 py-3 text-left">@@ -222,72 +281,7 @@<div class="px-6 pb-6"><div class="grid grid-cols-1 gap-4 md:grid-cols-2">{#each group.items as template}- <Card class="hover:bg-muted/50 hover:border-primary/20 border transition-colors">- <div class="p-4">- <div class="mb-2 flex items-start justify-between gap-2">- <h4 class="truncate pr-2 font-semibold">{template.name}</h4>- <div class="ml-2 flex flex-shrink-0 flex-wrap items-center gap-1">- {#if template.metadata?.version}- <Badge variant="outline" class="text-xs">v{template.metadata.version}</Badge>- {/if}- {#if template.metadata?.envUrl || template.envContent}- <Badge variant="secondary" class="text-xs">- <SettingsIcon class="mr-1 size-3" />- ENV- </Badge>- {/if}- </div>- </div>-- <p class="text-muted-foreground mb-3 line-clamp-2 text-sm">- {template.description}- </p>-- {#if normalizeTags(template).length > 0}- <div class="mb-3 flex flex-wrap gap-1">- {#each normalizeTags(template) as tag}- <Badge variant="outline" class="text-[10px]">{tag}</Badge>- {/each}- </div>- {/if}-- <div class="flex items-center justify-between gap-2">- <div class="text-muted-foreground text-xs">- {template.isRemote ? m.templates_remote_template_label() : m.templates_local_template_label()}- </div>- <div class="flex gap-2">- {#if template.isRemote}- <Button- variant="outline"- size="sm"- onclick={() => handleDownload(template)}- disabled={loadingStates.get(`download-${template.id}`)}- >- {#if loadingStates.get(`download-${template.id}`)}- <Spinner class="mr-1 size-3" />- {m.templates_downloading()}- {:else}- <DownloadIcon class="mr-1 size-3" />- {m.templates_download()}- {/if}- </Button>- {/if}- <Button- size="sm"- onclick={() => handleSelect(template)}- disabled={loadingStates.get(template.id)}- >- {#if loadingStates.get(template.id)}- <Spinner class="mr-1 size-3" />- {m.templates_loading()}- {:else}- {m.templates_use_now()}- {/if}- </Button>- </div>- </div>- </div>- </Card>+ {@render templateCard(template)}{/each}</div></div>@@ -297,82 +291,9 @@{/each}</div>{:else}- <!-- Flat grid (no grouping) --><div class="grid grid-cols-1 gap-4 md:grid-cols-2">- {#each sortTemplates(allTemplates) as template}- <Card class="hover:bg-muted/50 hover:border-primary/20 border-2 transition-colors">- <div class="p-4">- <div class="mb-2 flex items-start justify-between gap-2">- <h4 class="truncate pr-2 font-semibold">{template.name}</h4>- <div class="ml-2 flex flex-shrink-0 flex-wrap items-center gap-1">- {#if template.metadata?.version}- <Badge variant="outline" class="text-xs">v{template.metadata.version}</Badge>- {/if}- {#if template.metadata?.envUrl || template.envContent}- <Badge variant="secondary" class="text-xs">- <SettingsIcon class="mr-1 size-3" />- ENV- </Badge>- {/if}- </div>- </div>-- <div class="mb-2">- <Badge variant="secondary" class="text-xs">- {#if template.isRemote}- <GlobeIcon class="mr-1 size-3" />- {:else}- <FolderOpenIcon class="mr-1 size-3" />- {/if}- {getRegistryName(template)}- </Badge>- </div>-- <p class="text-muted-foreground mb-3 line-clamp-2 text-sm">- {template.description}- </p>-- {#if normalizeTags(template).length > 0}- <div class="mb-3 flex flex-wrap gap-1">- {#each normalizeTags(template) as tag}- <Badge variant="outline" class="text-[10px]">{tag}</Badge>- {/each}- </div>- {/if}-- <div class="flex items-center justify-between gap-2">- <div class="text-muted-foreground text-xs">- {template.isRemote ? m.templates_remote_template_label() : m.templates_local_template_label()}- </div>- <div class="flex gap-2">- {#if template.isRemote}- <Button- variant="outline"- size="sm"- onclick={() => handleDownload(template)}- disabled={loadingStates.get(`download-${template.id}`)}- >- {#if loadingStates.get(`download-${template.id}`)}- <Spinner class="mr-1 size-3" />- {m.templates_downloading()}- {:else}- <DownloadIcon class="mr-1 size-3" />- {m.templates_download()}- {/if}- </Button>- {/if}- <Button size="sm" onclick={() => handleSelect(template)} disabled={loadingStates.get(template.id)}>- {#if loadingStates.get(template.id)}- <Spinner class="mr-1 size-3" />- {m.templates_loading()}- {:else}- {m.templates_use_now()}- {/if}- </Button>- </div>- </div>- </div>- </Card>+ {#each sortedTemplates as template}+ {@render templateCard(template, true)}{/each}</div>{/if}diff --git a/frontend/src/lib/components/progress-popover.svelte b/frontend/src/lib/components/progress-popover.svelteindex cd502dccd..7d7d3988b 100644--- a/frontend/src/lib/components/progress-popover.svelte+++ b/frontend/src/lib/components/progress-popover.svelte@@ -5,25 +5,10 @@import { Progress } from '$lib/components/ui/progress/index.js';import DownloadIcon from '@lucide/svelte/icons/download';import type { Icon as IconType } from '@lucide/svelte';- import { type Snippet } from 'svelte';+ import type { Snippet } from 'svelte';import { m } from '$lib/paraglide/messages';- let {- open = $bindable(false),- title = m.progress_title(),- subtitle = m.progress_subtitle(),- progress = $bindable(0),- statusText = '',- error = '',- loading = false,- align = 'center' as 'start' | 'center' | 'end',- sideOffset = 4,- class: className = '',- icon,- iconClass = 'text-primary size-4',- preventCloseWhileLoading = true,- children- } = $props<{+ interface Props {open?: boolean;title?: string;subtitle?: string;@@ -38,7 +23,28 @@iconClass?: string;preventCloseWhileLoading?: boolean;children: Snippet;- }>();+ }++ let {+ open = $bindable(false),+ title = m.progress_title(),+ subtitle = m.progress_subtitle(),+ progress = $bindable(0),+ statusText = '',+ error = '',+ loading = false,+ align = 'center',+ sideOffset = 4,+ class: className = '',+ icon,+ iconClass = 'text-primary size-4',+ preventCloseWhileLoading = true,+ children+ }: Props = $props();++ const percent = $derived(Math.round(progress));+ const isComplete = $derived(progress === 100);+ const displaySubtitle = $derived(error ? subtitle : isComplete ? m.progress_pull_completed() : subtitle);function handleOpenChange(next: boolean) {if (preventCloseWhileLoading && !next && loading) {@@ -47,11 +53,6 @@}open = next;}-- const percent = $derived(Math.round(progress));- const displaySubtitle = $derived(- error ? (subtitle ?? m.common_unknown()) : progress === 100 ? m.progress_pull_completed() : (subtitle ?? m.common_unknown())- );</script><Popover.Root bind:open onOpenChange={handleOpenChange}>@@ -61,45 +62,62 @@<Popover.Content class={cn('bg-popover w-80 rounded-md border p-4 shadow-md', className)} {align} {sideOffset}><div class="space-y-3">- <div class="flex items-center gap-3">- <div class="bg-primary/10 flex size-8 shrink-0 items-center justify-center rounded-full">- {#if icon}- {@const Icon = icon}- <Icon class={iconClass} />- {:else}- <DownloadIcon class={iconClass} />- {/if}- </div>- <div>- <h4 class="text-sm font-semibold">{title ?? m.common_unknown()}</h4>- <p class="text-muted-foreground text-xs">{displaySubtitle}</p>- </div>- </div>+ {@render headerSection()}+ {@render contentSection()}+ </div>+ <PopoverPrimitive.Arrow class="fill-background stroke-border" />+ </Popover.Content>+</Popover.Root>- {#if error}- <div class="rounded-md bg-red-50 p-3 dark:bg-red-950/20">- <p class="text-destructive text-sm">{error}</p>- </div>+{#snippet headerSection()}+ <div class="flex items-center gap-3">+ <div class="bg-primary/10 flex size-8 shrink-0 items-center justify-center rounded-full">+ {#if icon}+ {@const Icon = icon}+ <Icon class={iconClass} />{:else}- <div class="space-y-2">- <div class="flex justify-between text-xs">- <span class="text-muted-foreground truncate pr-2">{statusText || m.progress_preparing()}</span>- <span class="text-muted-foreground shrink-0">{percent}%</span>- </div>- <Progress value={progress} max={100} class="h-2 w-full" />- {#if loading}- <p class="text-muted-foreground text-xs">{m.progress_in_progress_note()}</p>- {/if}- </div>+ <DownloadIcon class={iconClass} />{/if}+ </div>+ <div>+ <h4 class="text-sm font-semibold">{title}</h4>+ <p class="text-muted-foreground text-xs">{displaySubtitle}</p>+ </div>+ </div>+{/snippet}- {#if !loading && progress === 100 && !error}- <div class="rounded-md bg-green-50 p-3 dark:bg-green-950/20">- <p class="text-sm text-green-600 dark:text-green-400">{m.progress_completed_success()}</p>- </div>- {/if}+{#snippet contentSection()}+ {#if error}+ {@render errorDisplay()}+ {:else}+ {@render progressDisplay()}+ {#if isComplete && !loading}+ {@render successDisplay()}+ {/if}+ {/if}+{/snippet}++{#snippet errorDisplay()}+ <div class="rounded-md bg-red-50 p-3 dark:bg-red-950/20">+ <p class="text-destructive text-sm">{error}</p>+ </div>+{/snippet}++{#snippet progressDisplay()}+ <div class="space-y-2">+ <div class="flex justify-between text-xs">+ <span class="text-muted-foreground truncate pr-2">{statusText || m.progress_preparing()}</span>+ <span class="text-muted-foreground shrink-0">{percent}%</span></div>+ <Progress value={progress} max={100} class="h-2 w-full" />+ {#if loading}+ <p class="text-muted-foreground text-xs">{m.progress_in_progress_note()}</p>+ {/if}+ </div>+{/snippet}- <PopoverPrimitive.Arrow class="fill-background stroke-border" />- </Popover.Content>-</Popover.Root>+{#snippet successDisplay()}+ <div class="rounded-md bg-green-50 p-3 dark:bg-green-950/20">+ <p class="text-sm text-green-600 dark:text-green-400">{m.progress_completed_success()}</p>+ </div>+{/snippet}diff --git a/frontend/src/lib/components/ui/button-group/button-group-separator.svelte b/frontend/src/lib/components/ui/button-group/button-group-separator.sveltenew file mode 100644index 000000000..4fcc179a6--- /dev/null+++ b/frontend/src/lib/components/ui/button-group/button-group-separator.svelte@@ -0,0 +1,18 @@+<script lang="ts">+ import { cn } from "$lib/utils.js";+ import type { ComponentProps } from "svelte";+ import { Separator } from "$lib/components/ui/separator/index.js";++ let {+ class: className,+ orientation = "vertical",+ ...restProps+ }: ComponentProps<typeof Separator> = $props();+</script>++<Separator+ data-slot="button-group-separator"+ {orientation}+ class={cn("bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto", className)}+ {...restProps}+/>diff --git a/frontend/src/lib/components/ui/button-group/button-group-text.svelte b/frontend/src/lib/components/ui/button-group/button-group-text.sveltenew file mode 100644index 000000000..69aa0fc2f--- /dev/null+++ b/frontend/src/lib/components/ui/button-group/button-group-text.svelte@@ -0,0 +1,33 @@+<script lang="ts">+ import { cn } from "$lib/utils.js";+ import type { HTMLAttributes } from "svelte/elements";+ import type { Snippet } from "svelte";++ let {+ class: className,+ child,+ ...restProps+ }: HTMLAttributes<HTMLDivElement> & {+ child?: Snippet<[{ props: Record<string, unknown> }]>;+ } = $props();++ const classes = $derived(+ cn(+ "bg-muted shadow-xs flex items-center gap-2 rounded-md border px-4 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",+ className+ )+ );++ const mergedProps = $derived({+ ...restProps,+ class: classes,+ });+</script>++{#if child}+ {@render child({ props: mergedProps })}+{:else}+ <div {...mergedProps}>+ {@render mergedProps.children?.()}+ </div>+{/if}diff --git a/frontend/src/lib/components/ui/button-group/button-group.svelte b/frontend/src/lib/components/ui/button-group/button-group.sveltenew file mode 100644index 000000000..fcde6fa86--- /dev/null+++ b/frontend/src/lib/components/ui/button-group/button-group.svelte@@ -0,0 +1,44 @@+<script lang="ts" module>+ import { tv, type VariantProps } from "tailwind-variants";++ const buttonGroupVariants = tv({+ base: "flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",+ variants: {+ orientation: {+ horizontal:+ "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",+ vertical:+ "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none",+ },+ },+ defaultVariants: {+ orientation: "horizontal",+ },+ });++ export type ButtonGroupOrientation = VariantProps<typeof buttonGroupVariants>["orientation"];+</script>++<script lang="ts">+ import { cn } from "$lib/utils.js";+ import type { HTMLAttributes } from "svelte/elements";++ let {+ class: className,+ children,+ orientation = "horizontal",+ ...restProps+ }: HTMLAttributes<HTMLDivElement> & {+ orientation?: ButtonGroupOrientation;+ } = $props();+</script>++<div+ role="group"+ data-slot="button-group"+ data-orientation={orientation}+ class={cn(buttonGroupVariants({ orientation }), className)}+ {...restProps}+>+ {@render children?.()}+</div>diff --git a/frontend/src/lib/components/ui/button-group/index.ts b/frontend/src/lib/components/ui/button-group/index.tsnew file mode 100644index 000000000..7f706e3e1--- /dev/null+++ b/frontend/src/lib/components/ui/button-group/index.ts@@ -0,0 +1,13 @@+import Root from "./button-group.svelte";+import Text from "./button-group-text.svelte";+import Separator from "./button-group-separator.svelte";++export {+ Root,+ Text,+ Separator,+ //+ Root as ButtonGroup,+ Text as ButtonGroupText,+ Separator as ButtonGroupSeparator,+};diff --git a/frontend/src/routes/projects/components/EditableName.svelte b/frontend/src/routes/projects/components/EditableName.svelteindex 80bded483..6509bf05e 100644--- a/frontend/src/routes/projects/components/EditableName.svelte+++ b/frontend/src/routes/projects/components/EditableName.svelte@@ -16,6 +16,7 @@originalValue,canEdit = true,onCommit,+ placeholder = '',class: className = ''}: {value: string;@@ -25,6 +26,7 @@originalValue: string;canEdit?: boolean;onCommit?: () => void;+ placeholder?: string;class?: string;} = $props();@@ -44,6 +46,7 @@<Inputbind:refbind:value+ {placeholder}class="h-8 min-w-[120px] max-w-[280px] px-2 text-left text-base font-semibold {error ? 'border-destructive' : ''}"autofocusonkeydown={(e) => {@@ -68,6 +71,7 @@<Inputbind:refbind:value+ {placeholder}class="h-8 max-w-[360px] px-2 text-lg font-semibold {error ? 'border-destructive' : ''}"autofocusonkeydown={(e) => {@@ -93,25 +97,25 @@<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"- title={canEdit ? `${value} (tap to edit)` : value}+ 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:outline-none focus:ring-2 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"+ title={canEdit ? `${value || placeholder} (tap to edit)` : value || placeholder}onclick={beginEdit}disabled={!canEdit}>- <span class="block truncate">{value}</span>+ <span class="block truncate {!value && placeholder ? 'text-muted-foreground' : ''}">{value || placeholder}</span></button></h1>{#if canEdit}<div class="flex items-center justify-center">- <span class="text-muted-foreground flex items-center gap-0.5 text-[8px] whitespace-nowrap opacity-30">+ <span class="text-muted-foreground flex items-center gap-0.5 whitespace-nowrap text-[8px] opacity-30"><PencilIcon class="size-1.5" />{m.tap_to_edit()}</span></div>{:else}<div class="flex items-center justify-center">- <span class="text-muted-foreground inline-flex cursor-help items-center gap-0.5 text-[8px] whitespace-nowrap opacity-40">+ <span class="text-muted-foreground inline-flex cursor-help items-center gap-0.5 whitespace-nowrap text-[8px] opacity-40"><InfoIcon class="size-1.5" />{m.cannot_edit()}</span>@@ -122,12 +126,14 @@<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"- title={value}+ class="w-full truncate bg-transparent px-0 py-0 text-left text-lg font-semibold leading-none {!value && placeholder+ ? 'text-muted-foreground'+ : ''}"+ title={value || placeholder}onclick={beginEdit}disabled={!canEdit}>- {value}+ {value || placeholder}</button></h1>{#if canEdit}diff --git a/frontend/src/routes/projects/new/+page.svelte b/frontend/src/routes/projects/new/+page.svelteindex 3da0e4eb2..bc4620f76 100644--- a/frontend/src/routes/projects/new/+page.svelte+++ b/frontend/src/routes/projects/new/+page.svelte@@ -10,7 +10,6 @@import { Label } from '$lib/components/ui/label/index.js';import { goto, invalidateAll } from '$app/navigation';import { toast } from 'svelte-sonner';- import CodeEditor from '$lib/components/code-editor/editor.svelte';import { preventDefault, createForm } from '$lib/utils/form.utils';import { tryCatch } from '$lib/utils/try-catch';import { handleApiResultWithCallbacks } from '$lib/utils/api.util';@@ -18,13 +17,17 @@import * as Dialog from '$lib/components/ui/dialog/index.js';import TemplateSelectionDialog from '$lib/components/dialogs/template-selection-dialog.svelte';import type { Template } from '$lib/types/template.type';- import * as DropdownButton from '$lib/components/ui/dropdown-button/index.js';import { z } from 'zod/v4';import { arcaneButtonVariants, actionConfigs } from '$lib/components/arcane-button/variants';import PlusCircleIcon from '@lucide/svelte/icons/plus-circle';import { m } from '$lib/paraglide/messages';import { projectService } from '$lib/services/project-service.js';import { systemService } from '$lib/services/system-service.js';+ import * as ButtonGroup from '$lib/components/ui/button-group/index.js';+ import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';+ import ChevronDown from '@lucide/svelte/icons/chevron-down';+ import CodePanel from '../components/CodePanel.svelte';+ import EditableName from '../components/EditableName.svelte';let { data } = $props();@@ -52,6 +55,10 @@let { inputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, formData));let dockerRunCommand = $state('');+ let composeOpen = $state(true);+ let envOpen = $state(true);++ let nameInputRef = $state<HTMLInputElement | null>(null);async function handleSubmit() {await handleCreateProject();@@ -130,215 +137,185 @@'data-[disabled]:opacity-50 data-[disabled]:pointer-events-none';</script>-<div class="bg-background min-h-screen">- <div class="bg-background/80 supports-[backdrop-filter]:bg-background/60 sticky top-0 border-b backdrop-blur">- <div class="max-w-full px-4 py-3">- <div class="flex items-center justify-between">- <div class="flex items-center gap-3">- <Button variant="ghost" size="sm" href="/projects" class="gap-2">- <ArrowLeftIcon class="size-4" />- {m.common_back()}- </Button>- <div class="bg-border h-4 w-px"></div>- <div class="flex items-center gap-2">- <h1 class="text-lg font-semibold leading-none">{m.compose_new_title()}</h1>- </div>+<div class="bg-background flex min-h-screen flex-col">+ <!-- Header -->+ <div class="bg-background/80 supports-[backdrop-filter]:bg-background/60 sticky top-0 z-50 border-b backdrop-blur">+ <div class="mx-auto flex h-16 max-w-full items-center justify-between gap-4 px-6">+ <div class="flex items-center gap-4">+ <Button variant="ghost" size="sm" href="/projects" class="gap-2">+ <ArrowLeftIcon class="size-4" />+ {m.common_back()}+ </Button>+ <div class="bg-border hidden h-4 w-px sm:block"></div>+ <div class="hidden items-center gap-3 sm:flex">+ <EditableName+ bind:value={$inputs.name.value}+ bind:ref={nameInputRef}+ variant="inline"+ error={$inputs.name.error ?? undefined}+ originalValue=""+ placeholder={m.compose_project_name_placeholder?.() || 'Enter project name...'}+ canEdit={!saving && !isLoadingTemplateContent}+ class="hidden sm:block"+ /></div>+ </div>- <div class="flex items-center gap-2">- <Dialog.Root bind:open={showConverterDialog}>- <Dialog.Content class="max-h-[80vh] sm:max-w-[800px]">- <Dialog.Header>- <Dialog.Title>{m.compose_converter_title()}</Dialog.Title>- <Dialog.Description>{m.compose_converter_description()}</Dialog.Description>- </Dialog.Header>-- <div class="max-h-[60vh] space-y-4 overflow-y-auto">- <div class="space-y-2">- <Label for="dockerRunCommand">{m.compose_docker_run_command_label()}</Label>- <Textarea- id="dockerRunCommand"- bind:value={dockerRunCommand}- placeholder={m.compose_docker_run_placeholder()}- rows={3}- disabled={converting}- class="font-mono text-sm"- />- </div>-- <div class="space-y-2">- <Label class="text-muted-foreground text-xs">{m.compose_example_commands_label()}</Label>- <div class="space-y-1">- {#each exampleCommands as command}- <Button- type="button"- variant="ghost"- size="sm"- class="h-auto w-full justify-start whitespace-normal break-all p-2 text-left font-mono text-xs"- onclick={() => useExample(command)}- >- <CopyIcon class="mr-2 size-3 shrink-0" />- <span class=""> {command} </span>- </Button>- {/each}- </div>- </div>- </div>-- <div class="flex w-full justify-end pt-4">- <Button type="button" disabled={!dockerRunCommand.trim() || converting} onclick={handleConvertDockerRun}>- {#if converting}- <Spinner class="mr-2 size-4" />- {m.compose_converting()}- {:else}- <WandIcon class="mr-2 size-4" />- {m.compose_convert_action()}- {/if}+ <div class="flex items-center gap-2">+ <ButtonGroup.Root>+ <Button+ disabled={!$inputs.name.value || !$inputs.composeContent.value || saving || converting || isLoadingTemplateContent}+ onclick={() => handleSubmit()}+ class={`${templateBtnClass} gap-2 rounded-r-none hover:translate-y-0 focus:translate-y-0 active:translate-y-0`}+ >+ {#if saving}+ <Spinner class="size-4" />+ {m.compose_creating()}+ {:else}+ <PlusCircleIcon class="size-4" />+ {m.compose_create_project()}+ {/if}+ </Button>++ <DropdownMenu.Root>+ <DropdownMenu.Trigger>+ {#snippet child({ props })}+ <Button+ {...props}+ class={`${templateBtnClass} -ml-px rounded-l-none px-2 hover:translate-y-0 focus:translate-y-0 active:translate-y-0`}+ variant="outline"+ >+ <ChevronDown class="size-4" /></Button>- </div>- </Dialog.Content>- </Dialog.Root>-- <DropdownButton.DropdownRoot>- <DropdownButton.Root align="center" class="inline-flex">- <DropdownButton.Main- disabled={!$inputs.name.value ||- !$inputs.composeContent.value ||- saving ||- converting ||- isLoadingTemplateContent}- onclick={() => handleSubmit()}- class={`${templateBtnClass} gap-2 rounded-r-none hover:!translate-y-0 focus-visible:!translate-y-0 active:!translate-y-0`}- >- {#if saving}- <Spinner class="size-4" />- {m.compose_creating()}- {:else}- <PlusCircleIcon class="size-4" />- {m.compose_create_project()}- {/if}- </DropdownButton.Main>-- <DropdownButton.DropdownTrigger>- {#snippet child({ props })}- <DropdownButton.Trigger- {...props}- class={[- props.class,- templateBtnClass,- '-ml-px rounded-l-none px-2',- 'hover:!translate-y-0 focus-visible:!translate-y-0 active:!translate-y-0'- ].join(' ')}- />- {/snippet}- </DropdownButton.DropdownTrigger>- </DropdownButton.Root>-- <DropdownButton.Content class={dropdownContentClass}>- <DropdownButton.Item- class={dropdownItemClass}- disabled={saving || converting || isLoadingTemplateContent}- onclick={() => (showTemplateDialog = true)}- >- <LayoutTemplateIcon class="size-4" />- {m.compose_use_template()}- </DropdownButton.Item>- <DropdownButton.Item class={dropdownItemClass} onclick={() => (showConverterDialog = true)}>- <TerminalIcon class="size-4" />- {m.compose_convert_from_docker_run()}- </DropdownButton.Item>- </DropdownButton.Content>- </DropdownButton.DropdownRoot>- </div>+ {/snippet}+ </DropdownMenu.Trigger>+ <DropdownMenu.Content align="end" class={dropdownContentClass}>+ <DropdownMenu.Group>+ <DropdownMenu.Item+ class={dropdownItemClass}+ disabled={saving || converting || isLoadingTemplateContent}+ onclick={() => (showTemplateDialog = true)}+ >+ <LayoutTemplateIcon class="size-4" />+ {m.compose_use_template()}+ </DropdownMenu.Item>+ <DropdownMenu.Item class={dropdownItemClass} onclick={() => (showConverterDialog = true)}>+ <TerminalIcon class="size-4" />+ {m.compose_convert_from_docker_run()}+ </DropdownMenu.Item>+ </DropdownMenu.Group>+ </DropdownMenu.Content>+ </DropdownMenu.Root>+ </ButtonGroup.Root></div></div></div>- <!-- Keep existing page padding -->- <div class="max-w-none p-6">- <div class="space-y-8">- <form class="space-y-6" onsubmit={preventDefault(handleSubmit)}>- <div class="mb-6 space-y-2">- <Label for="name" class="text-sm font-medium">{m.compose_name_label?.() ?? m.common_name()}</Label>- <div class="max-w-md">- <Input- type="text"- id="name"- name="name"- bind:value={$inputs.name.value}- required- placeholder={m.compose_name_placeholder()}- disabled={saving || isLoadingTemplateContent}- class={$inputs.name.error ? 'border-destructive' : ''}- />- {#if $inputs.name.error}- <p class="text-destructive mt-1 text-xs">{$inputs.name.error}</p>- {:else}- <p class="text-muted-foreground mt-1 text-xs">{m.compose_name_hint()}</p>- {/if}- </div>+ <!-- Main Content -->+ <div class="flex-1 overflow-hidden">+ <div class="mx-auto h-full max-w-full">+ <div class="flex h-full flex-col gap-4 p-6">+ <!-- Name field for mobile -->+ <div class="block sm:hidden">+ <EditableName+ bind:value={$inputs.name.value}+ bind:ref={nameInputRef}+ variant="block"+ error={$inputs.name.error ?? undefined}+ originalValue=""+ placeholder={m.compose_project_name_placeholder()}+ canEdit={!saving && !isLoadingTemplateContent}+ /></div>- <div class="grid grid-cols-1 gap-6 lg:grid-cols-3">- <!-- Compose -->- <div class="lg:col-span-2">- <div class="space-y-4">- <div class="flex items-center justify-between">- <h3 class="text-lg font-semibold">{m.compose_compose_file_title()}</h3>- <span class="text-muted-foreground text-xs">{m.compose_yaml_label()}</span>- </div>- <div- class="border-input focus-within:border-primary focus-within:ring-ring relative rounded-md border bg-transparent transition-colors focus-within:ring-2 focus-within:ring-offset-2"- class:border-destructive={$inputs.composeContent.error}- >- <div class="min-h-[500px] w-full overflow-hidden">- <CodeEditor- bind:value={$inputs.composeContent.value}- language="yaml"- height="full"- placeholder={m.compose_compose_placeholder()}- readOnly={saving || isLoadingTemplateContent}- />- </div>- </div>- {#if $inputs.composeContent.error}- <p class="text-destructive mt-1 text-xs">{$inputs.composeContent.error}</p>- {/if}- </div>+ <!-- Code Panels -->+ <form+ class="grid h-full grid-cols-1 gap-4 lg:grid-cols-5"+ style="grid-template-rows: 1fr;"+ onsubmit={preventDefault(handleSubmit)}+ >+ <div class="h-full lg:col-span-3">+ <CodePanel+ bind:open={composeOpen}+ title={m.compose_compose_file_title()}+ language="yaml"+ bind:value={$inputs.composeContent.value}+ placeholder={m.compose_compose_placeholder()}+ error={$inputs.composeContent.error ?? undefined}+ /></div>- <!-- Env -->- <div class="lg:col-span-1">- <div class="space-y-4">- <div class="flex items-center justify-between">- <h3 class="text-lg font-semibold">{m.compose_env_title()}</h3>- <span class="text-muted-foreground text-xs">{m.compose_env_kv_label()}</span>- </div>- <div- class="border-input focus-within:border-primary focus-within:ring-ring relative rounded-md border bg-transparent transition-colors focus-within:ring-2 focus-within:ring-offset-2"- class:border-destructive={$inputs.envContent.error}- >- <div class="min-h-[500px] w-full overflow-hidden">- <CodeEditor- bind:value={$inputs.envContent.value}- language="env"- height="full"- placeholder={m.compose_env_placeholder()}- readOnly={saving || isLoadingTemplateContent}- />- </div>- </div>- {#if $inputs.envContent.error}- <p class="text-destructive mt-1 text-xs">{$inputs.envContent.error}</p>- {/if}- </div>+ <div class="h-full lg:col-span-2">+ <CodePanel+ bind:open={envOpen}+ title={m.compose_env_title()}+ language="env"+ bind:value={$inputs.envContent.value}+ placeholder={m.compose_env_placeholder()}+ error={$inputs.envContent.error ?? undefined}+ /></div>- </div>- </form>+ </form>+ </div></div></div></div>+<!-- Converter Dialog -->+<Dialog.Root bind:open={showConverterDialog}>+ <Dialog.Content class="max-h-[80vh] sm:max-w-[800px]">+ <Dialog.Header>+ <Dialog.Title>{m.compose_converter_title()}</Dialog.Title>+ <Dialog.Description>{m.compose_converter_description()}</Dialog.Description>+ </Dialog.Header>++ <div class="max-h-[60vh] space-y-4 overflow-y-auto">+ <div class="space-y-2">+ <Label for="dockerRunCommand">{m.compose_docker_run_command_label()}</Label>+ <Textarea+ id="dockerRunCommand"+ bind:value={dockerRunCommand}+ placeholder={m.compose_docker_run_placeholder()}+ rows={3}+ disabled={converting}+ class="font-mono text-sm"+ />+ </div>++ <div class="space-y-2">+ <Label class="text-muted-foreground text-xs">{m.compose_example_commands_label()}</Label>+ <div class="space-y-1">+ {#each exampleCommands as command}+ <Button+ type="button"+ variant="ghost"+ size="sm"+ class="h-auto w-full justify-start whitespace-normal break-all p-2 text-left font-mono text-xs"+ onclick={() => useExample(command)}+ >+ <CopyIcon class="mr-2 size-3 shrink-0" />+ <span>{command}</span>+ </Button>+ {/each}+ </div>+ </div>+ </div>++ <div class="flex w-full justify-end pt-4">+ <Button type="button" disabled={!dockerRunCommand.trim() || converting} onclick={handleConvertDockerRun}>+ {#if converting}+ <Spinner class="mr-2 size-4" />+ {m.compose_converting()}+ {:else}+ <WandIcon class="mr-2 size-4" />+ {m.compose_convert_action()}+ {/if}+ </Button>+ </div>+ </Dialog.Content>+</Dialog.Root>++<!-- Template Selection Dialog --><TemplateSelectionDialogbind:open={showTemplateDialog}templates={data.composeTemplates || []}diff --git a/tests/spec/converter.spec.ts b/tests/spec/converter.spec.tsindex 2ca36a1bf..abfbc6ff7 100644--- a/tests/spec/converter.spec.ts+++ b/tests/spec/converter.spec.ts@@ -13,10 +13,8 @@ const ROUTES = {};const SELECTORS = {- dropdownTrigger: '[data-slot="dropdown-button-trigger"]',convertButton: (name = 'Convert to Compose') => ({ name }),textareaPlaceholder: 'docker run -d --name my-app -p 8080:80 nginx:alpine',- stackNamePlaceholder: 'e.g., my-web-app',exampleButtonName: /docker run -d --name nginx/,successToast: 'Docker run command converted successfully!',exampleCommandExpected: 'docker run -d --name nginx -p 8080:80 -v nginx_data:/usr/share/nginx/html nginx:alpine',@@ -24,7 +22,8 @@ const SELECTORS = {};async function openConvertFromDockerRun(page: Page) {- await page.locator(SELECTORS.dropdownTrigger).first().click();+ const dropdownTrigger = page.locator('button').filter({ has: page.locator('svg.lucide-chevron-down') });+ await dropdownTrigger.click();await page.getByRole('menuitem', { name: 'Convert from Docker Run' }).click();}@@ -66,7 +65,7 @@ test.describe('Docker Run to Compose Converter', () => {await expect(page.getByText(SELECTORS.successToast)).toBeVisible();- await expect(page.getByPlaceholder(SELECTORS.stackNamePlaceholder)).toHaveValue('nginx');+ await expect(page.getByRole('button', { name: 'nginx', exact: true })).toBeVisible();await expect(page.getByPlaceholder(SELECTORS.textareaPlaceholder)).toHaveValue('');});@@ -97,7 +96,7 @@ test.describe('Docker Run to Compose Converter', () => {await expect(page.getByText(SELECTORS.successToast)).toBeVisible();- await expect(page.getByPlaceholder(SELECTORS.stackNamePlaceholder)).toHaveValue('postgres');+ await expect(page.getByRole('button', { name: 'postgres', exact: true })).toBeVisible;});test('should use example commands', async ({ page }) => {@@ -141,6 +140,6 @@ test.describe('Docker Run to Compose Converter', () => {await expect(page.getByText(SELECTORS.successToast)).toBeVisible();- await expect(page.getByPlaceholder(SELECTORS.stackNamePlaceholder)).toHaveValue('redis');+ await expect(page.getByRole('button', { name: 'redis', exact: true })).toBeVisible();});});diff --git a/tests/spec/project.spec.ts b/tests/spec/project.spec.tsindex a7864bb13..cad9edeb2 100644--- a/tests/spec/project.spec.ts+++ b/tests/spec/project.spec.ts@@ -43,12 +43,6 @@ test.describe('Projects Page', () => {await expect(page.locator('p:has-text("Stopped") + p')).toHaveText(String(projectCounts.stoppedProjects));});- test('should navigate to new project page when "Create Project" is clicked', async ({ page }) => {- await page.getByRole('button', { name: 'Create Project' }).click();- await expect(page).toHaveURL(ROUTES.newProject);- await expect(page.getByRole('heading', { name: 'Create New Project' })).toBeVisible();- });-test('should display projects list', async ({ page }) => {await expect(page.locator('table')).toBeVisible();});@@ -119,24 +113,27 @@ test.describe('New Compose Project Page', () => {});test('should display the create project form', async ({ page }) => {- await expect(page.getByRole('heading', { name: 'Create New Project' })).toBeVisible();- await expect(page.getByLabel('Project Name')).toBeVisible();- await expect(page.getByText('Docker Compose File')).toBeVisible();- await expect(page.getByText('Environment (.env)')).toBeVisible();+ await expect(page.getByRole('button', { name: 'My New Project' })).toBeVisible();+ await expect(page.getByRole('heading', { name: 'Docker Compose File' })).toBeVisible();+ await expect(page.getByRole('heading', { name: 'Environment (.env)' })).toBeVisible();});test('should validate required fields', async ({ page }) => {const createButton = page.getByRole('button', { name: 'Create' }).first();await expect(createButton).toBeDisabled();- await page.getByLabel('Project Name').fill('test-project');+ await page.getByRole('button', { name: 'My New Project' }).click();+ await page.getByRole('textbox', { name: 'My New Project' }).fill('test-project');+ await page.getByRole('textbox', { name: 'My New Project' }).press('Enter');});test('should create a new project successfully', async ({ page }) => {const projectName = `test-project-${Date.now()}`;let createdProjectId: string | null = null;- await page.getByLabel('Project Name').fill(projectName);+ await page.getByRole('button', { name: 'My New Project' }).click();+ await page.getByRole('textbox', { name: 'My New Project' }).fill(projectName);+ await page.getByRole('textbox', { name: 'My New Project' }).press('Enter');const composeEditor = page.locator('.cm-editor').first();await expect(composeEditor).toBeVisible();@@ -163,7 +160,7 @@ test.describe('New Compose Project Page', () => {}});- const createButton = page.getByRole('button', { name: 'Create' });+ const createButton = page.getByRole('button', { name: 'Create Project', exact: true });await createButton.click();await page.waitForURL(/\/projects\/.+/, { timeout: 10000 });