-
Notifications
You must be signed in to change notification settings - Fork 20
feat(studio): Clone DataDesigner job #502
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
126 changes: 126 additions & 0 deletions
126
web/packages/studio/src/components/DataDesignerJobActionsMenu/index.tsx
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,126 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { CJobCancellableStatuses } from '@nemo/common/src/constants/query'; | ||
| import { | ||
| getDataDesignerListCreateJobsQueryKey, | ||
| useDataDesignerCancelCreateJob, | ||
| } from '@nemo/sdk/generated/data-designer/api'; | ||
| import type { CreateJob as DataDesignerJob } from '@nemo/sdk/generated/data-designer/schema'; | ||
| import { DeleteJobModal } from '@studio/components/dataViews/DataDesignerJobsDataView/DeleteJobModal'; | ||
| import { buildClonedJobRequest } from '@studio/components/NewDataDesignerJobForm/utils'; | ||
| import { | ||
| type QuickActionItem, | ||
| QuickActionsMenuRoot, | ||
| } from '@studio/components/QuickActionsMenu/QuickActionsMenuRoot'; | ||
| import { useWorkspaceFromPath } from '@studio/hooks/useWorkspaceFromPath'; | ||
| import { getDataDesignerJobDetailsRoute, getNewDataDesignerJobRoute } from '@studio/routes/utils'; | ||
| import { useQueryClient } from '@tanstack/react-query'; | ||
| import { type FC, useCallback, useState } from 'react'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
|
|
||
| interface DataDesignerJobActionsMenuProps { | ||
| job: DataDesignerJob; | ||
| /** Include a "View details" entry. Used in the table row, omitted on the details page. */ | ||
| includeViewDetails?: boolean; | ||
| /** Called after the job is successfully deleted, e.g. to navigate away from the details page. */ | ||
| onDeleted?: () => void; | ||
| /** Surface a cancel error (or `undefined` to clear) so the caller can render it. */ | ||
| onCancelError?: (message: string | undefined) => void; | ||
| } | ||
|
|
||
| /** | ||
| * Quick-actions menu for a single Data Designer job: View details (optional), Clone, Cancel | ||
| * (when cancellable), and Delete. Shared by the jobs table and the job details page so both | ||
| * expose the same actions. Owns its own delete modal; cancel errors are surfaced via callback. | ||
| */ | ||
| export const DataDesignerJobActionsMenu: FC<DataDesignerJobActionsMenuProps> = ({ | ||
| job, | ||
| includeViewDetails = false, | ||
| onDeleted, | ||
| onCancelError, | ||
| }) => { | ||
| const navigate = useNavigate(); | ||
| const workspace = useWorkspaceFromPath(); | ||
| const queryClient = useQueryClient(); | ||
| const [showDeleteModal, setShowDeleteModal] = useState(false); | ||
|
|
||
| const cancelJobMutation = useDataDesignerCancelCreateJob({ | ||
| mutation: { | ||
| onSuccess: () => { | ||
| queryClient.resetQueries({ | ||
| queryKey: getDataDesignerListCreateJobsQueryKey(workspace), | ||
| }); | ||
| onCancelError?.(undefined); | ||
| }, | ||
| onError: (error) => { | ||
| onCancelError?.(error instanceof Error ? error.message : 'Failed to cancel job'); | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const handleClone = useCallback(() => { | ||
| const cloneJobRequest = buildClonedJobRequest(job); | ||
| if (!cloneJobRequest) return; | ||
| navigate(getNewDataDesignerJobRoute(workspace), { | ||
| state: { cloneJobRequest }, | ||
| }); | ||
| }, [job, navigate, workspace]); | ||
|
|
||
| const handleCancel = useCallback(async () => { | ||
| if (!job.workspace || !job.name) return; | ||
| try { | ||
| onCancelError?.(undefined); | ||
| await cancelJobMutation.mutateAsync({ workspace: job.workspace, name: job.name }); | ||
| } catch { | ||
| // Error is surfaced via the mutation's onError callback. | ||
| } | ||
| }, [job.workspace, job.name, cancelJobMutation, onCancelError]); | ||
|
|
||
| const isCancellable = job.status != null && CJobCancellableStatuses.includes(job.status); | ||
|
|
||
| const actions: QuickActionItem[] = [ | ||
| ...(includeViewDetails | ||
| ? [ | ||
| { | ||
| label: 'View details', | ||
| onSelect: () => { | ||
| if (job.name) { | ||
| navigate(getDataDesignerJobDetailsRoute(workspace, job.name)); | ||
| } | ||
| }, | ||
| }, | ||
| ] | ||
| : []), | ||
| { | ||
| label: 'Clone', | ||
| onSelect: handleClone, | ||
| }, | ||
| ...(isCancellable | ||
| ? [ | ||
| { | ||
| label: 'Cancel', | ||
| onSelect: handleCancel, | ||
| }, | ||
| ] | ||
| : []), | ||
| { | ||
| label: 'Delete', | ||
| onSelect: () => setShowDeleteModal(true), | ||
| danger: true, | ||
| }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <> | ||
| <QuickActionsMenuRoot actions={actions} /> | ||
| {showDeleteModal && ( | ||
| <DeleteJobModal | ||
| jobs={[job]} | ||
| onClose={() => setShowDeleteModal(false)} | ||
| onDeleted={onDeleted} | ||
| /> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
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
69 changes: 69 additions & 0 deletions
69
web/packages/studio/src/components/NewDataDesignerJobForm/JobBasics.tsx
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,69 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { ControlledTextArea } from '@nemo/common/src/components/form/ControlledTextArea'; | ||
| import { ControlledTextInput } from '@nemo/common/src/components/form/ControlledTextInput'; | ||
| import { Flex, Panel, Stack, Text } from '@nvidia/foundations-react-core'; | ||
| import { type Control, type FieldValues, type Path } from 'react-hook-form'; | ||
|
|
||
| export interface JobBasicsProps<T extends FieldValues = FieldValues> { | ||
| control: Control<T>; | ||
| nameName: Path<T>; | ||
| rowsName: Path<T>; | ||
| descriptionName: Path<T>; | ||
| disabled?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * "Job basics" card: name the dataset, set the full-run record count, and describe the job. | ||
| */ | ||
| export function JobBasics<T extends FieldValues>({ | ||
| control, | ||
| nameName, | ||
| rowsName, | ||
| descriptionName, | ||
| disabled = false, | ||
| }: JobBasicsProps<T>) { | ||
| return ( | ||
| <Panel elevation="high" density="standard"> | ||
| <Stack gap="density-lg"> | ||
| <Stack gap="density-xs"> | ||
| <Text kind="label/bold/lg">Job basics</Text> | ||
| <Text kind="body/regular/sm" className="text-secondary"> | ||
| Name your fileset and set the full-run size. | ||
| </Text> | ||
| </Stack> | ||
|
|
||
| <Flex gap="density-md" align="start" className="w-full"> | ||
| <Stack className="min-w-0 flex-1"> | ||
| <ControlledTextInput | ||
| label="Fileset name" | ||
| disabled={disabled} | ||
| useControllerProps={{ name: nameName, control }} | ||
| /> | ||
| </Stack> | ||
| <Stack className="w-[200px] shrink-0"> | ||
| <ControlledTextInput | ||
| label="Records to generate" | ||
| type="number" | ||
| min={1} | ||
| step={1} | ||
| required | ||
| disabled={disabled} | ||
| useControllerProps={{ name: rowsName, control }} | ||
| /> | ||
| </Stack> | ||
| </Flex> | ||
|
|
||
| <ControlledTextArea | ||
| label="Description" | ||
| rows={3} | ||
| placeholder="What this fileset is for and how it will be used…" | ||
| className="w-full" | ||
| disabled={disabled} | ||
| useControllerProps={{ name: descriptionName, control }} | ||
| /> | ||
| </Stack> | ||
| </Panel> | ||
| ); | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.