Skip to content

Modern Docker Management, Designed for Everyone

feat: add unsaved changes message when deploying or redploying projects

Kyle Mendell32f1e33526c1
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 053d6aec5..8f98bb6f6 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -1426,6 +1426,9 @@
"projects_archived_count": "Archived Projects",
"projects_archive_requires_stopped": "Stop the project first",
"projects_archive_edit_blocked": "Unarchive the project before making changes.",
+ "projects_save_before_deploy_message": "This project has unsaved changes. Save them first so the deployment uses your latest edits.",
+ "projects_save_and_deploy": "Save & Deploy",
+ "projects_save_and_redeploy": "Save & Redeploy",
"projects_bulk_up": "Up ({count})",
"projects_bulk_down": "Down ({count})",
"projects_bulk_redeploy": "Redeploy ({count})",
diff --git a/frontend/src/lib/components/action-buttons.svelte b/frontend/src/lib/components/action-buttons.svelte
index 1029028f8..a0b25d89e 100644
--- a/frontend/src/lib/components/action-buttons.svelte
+++ b/frontend/src/lib/components/action-buttons.svelte
@@ -57,7 +57,9 @@
disabled = false,
disabledReason,
onRefresh,
- extraActions = []
+ extraActions = [],
+ hasUnsavedChanges = false,
+ onSaveChanges
}: {
id: string;
name?: string;
@@ -75,6 +77,8 @@
disabledReason?: string;
onRefresh?: () => void | Promise<void>;
extraActions?: ActionButton[];
+ hasUnsavedChanges?: boolean;
+ onSaveChanges?: () => Promise<boolean>;
} = $props();
let isLoading = $state<LoadingStates>({
@@ -276,48 +280,74 @@
}
}
+ // Saves pending editor changes first; the deploy is skipped if the save fails.
+ function confirmSaveBeforeDeploy(label: string, run: () => Promise<void>) {
+ openConfirmDialog({
+ title: m.common_unsaved_changes(),
+ message: m.projects_save_before_deploy_message(),
+ confirm: {
+ label,
+ action: async () => {
+ if (await onSaveChanges?.()) await run();
+ }
+ }
+ });
+ }
+
+ function confirmDeploy(watch: boolean) {
+ if (hasUnsavedChanges) {
+ confirmSaveBeforeDeploy(m.projects_save_and_deploy(), () => handleDeploy(undefined, watch));
+ return;
+ }
+ void handleDeploy(undefined, watch);
+ }
+
function confirmRedeploy(watch: boolean) {
+ if (hasUnsavedChanges) {
+ confirmSaveBeforeDeploy(m.projects_save_and_redeploy(), () => handleRedeploy(watch));
+ return;
+ }
openConfirmDialog({
title: type === 'container' ? m.container_confirm_redeploy_title() : m.common_confirm_redeploy_title(),
message: type === 'container' ? m.container_confirm_redeploy_message() : m.common_confirm_redeploy_message(),
confirm: {
label: m.common_redeploy(),
- action: async () => {
- const operationStartedAt = Math.floor(Temporal.Now.instant().epochMilliseconds / 1000);
- if (watch) {
- operationWatchStore.start(`${m.common_redeploy()} — ${name ?? id}`);
- }
- const result = await redeployMutation.mutateAsync({ watch });
- if (watch && result.error) {
- operationWatchStore.fail(
- result.error.message || m.common_action_failed_with_type({ action: m.common_redeploy(), type })
- );
- return;
- }
- if (watch) {
- enterInteractiveWatchInternal(operationStartedAt);
- }
- await handleApiResultWithCallbacks({
- result,
- message: m.common_action_failed_with_type({ action: m.common_redeploy(), type }),
- onSuccess: async (data) => {
- const activityId = type === 'container' ? extractActivityId(data) : redeployActivityId;
- if (activityId && !watch) {
- toast.success(
- type === 'project' ? m.compose_redeploy_success() : m.container_redeploy_success(),
- activityToastOptions(activityId)
- );
- }
- const containerData = data as ContainerDetailsDto;
- if (type === 'container' && containerData?.id) {
- goto(`/containers/${containerData.id}`);
- } else if (type === 'container') {
- goto('/containers');
- } else {
- onActionComplete('running');
- }
- }
- });
+ action: () => handleRedeploy(watch)
+ }
+ });
+ }
+
+ async function handleRedeploy(watch: boolean) {
+ const operationStartedAt = Math.floor(Temporal.Now.instant().epochMilliseconds / 1000);
+ if (watch) {
+ operationWatchStore.start(`${m.common_redeploy()} — ${name ?? id}`);
+ }
+ const result = await redeployMutation.mutateAsync({ watch });
+ if (watch && result.error) {
+ operationWatchStore.fail(result.error.message || m.common_action_failed_with_type({ action: m.common_redeploy(), type }));
+ return;
+ }
+ if (watch) {
+ enterInteractiveWatchInternal(operationStartedAt);
+ }
+ await handleApiResultWithCallbacks({
+ result,
+ message: m.common_action_failed_with_type({ action: m.common_redeploy(), type }),
+ onSuccess: async (data) => {
+ const activityId = type === 'container' ? extractActivityId(data) : redeployActivityId;
+ if (activityId && !watch) {
+ toast.success(
+ type === 'project' ? m.compose_redeploy_success() : m.container_redeploy_success(),
+ activityToastOptions(activityId)
+ );
+ }
+ const containerData = data as ContainerDetailsDto;
+ if (type === 'container' && containerData?.id) {
+ goto(`/containers/${containerData.id}`);
+ } else if (type === 'container') {
+ goto('/containers');
+ } else {
+ onActionComplete('running');
}
}
});
@@ -519,7 +549,7 @@
loading: uiLoading.start,
disabled,
disabledReason,
- onclick: () => handleDeploy(),
+ onclick: () => confirmDeploy(false),
menuContent: upMenu
});
}
@@ -635,7 +665,7 @@
{#snippet upMenu(disabled: boolean)}
<DeployOptionsMenuItems />
<DropdownMenu.Separator />
- {@render watchItem(() => handleDeploy(undefined, true), disabled)}
+ {@render watchItem(() => confirmDeploy(true), disabled)}
{/snippet}
{#snippet redeployMenu(disabled: boolean)}
diff --git a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
index 0bb868b89..28339fe50 100644
--- a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
+++ b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
@@ -602,7 +602,7 @@
const normalizedProject = withLoadedProjectIncludeContent(details);
if (!normalizedProject) return;
const savedProjectWorkspaceContents =
- options.preserveProjectWorkspaceContents === true ? { ...projectWorkspaceContents } : {};
+ options.preserveProjectWorkspaceContents === true ? { ...projectWorkspaceContents } : { ...loadedProjectWorkspaceContents };
inputs.name.value = normalizedProject.name || '';
inputs.composeContent.value = normalizedProject.composeContent || '';
@@ -720,20 +720,22 @@
afterNavigate(initializeProjectPreferences);
- async function handleSaveChanges() {
- if (!project || !hasChanges) return;
+ // Resolves true once the project has no unsaved changes left.
+ async function handleSaveChanges(): Promise<boolean> {
+ if (!project) return false;
+ if (!hasChanges) return true;
if (project.isArchived) {
toast.error(m.projects_archive_edit_blocked());
- return;
+ return false;
}
if (hasAnyErrors) {
toast.error(m.templates_validation_error());
- return;
+ return false;
}
const formValues = form.data();
const validated = isGitOpsManaged ? formValues : form.validate();
- if (!validated) return;
+ if (!validated) return false;
const { composeContent, envContent, overrideContent } = validated;
const namePayload = isGitOpsManaged ? undefined : effectiveName;
@@ -804,7 +806,9 @@
const message = error instanceof Error ? error.message : m.common_save_failed();
toast.error(workspaceCommitted ? m.projects_workspace_saved_configuration_failed({ error: message }) : message);
+ return false;
}
+ return true;
} finally {
isLoading.saving = false;
}
@@ -1474,7 +1478,7 @@
{@render gitSourceNotice()}
{@render composeFilesNotice()}
{#if lastPrefsProjectId === project.id}
- <div class="mb-2 flex shrink-0 flex-wrap items-center justify-between gap-2">
+ <div class="mb-3 flex shrink-0 flex-wrap items-center justify-between gap-2">
<div class="flex items-center gap-2">
<label
for="layout-mode-toggle"
@@ -1499,8 +1503,14 @@
</div>
{#if canUpdateProject}
- <div class="flex items-center gap-2">
- <span class={cn('text-xs', hasChanges ? 'text-warning' : 'text-success')}>
+ <div
+ class={cn(
+ // Negative margins cancel the border + padding so toggling the highlight never shifts layout.
+ '-my-[5px] -mr-[5px] flex items-center gap-2 rounded-xl border py-1 pr-1 pl-3 transition-colors duration-200',
+ hasChanges ? 'border-warning/30 bg-warning/10' : 'border-transparent'
+ )}
+ >
+ <span class={cn('text-xs', hasChanges ? 'font-medium text-warning' : 'text-success')}>
{hasChanges ? m.common_unsaved_changes() : m.common_all_changes_saved()}
</span>
{#if hasChanges}
@@ -1516,6 +1526,7 @@
{/if}
<ArcaneButton
action="save"
+ tone={hasChanges ? 'outline-warning' : undefined}
size="sm"
class="min-w-20"
disabled={!canSave}
@@ -2240,6 +2251,8 @@
}}
onRefresh={() => refreshProjectDetails()}
extraActions={projectExtraActions}
+ hasUnsavedChanges={hasChanges}
+ onSaveChanges={handleSaveChanges}
/>
{/snippet}