mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 16:03:27 +00:00
consistent workspace query arg
This commit is contained in:
@@ -118,10 +118,10 @@
|
||||
}
|
||||
loadingSave = false
|
||||
if (leave) {
|
||||
goto(`/flows/get/${$flowStore.path}?workspace_id=${$workspaceStore}`)
|
||||
goto(`/flows/get/${$flowStore.path}?workspace=${$workspaceStore}`)
|
||||
} else if (initialPath !== $flowStore.path) {
|
||||
initialPath = $flowStore.path
|
||||
goto(`/flows/edit/${$flowStore.path}?workspace_id=${$workspaceStore}`)
|
||||
goto(`/flows/edit/${$flowStore.path}?workspace=${$workspaceStore}`)
|
||||
}
|
||||
} catch (err) {
|
||||
sendUserToast(`The flow could not be saved: ${err.body}`, true)
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
})
|
||||
if (leave) {
|
||||
history.replaceState(history.state, '', `/scripts/edit/${newHash}`)
|
||||
goto(`/scripts/get/${newHash}?workspace_id=${$workspaceStore}`)
|
||||
goto(`/scripts/get/${newHash}?workspace=${$workspaceStore}`)
|
||||
} else {
|
||||
await goto(`/scripts/edit/${newHash}`)
|
||||
script.hash = newHash
|
||||
|
||||
+2
-3
@@ -149,7 +149,7 @@
|
||||
/>
|
||||
{/if}
|
||||
{:else if componentInput?.runnable?.type === 'runnableByPath' && componentInput?.runnable?.path}
|
||||
<div class="p-2 h-full flex flex-col gap-2 ">
|
||||
<div class="p-2 h-full flex flex-col gap-2">
|
||||
{#if componentInput.runnable.runType == 'script' || componentInput.runnable.runType == 'hubscript'}
|
||||
<div>
|
||||
<Button
|
||||
@@ -218,8 +218,7 @@
|
||||
startIcon={{ icon: faEye }}
|
||||
endIcon={{ icon: faExternalLinkAlt }}
|
||||
target="_blank"
|
||||
href="/flows/get/{componentInput?.['runnable']
|
||||
?.path}?workspace_id={$workspaceStore}"
|
||||
href="/flows/get/{componentInput?.['runnable']?.path}?workspace={$workspaceStore}"
|
||||
>
|
||||
Details page
|
||||
</Button>
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
{/if}
|
||||
|
||||
<Button
|
||||
href="/flows/get/{path}?workspace_id={$workspaceStore}"
|
||||
href="/flows/get/{path}?workspace={$workspaceStore}"
|
||||
color="light"
|
||||
variant="border"
|
||||
size="xs"
|
||||
@@ -133,7 +133,7 @@
|
||||
{
|
||||
displayName: 'View flow',
|
||||
icon: faEye,
|
||||
href: `/flows/get/${path}?workspace_id=${$workspaceStore}`
|
||||
href: `/flows/get/${path}?workspace=${$workspaceStore}`
|
||||
},
|
||||
{
|
||||
displayName: 'Edit',
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
{/if}
|
||||
|
||||
<Button
|
||||
href="/scripts/get/{hash}?workspace_id={$workspaceStore}"
|
||||
href="/scripts/get/{hash}?workspace={$workspaceStore}"
|
||||
color="light"
|
||||
variant="border"
|
||||
size="xs"
|
||||
@@ -149,7 +149,7 @@
|
||||
{
|
||||
displayName: 'View script',
|
||||
icon: faEye,
|
||||
href: `/scripts/get/${hash}?workspace_id=${$workspaceStore}`
|
||||
href: `/scripts/get/${hash}?workspace=${$workspaceStore}`
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
@@ -498,7 +498,7 @@ export function scriptPathToHref(path: string): string {
|
||||
if (path.startsWith('hub/')) {
|
||||
return 'https://hub.windmill.dev/from_version/' + path.substring(4)
|
||||
} else {
|
||||
return `/scripts/get/${path}?workspace_id=${get(workspaceStore)}`
|
||||
return `/scripts/get/${path}?workspace=${get(workspaceStore)}`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,13 @@
|
||||
goto('/user/login')
|
||||
}
|
||||
|
||||
$: {
|
||||
let queryWorkspace = $page.url.searchParams.get('workspace')
|
||||
if (queryWorkspace) {
|
||||
$workspaceStore = queryWorkspace
|
||||
}
|
||||
}
|
||||
|
||||
$: if (userSettings && $page.url.hash === USER_SETTINGS_HASH) {
|
||||
userSettings.openDrawer()
|
||||
} else if (superadminSettings && $page.url.hash === SUPERADMIN_SETTINGS_HASH) {
|
||||
|
||||
@@ -19,11 +19,6 @@
|
||||
can_write = canWrite(app?.path, app?.extra_perms!, $userStore)
|
||||
}
|
||||
|
||||
let queryId = $page.url.searchParams.get('workspace_id')
|
||||
if (queryId && queryId != $workspaceStore) {
|
||||
$workspaceStore = $page.url.searchParams.get('workspace_id')!
|
||||
}
|
||||
|
||||
$: if ($workspaceStore && $page.params.path) {
|
||||
loadApp()
|
||||
}
|
||||
|
||||
@@ -50,11 +50,6 @@
|
||||
let path = $page.params.path
|
||||
let shareModal: ShareModal
|
||||
|
||||
let queryId = $page.url.searchParams.get('workspace_id')
|
||||
if (queryId && queryId != $workspaceStore) {
|
||||
$workspaceStore = $page.url.searchParams.get('workspace_id')!
|
||||
}
|
||||
|
||||
$: {
|
||||
if ($workspaceStore && $userStore) {
|
||||
loadFlow()
|
||||
@@ -159,7 +154,7 @@
|
||||
<MoveDrawer
|
||||
bind:this={moveDrawer}
|
||||
on:update={async (e) => {
|
||||
await goto('/flows/get/' + e.detail + `?workspace_id=${$workspaceStore}`)
|
||||
await goto('/flows/get/' + e.detail + `?workspace=${$workspaceStore}`)
|
||||
loadFlow()
|
||||
loadSchedule()
|
||||
}}
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
startIcon={{ icon: faEye }}
|
||||
disabled={flow == undefined}
|
||||
variant="border"
|
||||
href="/flows/get/{flow?.path}?workspace_id={$workspaceStore}"
|
||||
href="/flows/get/{flow?.path}?workspace={$workspaceStore}"
|
||||
>
|
||||
Flow
|
||||
</Button>
|
||||
|
||||
@@ -34,9 +34,6 @@
|
||||
import Dropdown from '$lib/components/Dropdown.svelte'
|
||||
import { goto } from '$app/navigation'
|
||||
|
||||
$: workspace_id = $page.url.searchParams.get('workspace') ?? $workspaceStore
|
||||
$: not_same_workspace = workspace_id !== $workspaceStore
|
||||
|
||||
let job: Job | undefined
|
||||
const iconScale = 1
|
||||
|
||||
@@ -50,17 +47,17 @@
|
||||
const SMALL_ICON_SCALE = 0.7
|
||||
|
||||
async function deleteCompletedJob(id: string): Promise<void> {
|
||||
await JobService.deleteCompletedJob({ workspace: workspace_id!, id })
|
||||
await JobService.deleteCompletedJob({ workspace: $workspaceStore!, id })
|
||||
getLogs()
|
||||
}
|
||||
|
||||
async function cancelJob(id: string) {
|
||||
try {
|
||||
if (forceCancel) {
|
||||
await JobService.forceCancelQueuedJob({ workspace: workspace_id!, id, requestBody: {} })
|
||||
await JobService.forceCancelQueuedJob({ workspace: $workspaceStore!, id, requestBody: {} })
|
||||
setTimeout(getLogs, 5000)
|
||||
} else {
|
||||
await JobService.cancelQueuedJob({ workspace: workspace_id!, id, requestBody: {} })
|
||||
await JobService.cancelQueuedJob({ workspace: $workspaceStore!, id, requestBody: {} })
|
||||
}
|
||||
sendUserToast(`job ${id} canceled`)
|
||||
} catch (err) {
|
||||
@@ -83,7 +80,7 @@
|
||||
}
|
||||
|
||||
$: {
|
||||
if (workspace_id && $page.params.run && testJobLoader) {
|
||||
if ($workspaceStore && $page.params.run && testJobLoader) {
|
||||
forceCancel = false
|
||||
getLogs()
|
||||
}
|
||||
@@ -98,19 +95,24 @@
|
||||
bind:this={testJobLoader}
|
||||
bind:isLoading={testIsLoading}
|
||||
bind:job
|
||||
workspaceOverride={workspace_id}
|
||||
workspaceOverride={$workspaceStore}
|
||||
bind:notfound
|
||||
/>
|
||||
|
||||
{#if notfound}
|
||||
<CenteredPage>
|
||||
<div class="flex flex-col gap-6">
|
||||
<h1 class="text-red-400 mt-6">Job {$page.params.run} not found in {workspace_id}</h1>
|
||||
<h1 class="text-red-400 mt-6">Job {$page.params.run} not found in {$workspaceStore}</h1>
|
||||
<h2>Are you in the right workspace?</h2>
|
||||
<div class="flex flex-col gap-2">
|
||||
{#each $userWorkspaces as workspace}
|
||||
<div>
|
||||
<Button variant="border" href="/run/{$page.params.run}?workspace={workspace.id}">
|
||||
<Button
|
||||
variant="border"
|
||||
on:click={() => {
|
||||
goto(`/run/${$page.params.run}?workspace=${workspace.id}`)
|
||||
}}
|
||||
>
|
||||
See in {workspace.name}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -149,7 +151,6 @@
|
||||
delete
|
||||
</Dropdown>
|
||||
<Button
|
||||
disabled={not_same_workspace}
|
||||
href={runsHref}
|
||||
variant="border"
|
||||
color="blue"
|
||||
@@ -169,7 +170,6 @@
|
||||
{#if isRunning}
|
||||
{#if !forceCancel}
|
||||
<Button
|
||||
disabled={not_same_workspace}
|
||||
color="red"
|
||||
size="md"
|
||||
startIcon={{ icon: faTimesCircle }}
|
||||
@@ -186,7 +186,6 @@
|
||||
</Button>
|
||||
{:else}
|
||||
<Button
|
||||
disabled={not_same_workspace}
|
||||
color="red"
|
||||
size="md"
|
||||
startIcon={{ icon: faTimesCircle }}
|
||||
@@ -200,17 +199,11 @@
|
||||
</Button>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if not_same_workspace}
|
||||
<span class="text-red-500 text-sm"
|
||||
>Disabled because job from a different workspace {workspace_id} (current: {$workspaceStore})</span
|
||||
>
|
||||
{/if}
|
||||
<Button
|
||||
on:click|once={() => {
|
||||
$runFormStore = job?.args
|
||||
goto(`${stem}/run/${route}`)
|
||||
}}
|
||||
disabled={not_same_workspace}
|
||||
color="blue"
|
||||
size="md"
|
||||
startIcon={{ icon: faRefresh }}>Run again</Button
|
||||
@@ -218,7 +211,6 @@
|
||||
{#if !$userStore?.operator}
|
||||
{#if canWrite(job?.script_path ?? '', {}, $userStore)}
|
||||
<Button
|
||||
disabled={not_same_workspace}
|
||||
on:click|once={() => {
|
||||
$runFormStore = job?.args
|
||||
goto(`${stem}/edit/${route}${isScript ? `` : `?nodraft=true`}`)
|
||||
@@ -229,13 +221,7 @@
|
||||
>
|
||||
{/if}
|
||||
{/if}
|
||||
<Button
|
||||
disabled={not_same_workspace}
|
||||
href={viewHref}
|
||||
color="blue"
|
||||
size="md"
|
||||
startIcon={{ icon: faScroll }}
|
||||
>
|
||||
<Button href={viewHref} color="blue" size="md" startIcon={{ icon: faScroll }}>
|
||||
View {job?.job_kind}
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
@@ -292,7 +278,7 @@
|
||||
{/if}
|
||||
{job.script_path ?? (job.job_kind == 'dependencies' ? 'lock dependencies' : 'No path')}
|
||||
{#if job.script_hash}
|
||||
<a href="/scripts/get/{job.script_hash}?workspace_id={workspace_id}}"
|
||||
<a href="/scripts/get/{job.script_hash}?$workspaceStore={$workspaceStore}}"
|
||||
><Badge color="gray">{truncateHash(job.script_hash)}</Badge></a
|
||||
>
|
||||
{/if}
|
||||
@@ -371,7 +357,7 @@
|
||||
on:jobsLoaded={({ detail }) => {
|
||||
job = detail
|
||||
}}
|
||||
workspaceId={workspace_id}
|
||||
workspaceId={$workspaceStore}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -57,10 +57,6 @@
|
||||
|
||||
let shareModal: ShareModal
|
||||
|
||||
let queryId = $page.url.searchParams.get('workspace_id')
|
||||
if (queryId && queryId != $workspaceStore) {
|
||||
$workspaceStore = $page.url.searchParams.get('workspace_id')!
|
||||
}
|
||||
|
||||
$: loading = !script
|
||||
$: if ($workspaceStore) {
|
||||
@@ -179,7 +175,7 @@
|
||||
<MoveDrawer
|
||||
bind:this={moveDrawer}
|
||||
on:update={async (e) => {
|
||||
await goto('/scripts/get/' + e.detail + `?workspace_id=${$workspaceStore}`)
|
||||
await goto('/scripts/get/' + e.detail + `?workspace=${$workspaceStore}`)
|
||||
loadScript($page.params.hash)
|
||||
}}
|
||||
/>
|
||||
@@ -329,9 +325,9 @@
|
||||
variant="contained"
|
||||
size="xs"
|
||||
startIcon={{ icon: faArrowLeft }}
|
||||
href="/scripts/get/{script.parent_hashes[0]}?workspace_id={$workspaceStore}"
|
||||
href="/scripts/get/{script.parent_hashes[0]}?workspace={$workspaceStore}"
|
||||
dropdownItems={script.parent_hashes.map((hash) => ({
|
||||
href: `/scripts/get/${hash}?workspace_id=${$workspaceStore}`,
|
||||
href: `/scripts/get/${hash}?workspace=${$workspaceStore}`,
|
||||
label: hash
|
||||
}))}
|
||||
>
|
||||
@@ -352,7 +348,7 @@
|
||||
{#if topHash}
|
||||
<Alert type="warning" title="Not HEAD">
|
||||
This hash is not HEAD (latest non-archived version at this path) :
|
||||
<a href="/scripts/get/{topHash}?workspace_id={$workspaceStore}"
|
||||
<a href="/scripts/get/{topHash}?workspace={$workspaceStore}"
|
||||
>Go to the HEAD of this path</a
|
||||
>
|
||||
</Alert>
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
startIcon={{ icon: faEye }}
|
||||
disabled={script == undefined}
|
||||
variant="border"
|
||||
href="/scripts/get/{script?.hash}?workspace_id={$workspaceStore}"
|
||||
href="/scripts/get/{script?.hash}?workspace={$workspaceStore}"
|
||||
>Script</Button
|
||||
>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user