mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 08:02:26 +00:00
feat: restore flow version as fork (#4032)
* feat: restore flow version as fork * fix: use goto instead of open
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
import Button from '../common/button/Button.svelte'
|
||||
import { ArrowRight, Pencil, X } from 'lucide-svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { goto } from '$app/navigation'
|
||||
|
||||
export let path: string
|
||||
let drawer: Drawer
|
||||
@@ -191,6 +192,13 @@
|
||||
{/if}
|
||||
</span>
|
||||
<div class="flex p-1 gap-2">
|
||||
<Button
|
||||
size="xs"
|
||||
on:click={() =>
|
||||
goto(`/flows/add?template_id=${selectedVersion?.id}&template=${path}`)}
|
||||
>
|
||||
Restore as fork
|
||||
</Button>
|
||||
<Button size="xs" on:click={() => restoreVersion(selected)}
|
||||
>Redeploy with that version
|
||||
</Button>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
const hubId = $page.url.searchParams.get('hub')
|
||||
const templatePath = $page.url.searchParams.get('template')
|
||||
const templateId = $page.url.searchParams.get('template_id')
|
||||
const initialState = hubId || templatePath || nodraft ? undefined : localStorage.getItem('flow')
|
||||
|
||||
let selectedId: string = 'settings-metadata'
|
||||
@@ -98,13 +99,21 @@
|
||||
state?.selectedId && (selectedId = state?.selectedId)
|
||||
} else {
|
||||
if (templatePath) {
|
||||
const template = await FlowService.getFlowByPath({
|
||||
workspace: $workspaceStore!,
|
||||
path: templatePath
|
||||
})
|
||||
let template: Flow
|
||||
if (templateId) {
|
||||
template = await FlowService.getFlowVersion({
|
||||
workspace: $workspaceStore!,
|
||||
path: templatePath,
|
||||
version: parseInt(templateId)
|
||||
})
|
||||
} else {
|
||||
template = await FlowService.getFlowByPath({
|
||||
workspace: $workspaceStore!,
|
||||
path: templatePath
|
||||
})
|
||||
}
|
||||
Object.assign(flow, template)
|
||||
const oldPath = templatePath.split('/')
|
||||
console.log(oldPath)
|
||||
initialPath = `u/${$userStore?.username.split('@')[0]}/${oldPath[oldPath.length - 1]}_fork`
|
||||
flow = flow
|
||||
goto('?', { replaceState: true })
|
||||
|
||||
Reference in New Issue
Block a user