Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
refactor: move progress popover to its own component
Kyle Mendellc83995d70cd3
diff --git a/backend/internal/api/stack_handler.go b/backend/internal/api/stack_handler.goindex d4a96c02a..6b841d151 100644--- a/backend/internal/api/stack_handler.go+++ b/backend/internal/api/stack_handler.go@@ -480,7 +480,6 @@ func (h *StackHandler) PullStack(c *gin.Context) {stackID = c.Param("id")}- // Stream headers, same as image pullc.Writer.Header().Set("Content-Type", "application/x-json-stream")c.Writer.Header().Set("Cache-Control", "no-cache")c.Writer.Header().Set("Connection", "keep-alive")@@ -586,8 +585,6 @@ func (h *StackHandler) PullImages(c *gin.Context) {})return}-- // Do not send a final JSON body; stream completes like the image pull endpoint.}func (h *StackHandler) ConvertDockerRun(c *gin.Context) {diff --git a/backend/internal/services/stack_service.go b/backend/internal/services/stack_service.goindex fa1552f21..5f6c44f02 100644--- a/backend/internal/services/stack_service.go+++ b/backend/internal/services/stack_service.go@@ -367,7 +367,6 @@ func (s *StackService) PullStackImages(ctx context.Context, stackID string, progreturn fmt.Errorf("failed to parse services from compose file: %w", err)}- // Build a unique image listseen := map[string]struct{}{}var images []stringfor _, svc := range servicesFromFile {@@ -382,7 +381,6 @@ func (s *StackService) PullStackImages(ctx context.Context, stackID string, progimages = append(images, img)}- // Stream helperflusher, ok := progressWriter.(http.Flusher)writeJSON := func(m map[string]any) {b, _ := json.Marshal(m)@@ -402,7 +400,6 @@ func (s *StackService) PullStackImages(ctx context.Context, stackID string, prog})for _, img := range images {- // optional delimiter line per imagewriteJSON(map[string]any{"status": "Pulling", "id": img})if err := s.imageService.PullImage(ctx, img, progressWriter, systemUser); err != nil {@@ -430,7 +427,6 @@ func (s *StackService) PullStackImages(ctx context.Context, stackID string, progreturn firstErr}- // Fallback to docker-compose pull (legacy), stream as plain linescmd := exec.CommandContext(ctx, "docker-compose", "pull")cmd.Dir = stack.Pathcmd.Env = append(os.Environ(),diff --git a/frontend/src/lib/components/action-buttons.svelte b/frontend/src/lib/components/action-buttons.svelteindex 7c767230e..9ea48fbdb 100644--- a/frontend/src/lib/components/action-buttons.svelte+++ b/frontend/src/lib/components/action-buttons.svelte@@ -6,8 +6,7 @@import { tryCatch } from '$lib/utils/try-catch';import { handleApiResultWithCallbacks } from '$lib/utils/api.util';import { ArcaneButton } from '$lib/components/arcane-button/index.js';- import * as Popover from '$lib/components/ui/popover/index.js';- import { Progress } from '$lib/components/ui/progress/index.js';+ import ProgressPopover from '$lib/components/progress-popover.svelte';import DownloadIcon from '@lucide/svelte/icons/download';import { environmentStore, LOCAL_DOCKER_ENVIRONMENT_ID } from '$lib/stores/environment.store';import { get } from 'svelte/store';@@ -357,17 +356,6 @@}}}-- function handlePopoverOpenChange(newOpenState: boolean) {- if (!newOpenState && isLoading.pulling) {- pullPopoverOpen = true;- return;- }- pullPopoverOpen = newOpenState;- if (newOpenState && !isLoading.pulling) {- resetPullState();- }- }</script><div class="flex items-center gap-2">@@ -393,49 +381,19 @@<ArcaneButton action="redeploy" onclick={() => confirmAction('redeploy')} loading={isLoading.redeploy} />{#if type === 'stack'}- <Popover.Root bind:open={pullPopoverOpen} onOpenChange={handlePopoverOpenChange}>- <Popover.Trigger>- <ArcaneButton action="pull" onclick={handlePull} loading={isLoading.pulling} />- </Popover.Trigger>- <Popover.Content class="w-80 p-4" align="center">- <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">- <DownloadIcon class="text-primary size-4" />- </div>- <div>- <h4 class="text-sm font-semibold">Pulling Images</h4>- <p class="text-muted-foreground text-xs">Downloading latest versions</p>- </div>- </div>-- {#if pullError}- <div class="rounded-md bg-red-50 p-3 dark:bg-red-950/20">- <p class="text-destructive text-sm">{pullError}</p>- </div>- {:else}- <div class="space-y-2">- <div class="flex justify-between text-xs">- <span class="text-muted-foreground truncate pr-2">{pullStatusText || 'Preparing...'}</span>- <span class="text-muted-foreground shrink-0">{Math.round(pullProgress)}%</span>- </div>- <Progress value={pullProgress} max={100} class="h-2 w-full" />- {#if isLoading.pulling}- <p class="text-muted-foreground text-xs">This may take a while depending on image sizes and your connection.</p>- {/if}- </div>- {/if}-- {#if !isLoading.pulling && pullProgress === 100 && !pullError}- <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">✓ All images pulled successfully!</p>- </div>- {/if}- </div>- </Popover.Content>- </Popover.Root>+ <ProgressPopover+ bind:open={pullPopoverOpen}+ bind:progress={pullProgress}+ title="Pulling Images"+ statusText={pullStatusText}+ error={pullError}+ loading={isLoading.pulling}+ icon={DownloadIcon}+ >+ <ArcaneButton action="pull" onclick={() => handlePull()} loading={isLoading.pulling} />+ </ProgressPopover>{:else}- <ArcaneButton action="pull" onclick={handlePull} loading={isLoading.pulling} />+ <ArcaneButton action="pull" onclick={() => handlePull()} loading={isLoading.pulling} />{/if}<ArcaneButtondiff --git a/frontend/src/lib/components/progress-popover.svelte b/frontend/src/lib/components/progress-popover.sveltenew file mode 100644index 000000000..a28117d59--- /dev/null+++ b/frontend/src/lib/components/progress-popover.svelte@@ -0,0 +1,102 @@+<script lang="ts">+ import { cn } from '$lib/utils.js';+ import * as Popover from '$lib/components/ui/popover/index.js';+ import { Popover as PopoverPrimitive } from 'bits-ui';+ 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';++ let {+ open = $bindable(false),+ title = 'Progress',+ subtitle = 'Working…',+ 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<{+ open?: boolean;+ title?: string;+ subtitle?: string;+ progress?: number;+ statusText?: string;+ error?: string;+ loading?: boolean;+ align?: 'start' | 'center' | 'end';+ sideOffset?: number;+ class?: string;+ icon?: typeof IconType;+ iconClass?: string;+ preventCloseWhileLoading?: boolean;+ children: Snippet;+ }>();++ function handleOpenChange(next: boolean) {+ if (preventCloseWhileLoading && !next && loading) {+ open = true;+ return;+ }+ open = next;+ }++ const percent = $derived(Math.round(progress));+ const displaySubtitle = $derived(error ? subtitle : progress === 100 ? 'Pull Completed' : subtitle);+</script>++<Popover.Root bind:open onOpenChange={handleOpenChange}>+ <Popover.Trigger>+ {@render children()}+ </Popover.Trigger>++ <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}</h4>+ <p class="text-muted-foreground text-xs">{displaySubtitle}</p>+ </div>+ </div>++ {#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>+ {:else}+ <div class="space-y-2">+ <div class="flex justify-between text-xs">+ <span class="text-muted-foreground truncate pr-2">{statusText || '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">This may take a while depending on size and connection.</p>+ {/if}+ </div>+ {/if}++ {#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">✓ Completed successfully!</p>+ </div>+ {/if}+ </div>++ <PopoverPrimitive.Arrow class="fill-background stroke-border" />+ </Popover.Content>+</Popover.Root>