diff --git a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte index 6894a69549..6d9d19942c 100644 --- a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte @@ -562,6 +562,43 @@ let showEditButton = $derived(!isRuleActive('DisableDirectDeployment')) + // Ways to edit what this run executed, offered from the "View" button's dropdown. Only a + // deployed script or flow has an editor to open — hub scripts and previews have no path in + // this workspace to edit. + let editDropdownItems = $derived.by(() => { + const kind = job?.job_kind + const path = job?.script_path ?? '' + if ((kind !== 'script' && kind !== 'flow') || $userStore?.operator) return [] + return [ + ...(canWrite(path, {}, $userStore) + ? [ + { + label: `Edit ${kind}`, + icon: Pen, + href: `/${kind}s/edit/${path}?workspace=${$workspaceStore}`, + disabled: !showEditButton, + onClick: () => { + $initialArgsStore = job?.args + } + } + ] + : []), + ...(!showEditButton && !isCloudHosted() && editInForkAllowed($workspaceStore, $userWorkspaces) + ? [ + { + label: editInForkLabel($workspaceStore, $userWorkspaces), + icon: Pen, + // The href is what a modifier click opens, and where the no-dev-workspace case + // lands; a plain click preventDefaults synchronously and resolves the real + // destination asynchronously instead — hence `hasHref`. + href: buildForkEditUrl(kind, path), + onClick: (e?: Event) => onEditInForkClick(e, kind, path, { hasHref: true }) + } + ] + : []) + ] + }) + // Admins always pass the backend gate. Everyone else fails closed while the rulesets // are still loading, so the item is never briefly offered to a restricted user. let canSharePublicly = $derived( @@ -927,41 +964,12 @@ Run again {/if} - {#if job?.job_kind === 'script' || job?.job_kind === 'flow'} - {#if !$userStore?.operator} - {#if canWrite(job?.script_path ?? '', {}, $userStore)} - - {/if} - {#if !showEditButton && !isCloudHosted() && editInForkAllowed($workspaceStore, $userWorkspaces)} - - {/if} - {/if} - {/if} {#if job?.job_kind === 'script' || job?.job_kind === 'script_hub' || job?.job_kind === 'flow'}