From 6d263bdf1e389e59c4d57e2fee1465169fde7bdc Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Mon, 8 Jun 2026 15:22:08 +0200 Subject: [PATCH] refactor(drafts): extract DraftEditorModals trailer block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The four editor routes (scripts/flows/apps/apps_raw) mounted an identical pair of trailer modals — DraftSyncConflictModal + OtherUsersDraftsModal — wrapped in the same guard chain and {#key path} remount. Lift the markup into one component; routes thread their itemKind, path, editPathFor, and loader callback. Pure markup extraction, no state ownership change. Drops the unused userStore import where the trailer was the only consumer. --- .../DraftEditorModals.svelte | 67 +++++++++++++++++++ .../(logged)/apps/edit/[...path]/+page.svelte | 36 ++++------ .../apps_raw/edit/[...path]/+page.svelte | 34 +++------- .../flows/edit/[...path]/+page.svelte | 36 ++++------ .../scripts/edit/[...path]/+page.svelte | 37 ++++------ 5 files changed, 115 insertions(+), 95 deletions(-) create mode 100644 frontend/src/lib/components/common/confirmationModal/DraftEditorModals.svelte diff --git a/frontend/src/lib/components/common/confirmationModal/DraftEditorModals.svelte b/frontend/src/lib/components/common/confirmationModal/DraftEditorModals.svelte new file mode 100644 index 0000000000..ed86138afc --- /dev/null +++ b/frontend/src/lib/components/common/confirmationModal/DraftEditorModals.svelte @@ -0,0 +1,67 @@ + + +{#if enabled && workspace && path} + + {#if otherDraftsUsers.length > 0} + {#key path} + + {/key} + {/if} +{/if} diff --git a/frontend/src/routes/(root)/(logged)/apps/edit/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/apps/edit/[...path]/+page.svelte index 319cc3ea52..855391714c 100644 --- a/frontend/src/routes/(root)/(logged)/apps/edit/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/apps/edit/[...path]/+page.svelte @@ -1,17 +1,15 @@ -{#if $workspaceStore && path} - loadApp()} - getLocalDraft={() => app?.value} - /> -{/if} -{#if $workspaceStore && path && otherDraftsUsers.length > 0} - {#key path} - `/apps/edit/${forkedPath}`} - /> - {/key} -{/if} + `/apps/edit/${forkedPath}`} + onLoadFromServer={() => loadApp()} + getLocalDraft={() => app?.value} +/> {#key redraw} {#if app} diff --git a/frontend/src/routes/(root)/(logged)/apps_raw/edit/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/apps_raw/edit/[...path]/+page.svelte index c65a3bd30a..7f74d38f99 100644 --- a/frontend/src/routes/(root)/(logged)/apps_raw/edit/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/apps_raw/edit/[...path]/+page.svelte @@ -15,11 +15,9 @@ import { type RawAppData, DEFAULT_DATA } from '$lib/components/raw_apps/dataTableRefUtils' import { UserDraft } from '$lib/userDraft.svelte' import { notifyDraftLoaded } from '$lib/userDraftToast' - import DraftSyncConflictModal from '$lib/components/common/confirmationModal/DraftSyncConflictModal.svelte' + import DraftEditorModals from '$lib/components/common/confirmationModal/DraftEditorModals.svelte' import { UserDraftDbSyncer } from '$lib/userDraftDbSyncer.svelte' - import OtherUsersDraftsModal, { - type OtherDraftUser - } from '$lib/components/common/confirmationModal/OtherUsersDraftsModal.svelte' + import { type OtherDraftUser } from '$lib/components/common/confirmationModal/OtherUsersDraftsModal.svelte' import RawAppTemplatePicker, { type RawAppTemplatePickerResult } from '$lib/components/raw_apps/RawAppTemplatePicker.svelte' @@ -382,25 +380,15 @@ -{#if $workspaceStore && path} - loadApp()} - getLocalDraft={() => draftHandle.draft} - /> -{/if} -{#if $workspaceStore && path && otherDraftsUsers.length > 0} - {#key path} - `/apps_raw/edit/${forkedPath}`} - /> - {/key} -{/if} + `/apps_raw/edit/${forkedPath}`} + onLoadFromServer={() => loadApp()} + getLocalDraft={() => draftHandle.draft} +/> diff --git a/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte index 33be431128..5b434d7edd 100644 --- a/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte @@ -3,18 +3,16 @@ import FlowBuilder from '$lib/components/FlowBuilder.svelte' import { editPathFor, invalidate } from '$lib/components/workspacePicker' - import { initialArgsStore, userStore, workspaceStore } from '$lib/stores' + import { initialArgsStore, workspaceStore } from '$lib/stores' import { decodeState, emptySchema, type StateStore } from '$lib/utils' import { initFlow } from '$lib/components/flows/flowStore.svelte' import { goto } from '$lib/navigation' import { sendUserToast } from '$lib/toast' import DiffDrawer from '$lib/components/DiffDrawer.svelte' - import DraftSyncConflictModal from '$lib/components/common/confirmationModal/DraftSyncConflictModal.svelte' + import DraftEditorModals from '$lib/components/common/confirmationModal/DraftEditorModals.svelte' import { UserDraftDbSyncer } from '$lib/userDraftDbSyncer.svelte' - import OtherUsersDraftsModal, { - type OtherDraftUser - } from '$lib/components/common/confirmationModal/OtherUsersDraftsModal.svelte' + import { type OtherDraftUser } from '$lib/components/common/confirmationModal/OtherUsersDraftsModal.svelte' import type { ScheduleTrigger } from '$lib/components/triggers' import type { Trigger } from '$lib/components/triggers/utils' import { tick, untrack } from 'svelte' @@ -317,25 +315,15 @@ -{#if $workspaceStore && flowDraftPath} - loadFlow()} - getLocalDraft={() => flowHandle.draft} - /> -{/if} -{#if $workspaceStore && flowDraftPath && otherDraftsUsers.length > 0} - {#key flowDraftPath} - `/flows/edit/${forkedPath}`} - /> - {/key} -{/if} + `/flows/edit/${forkedPath}`} + onLoadFromServer={() => loadFlow()} + getLocalDraft={() => flowHandle.draft} +/> {#if notFound}

Flow not found at path {page.params.path}

diff --git a/frontend/src/routes/(root)/(logged)/scripts/edit/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/scripts/edit/[...path]/+page.svelte index c8c40e6831..0a18bc19be 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/edit/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/edit/[...path]/+page.svelte @@ -1,16 +1,15 @@ -{#if !hash && $workspaceStore && page.params.path} - loadScript()} - getLocalDraft={() => scriptHandle.draft} - /> -{/if} -{#if !hash && $workspaceStore && page.params.path && otherDraftsUsers.length > 0} - {#key page.params.path} - `/scripts/edit/${forkedPath}`} - /> - {/key} -{/if} + `/scripts/edit/${forkedPath}`} + onLoadFromServer={() => loadScript()} + getLocalDraft={() => scriptHandle.draft} +/> {#if scriptHandle.draft && renderEditor}