mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-07 08:02:40 +00:00
* fix(frontend): preserve flow settings when updating summary/path from detail page Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(frontend): type builders prop with ReturnType<typeof createDropdownMenu> Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(frontend): extract shared updateItemPathAndSummary utility to deduplicate move/rename logic Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(frontend): enable inline summary/path editing on script detail page Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * improve layout * feat(frontend): add dirty tracking to MoveDrawer Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * nit move drawer * fix(frontend): drop on_behalf_of_email from move/rename and warn user about redeployment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(frontend): hide on_behalf_of warning in MoveDrawer when user is not owner Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(frontend): only reload script when path unchanged in onSaved callback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
100 lines
2.8 KiB
Svelte
100 lines
2.8 KiB
Svelte
<script lang="ts">
|
|
import { createEventDispatcher } from 'svelte'
|
|
import { userStore, workspaceStore } from '$lib/stores'
|
|
import { Alert, Button, Drawer } from './common'
|
|
import DrawerContent from './common/drawer/DrawerContent.svelte'
|
|
import Path from './Path.svelte'
|
|
import { isOwner } from '$lib/utils'
|
|
import { updateItemPathAndSummary, checkFlowOnBehalfOf } from './moveRenameManager'
|
|
import Label from './Label.svelte'
|
|
import TextInput from './text_input/TextInput.svelte'
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
type Kind = 'script' | 'resource' | 'schedule' | 'variable' | 'flow' | 'app'
|
|
|
|
let kind = $state<Kind>('flow')
|
|
let initialPath = $state('')
|
|
let initialSummary = $state('')
|
|
let path = $state<string | undefined>(undefined)
|
|
let summary = $state<string | undefined>(undefined)
|
|
let dirtyPath = $state(false)
|
|
|
|
let drawer = $state<Drawer>() as Drawer
|
|
|
|
let own = $state(false)
|
|
let onBehalfOfEmail = $state<string | undefined>(undefined)
|
|
let hasChanges = $derived((summary ?? '') !== initialSummary || dirtyPath)
|
|
|
|
export async function openDrawer(
|
|
initialPath_l: string,
|
|
summary_l: string | undefined,
|
|
kind_l: Kind
|
|
) {
|
|
kind = kind_l
|
|
path = undefined
|
|
dirtyPath = false
|
|
onBehalfOfEmail = undefined
|
|
initialPath = initialPath_l
|
|
initialSummary = summary_l ?? ''
|
|
summary = summary_l
|
|
loadOwner()
|
|
drawer.openDrawer()
|
|
if (kind === 'flow') {
|
|
onBehalfOfEmail = await checkFlowOnBehalfOf($workspaceStore!, initialPath_l)
|
|
}
|
|
}
|
|
|
|
function loadOwner() {
|
|
own = isOwner(initialPath, $userStore!, $workspaceStore!)
|
|
}
|
|
|
|
async function updatePath() {
|
|
if (kind === 'flow' || kind === 'script' || kind === 'app') {
|
|
await updateItemPathAndSummary({
|
|
workspace: $workspaceStore!,
|
|
kind,
|
|
initialPath,
|
|
newPath: path ?? '',
|
|
newSummary: summary ?? ''
|
|
})
|
|
}
|
|
dispatch('update', path)
|
|
drawer.closeDrawer()
|
|
}
|
|
</script>
|
|
|
|
<Drawer bind:this={drawer}>
|
|
<DrawerContent title="Move/Rename {initialPath}" on:close={drawer.closeDrawer}>
|
|
{#if !own}
|
|
<Alert type="warning" title="Not owner" class="mb-4">
|
|
Since you do not own this item, you cannot move this item (you can however fork it)
|
|
</Alert>
|
|
{/if}
|
|
{#if own && onBehalfOfEmail}
|
|
<Alert type="info" title="Run on behalf of" class="mb-4">
|
|
This flow will be redeployed on behalf of you ({$userStore?.email}) instead of {onBehalfOfEmail}
|
|
</Alert>
|
|
{/if}
|
|
<Label label="Summary" class="mb-6">
|
|
<TextInput
|
|
inputProps={{
|
|
type: 'text',
|
|
placeholder: 'Short summary to be displayed when listed',
|
|
disabled: !own
|
|
}}
|
|
bind:value={summary}
|
|
/>
|
|
</Label>
|
|
|
|
<Label label="Path">
|
|
<Path disabled={!own} {kind} {initialPath} bind:path bind:dirty={dirtyPath} />
|
|
</Label>
|
|
{#snippet actions()}
|
|
<Button variant="accent" disabled={!own || !hasChanges} on:click={updatePath}
|
|
>Move/Rename</Button
|
|
>
|
|
{/snippet}
|
|
</DrawerContent>
|
|
</Drawer>
|