forked from Cloud-Pipelines/pipeline-editor
-
Notifications
You must be signed in to change notification settings - Fork 5
feat: submit run with arguments #1618
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
Open
maxy-shpfy
wants to merge
1
commit into
01-12-fix_call_rerun_pipeline_with_actual_task_arguments
Choose a base branch
from
01-12-feat_submit_run_with_arguments
base: 01-12-fix_call_rerun_pipeline_with_actual_task_arguments
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
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
This file contains hidden or 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 hidden or 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
137 changes: 137 additions & 0 deletions
137
src/components/shared/Submitters/Oasis/components/SubmitTaskArgumentsDialog.tsx
maxy-shpfy marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,137 @@ | ||
| import { type ChangeEvent, useState } from "react"; | ||
|
|
||
| import { typeSpecToString } from "@/components/shared/ReactFlow/FlowCanvas/TaskNode/ArgumentsEditor/utils"; | ||
| import { getArgumentsFromInputs } from "@/components/shared/ReactFlow/FlowCanvas/utils/getArgumentsFromInputs"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { | ||
| Dialog, | ||
| DialogContent, | ||
| DialogDescription, | ||
| DialogFooter, | ||
| DialogHeader, | ||
| DialogTitle, | ||
| } from "@/components/ui/dialog"; | ||
| import { Input } from "@/components/ui/input"; | ||
| import { BlockStack, InlineStack } from "@/components/ui/layout"; | ||
| import { ScrollArea } from "@/components/ui/scroll-area"; | ||
| import { Paragraph } from "@/components/ui/typography"; | ||
| import { cn } from "@/lib/utils"; | ||
| import type { ComponentSpec, InputSpec } from "@/utils/componentSpec"; | ||
|
|
||
| interface SubmitTaskArgumentsDialogProps { | ||
| open: boolean; | ||
| onCancel: () => void; | ||
| onConfirm: (args: Record<string, string>) => void; | ||
| componentSpec: ComponentSpec; | ||
| } | ||
|
|
||
| export const SubmitTaskArgumentsDialog = ({ | ||
| open, | ||
| onCancel, | ||
| onConfirm, | ||
| componentSpec, | ||
| }: SubmitTaskArgumentsDialogProps) => { | ||
| const initialArgs = getArgumentsFromInputs(componentSpec); | ||
|
|
||
| const [taskArguments, setTaskArguments] = | ||
| useState<Record<string, string>>(initialArgs); | ||
|
|
||
| const inputs = componentSpec.inputs ?? []; | ||
|
|
||
| const handleValueChange = (name: string, value: string) => { | ||
| setTaskArguments((prev) => ({ | ||
| ...prev, | ||
| [name]: value, | ||
| })); | ||
| }; | ||
|
|
||
| const handleConfirm = () => onConfirm(taskArguments); | ||
|
|
||
| const handleCancel = () => { | ||
| setTaskArguments(initialArgs); | ||
| onCancel(); | ||
| }; | ||
|
|
||
| const hasInputs = inputs.length > 0; | ||
|
|
||
| return ( | ||
| <Dialog open={open} onOpenChange={handleCancel}> | ||
| <DialogContent className="sm:max-w-lg"> | ||
| <DialogHeader> | ||
| <DialogTitle>Submit Run with Arguments</DialogTitle> | ||
| <DialogDescription> | ||
| {hasInputs | ||
| ? "Customize the pipeline input values before submitting." | ||
| : "This pipeline has no configurable inputs."} | ||
| </DialogDescription> | ||
| </DialogHeader> | ||
|
|
||
| {hasInputs && ( | ||
| <ScrollArea className="max-h-[60vh] pr-4"> | ||
| <BlockStack gap="4" className="p-1"> | ||
| {inputs.map((input) => ( | ||
| <ArgumentField | ||
| key={input.name} | ||
| input={input} | ||
| value={taskArguments[input.name] ?? ""} | ||
| onChange={handleValueChange} | ||
| /> | ||
| ))} | ||
| </BlockStack> | ||
| </ScrollArea> | ||
| )} | ||
|
|
||
| <DialogFooter> | ||
| <Button variant="outline" onClick={handleCancel}> | ||
| Cancel | ||
| </Button> | ||
| <Button onClick={handleConfirm}>Submit Run</Button> | ||
| </DialogFooter> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| }; | ||
|
|
||
| interface ArgumentFieldProps { | ||
| input: InputSpec; | ||
| value: string; | ||
| onChange: (name: string, value: string) => void; | ||
| } | ||
|
|
||
| const ArgumentField = ({ input, value, onChange }: ArgumentFieldProps) => { | ||
| const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
| onChange(input.name, e.target.value); | ||
| }; | ||
|
|
||
| const typeLabel = typeSpecToString(input.type); | ||
| const isRequired = !input.optional; | ||
| const placeholder = input.default ?? ""; | ||
|
|
||
| return ( | ||
| <BlockStack gap="1"> | ||
| <InlineStack gap="2" align="start"> | ||
| <Paragraph size="sm" className="wrap-break-word"> | ||
| {input.name} | ||
maxy-shpfy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </Paragraph> | ||
| <Paragraph size="xs" tone="subdued" className="truncate"> | ||
| ({typeLabel} | ||
| {isRequired ? "*" : ""}) | ||
maxy-shpfy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </Paragraph> | ||
| </InlineStack> | ||
|
|
||
| {input.description && ( | ||
| <Paragraph size="xs" tone="subdued" className="italic"> | ||
| {input.description} | ||
| </Paragraph> | ||
| )} | ||
|
|
||
| <Input | ||
| id={input.name} | ||
| value={value} | ||
| onChange={handleChange} | ||
| placeholder={placeholder} | ||
| className={cn(isRequired && !value && !placeholder && "border-red-300")} | ||
| /> | ||
| </BlockStack> | ||
| ); | ||
| }; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.