From 14b6aab9024f456203f8dc08ca8e6fa53ba28601 Mon Sep 17 00:00:00 2001 From: wendrul <53628737+wendrul@users.noreply.github.com> Date: Thu, 26 Feb 2026 17:43:30 +0100 Subject: [PATCH] add button to edit in workspace fork (#8119) * Add button to edit in workspace fork * Remove old fork from script row * Remove fork button from approw * fix frontend check --- .../src/lib/components/FlowBuilder.svelte | 9 +++ .../src/lib/components/ScriptBuilder.svelte | 12 ++++ .../apps/editor/AppEditorHeader.svelte | 14 ++++- .../lib/components/common/table/AppRow.svelte | 25 +++++--- .../components/common/table/FlowRow.svelte | 25 +++++--- .../components/common/table/ScriptRow.svelte | 63 +++++++++++-------- .../raw_apps/RawAppEditorHeader.svelte | 14 ++++- frontend/src/lib/utils/editInFork.ts | 22 +++++++ .../(logged)/flows/get/[...path]/+page.svelte | 14 +++++ .../(root)/(logged)/run/[...run]/+page.svelte | 11 ++++ .../scripts/get/[...hash]/+page.svelte | 14 +++++ 11 files changed, 176 insertions(+), 47 deletions(-) create mode 100644 frontend/src/lib/utils/editInFork.ts diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index 95e659bdf4..5266f4f169 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -96,6 +96,8 @@ import type { FlowBuilderProps } from './flow_builder' import { ModulesTestStates } from './modulesTest.svelte' import FlowAssetsHandler, { initFlowGraphAssetsCtx } from './flows/FlowAssetsHandler.svelte' + import { isRuleActive } from '$lib/workspaceProtectionRules.svelte' + import { buildForkEditUrl } from '$lib/utils/editInFork' let { initialPath = $bindable(''), @@ -810,6 +812,13 @@ onClick: () => window.open(`/flows/add?template=${initialPath}`) }) } + + if (!newFlow && !isRuleActive('DisableWorkspaceForking')) { + dropdownItems.push({ + label: 'Edit in workspace fork', + onClick: () => window.open(buildForkEditUrl('flow', initialPath)) + }) + } } let flowCopilotContext: FlowCopilotContext = $state({ diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte index 9b634fd921..40c4c2b896 100644 --- a/frontend/src/lib/components/ScriptBuilder.svelte +++ b/frontend/src/lib/components/ScriptBuilder.svelte @@ -103,6 +103,8 @@ import { inputSizeClasses } from './text_input/TextInput.svelte' import type { ButtonType } from './common/button/model' import DebounceLimit from './flows/DebounceLimit.svelte' + import { isRuleActive } from '$lib/workspaceProtectionRules.svelte' + import { buildForkEditUrl } from '$lib/utils/editInFork' import OnBehalfOfSelector, { type OnBehalfOfChoice } from './OnBehalfOfSelector.svelte' let { @@ -769,6 +771,16 @@ window.open(`/scripts/add?template=${initialPath}`) } }, + ...(!isRuleActive('DisableWorkspaceForking') + ? [ + { + label: 'Edit in workspace fork', + onClick: () => { + window.open(buildForkEditUrl('script', initialPath)) + } + } + ] + : []), ...(customUi?.topBar?.diff !== false && savedScript && diffDrawer ? [ { diff --git a/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte b/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte index a85602ddfa..f194bc1df7 100644 --- a/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte +++ b/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte @@ -63,6 +63,8 @@ import AppEditorHeaderDeployInitialDraft from './AppEditorHeaderDeployInitialDraft.svelte' import { computeSecretUrl } from './appDeploy.svelte' import { updatePolicy } from './appPolicy' + import { isRuleActive } from '$lib/workspaceProtectionRules.svelte' + import { buildForkEditUrl } from '$lib/utils/editInFork' interface Props { policy: Policy @@ -1118,7 +1120,17 @@ onClick: () => { window.open(`/apps/add?template=${appPath}`) } - } + }, + ...(!isRuleActive('DisableWorkspaceForking') + ? [ + { + label: 'Edit in workspace fork', + onClick: () => { + window.open(buildForkEditUrl('app', $appPath)) + } + } + ] + : []) ] : undefined} > diff --git a/frontend/src/lib/components/common/table/AppRow.svelte b/frontend/src/lib/components/common/table/AppRow.svelte index 529b50ea0b..3998b15af5 100644 --- a/frontend/src/lib/components/common/table/AppRow.svelte +++ b/frontend/src/lib/components/common/table/AppRow.svelte @@ -32,6 +32,8 @@ import AppDeploymentHistory from '$lib/components/apps/editor/AppDeploymentHistory.svelte' import { isDeployable } from '$lib/utils_deployable' import { getDeployUiSettings } from '$lib/components/home/deploy_ui' + import { isRuleActive } from '$lib/workspaceProtectionRules.svelte' + import { buildForkEditUrl } from '$lib/utils/editInFork' interface Props { app: ListableApp & { has_draft?: boolean; draft_only?: boolean; canWrite: boolean } @@ -97,8 +99,8 @@ {/snippet} {#snippet actions()}