-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch re-run jobs UI #4811
Open
ricin9
wants to merge
1
commit into
windmill-labs:main
Choose a base branch
from
ricin9:miloudi/batch-rerun
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Batch re-run jobs UI #4811
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
frontend/src/lib/components/runs/BatchRerunPanel.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<script lang="ts"> | ||
import { base } from '$lib/base' | ||
import { FlowService, JobService, ScriptService, type Job, type ScriptArgs } from '../../gen' | ||
import { Tab, Tabs } from '../common' | ||
import { workspaceStore } from '$lib/stores' | ||
import type { Schema } from '$lib/common' | ||
import SchemaForm from '../SchemaForm.svelte' | ||
|
||
export let selectedIds: string[] | ||
export let jobs: Job[] | undefined | ||
export let blankLink = false | ||
export let workspace: string | undefined | ||
|
||
let viewTab = selectedIds[0] || '' | ||
$: currentViewJob = | ||
viewTab === 'common_args' ? undefined : jobs?.find((job) => job.id === viewTab) | ||
|
||
export let args: { [jobId: string]: ScriptArgs }[] = [] | ||
let schemas: { [jobId: string]: Schema }[] = [] | ||
|
||
$: { | ||
if (currentViewJob && !schemas[currentViewJob.id]) { | ||
loadScript(currentViewJob) | ||
} | ||
} | ||
|
||
async function loadScript(job: Job): Promise<void> { | ||
if (job.job_kind === 'script') { | ||
if (job.script_hash) { | ||
schemas[job.id] = ( | ||
await ScriptService.getScriptByHash({ | ||
workspace: $workspaceStore!, | ||
hash: job.script_hash | ||
}) | ||
).schema | ||
} else if (job.script_path) { | ||
schemas[job.id] = ( | ||
await ScriptService.getScriptByPath({ | ||
workspace: $workspaceStore!, | ||
path: job.script_path | ||
}) | ||
).schema | ||
} | ||
} else if (job.job_kind === 'flow' && job.script_path) { | ||
schemas[job.id] = ( | ||
await FlowService.getFlowByPath({ | ||
workspace: $workspaceStore!, | ||
path: job.script_path | ||
}) | ||
).schema | ||
} | ||
if (schemas[job.id]?.properties && Object.keys(schemas[job.id]).length > 0) { | ||
args[job.id] = await JobService.getJobArgs({ | ||
workspace: $workspaceStore ?? '', | ||
id: job.id | ||
}) | ||
} | ||
} | ||
|
||
$: if (viewTab !== 'common_args' && !selectedIds.includes(viewTab)) { | ||
viewTab = selectedIds[0] || '' // when you are viewing a job's tab and you deselect it | ||
} | ||
</script> | ||
|
||
<div class="p-4 flex flex-col gap-2 items-start h-full"> | ||
{#if selectedIds.length > 0} | ||
<div class=" w-full h-full"> | ||
<Tabs bind:selected={viewTab}> | ||
<!-- <Tab size="xs" value="common_args">Common Input</Tab> --> | ||
{#each selectedIds as selectedJobId} | ||
<Tab size="xs" value={selectedJobId} | ||
>{jobs?.find((job) => job.id === selectedJobId)?.script_path || 'Job'}</Tab | ||
> | ||
{/each} | ||
|
||
<svelte:fragment slot="content"> | ||
<div class="flex flex-col flex-1 h-full"> | ||
{#if viewTab === 'common_args'} | ||
<p>Not currently implemented</p> | ||
{:else} | ||
{@const currentViewJobId = viewTab} | ||
{@const currentViewSchema = schemas[currentViewJobId]} | ||
<a | ||
href="{base}/run/{currentViewJobId}?workspace={workspace ?? $workspaceStore}" | ||
class="flex flex-row gap-1 items-center" | ||
target={blankLink ? '_blank' : undefined} | ||
> | ||
<span class="font-semibold text-sm leading-6">ID:</span> | ||
<span class="text-sm">{currentViewJobId ?? ''}</span> | ||
</a> | ||
|
||
<span class="font-semibold text-xs leading-6">Arguments</span> | ||
|
||
{#if currentViewSchema} | ||
<div class="my-2" /> | ||
{#if !currentViewSchema.properties || Object.keys(currentViewSchema.properties).length === 0} | ||
<div class="text-sm py-4 italic">No arguments</div> | ||
{:else if args[currentViewJobId]} | ||
<span class=" text-xs leading-6" | ||
>Jobs will be re-ran using the old arguments, you can override them below</span | ||
> | ||
<SchemaForm | ||
prettifyHeader | ||
autofocus | ||
schema={currentViewSchema} | ||
bind:args={args[currentViewJobId]} | ||
/> | ||
{:else} | ||
<div class="text-xs text-tertiary">Loading...</div> | ||
{/if} | ||
{:else} | ||
<div class="text-xs text-tertiary">Loading...</div> | ||
{/if} | ||
{/if} | ||
</div> | ||
</svelte:fragment> | ||
</Tabs> | ||
</div> | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using non-null assertion operator (!) with $workspaceStore. Consider handling the case where $workspaceStore might be null or undefined to prevent potential runtime errors.