-
Notifications
You must be signed in to change notification settings - Fork 18
feat(studio): DD schema list in builder #847
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
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
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
74 changes: 74 additions & 0 deletions
74
web/packages/studio/src/routes/DataDesignerJobBuildRoute/SchemaList.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,74 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { Flex, Stack, Text } from '@nvidia/foundations-react-core'; | ||
| import { | ||
| getColumnReferences, | ||
| topologicalSortColumns, | ||
| } from '@studio/routes/DataDesignerJobBuildRoute/columns'; | ||
| import { SchemaRow } from '@studio/routes/DataDesignerJobBuildRoute/SchemaRow'; | ||
| import type { JobBuilderFormValues } from '@studio/routes/DataDesignerJobBuildRoute/useJobBuilder'; | ||
| import { type FC, useMemo } from 'react'; | ||
| import { useFormContext, useWatch } from 'react-hook-form'; | ||
|
|
||
| export interface SchemaListProps { | ||
| selectedId: string | null; | ||
| onSelect: (id: string | null) => void; | ||
| onDelete: (id: string) => void; | ||
| } | ||
|
|
||
| /** | ||
| * A flat, top-to-bottom list of the recipe's columns — a simpler alternative to the DAG | ||
| * canvas. Each row shows the column's type and summary, with its dependencies listed | ||
| * inline as relationship tags rather than drawn as edges. Selecting a row opens the same | ||
| * config pane the canvas uses, so the surrounding left/right panels are unchanged. | ||
| */ | ||
| export const SchemaList: FC<SchemaListProps> = ({ selectedId, onSelect, onDelete }) => { | ||
| const { control } = useFormContext<JobBuilderFormValues>(); | ||
| const columnRecord = useWatch({ control, name: 'columns' }); | ||
| const columns = useMemo(() => topologicalSortColumns(columnRecord), [columnRecord]); | ||
| const referencesById = useMemo(() => { | ||
| const knownNames = new Set(columns.map((column) => column.name).filter(Boolean)); | ||
| return new Map(columns.map((column) => [column.id, getColumnReferences(column, knownNames)])); | ||
| }, [columns]); | ||
|
|
||
| return ( | ||
| <Stack className="h-full overflow-y-auto px-density-2xl py-density-xl"> | ||
| <Flex align="start" justify="between" gap="density-lg" className="mb-density-lg"> | ||
| <Stack gap="density-xxs" className="min-w-0"> | ||
| <Text kind="title/md" className="text-primary"> | ||
| Schema | ||
| </Text> | ||
| <Text kind="body/regular/sm" className="text-secondary"> | ||
| Reference columns with {'{{ column }}'}. | ||
| </Text> | ||
| </Stack> | ||
| </Flex> | ||
|
|
||
| {columns.length === 0 ? ( | ||
| <Flex | ||
| align="center" | ||
| justify="center" | ||
| className="min-h-[160px] flex-1 rounded-md border border-dashed border-base" | ||
| > | ||
| <Text kind="body/regular/md" className="text-secondary"> | ||
| No columns yet — add one from the left to get started. | ||
| </Text> | ||
| </Flex> | ||
| ) : ( | ||
| <Stack gap="density-md"> | ||
| {columns.map((column) => ( | ||
| <SchemaRow | ||
| key={column.id} | ||
| column={column} | ||
| references={referencesById.get(column.id) ?? []} | ||
| selected={column.id === selectedId} | ||
| onSelect={() => onSelect(column.id)} | ||
| onDelete={() => onDelete(column.id)} | ||
| /> | ||
| ))} | ||
| </Stack> | ||
| )} | ||
| </Stack> | ||
| ); | ||
| }; |
105 changes: 105 additions & 0 deletions
105
web/packages/studio/src/routes/DataDesignerJobBuildRoute/SchemaRow.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,105 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { Badge, Button, Flex, Stack, Tag, Text } from '@nvidia/foundations-react-core'; | ||
| import { CardIconBadge } from '@studio/components/common/SelectableCard'; | ||
| import type { BuilderColumn } from '@studio/routes/DataDesignerJobBuildRoute/columns'; | ||
| import { describeColumn } from '@studio/routes/DataDesignerJobBuildRoute/describeColumn'; | ||
| import { Box, Trash2 } from 'lucide-react'; | ||
| import type { FC } from 'react'; | ||
|
|
||
| /** Accent color → NVIDIA Foundations text token, matching the DAG node icon styling. */ | ||
| const ACCENT_ICON_CLASS: Record<string, string> = { | ||
| blue: 'text-[color:var(--text-color-accent-blue)]', | ||
| gray: 'text-[color:var(--text-color-accent-gray)]', | ||
| green: 'text-[color:var(--text-color-accent-green)]', | ||
| purple: 'text-[color:var(--text-color-accent-purple)]', | ||
| red: 'text-[color:var(--text-color-accent-red)]', | ||
| teal: 'text-[color:var(--text-color-accent-teal)]', | ||
| yellow: 'text-[color:var(--text-color-accent-yellow)]', | ||
| }; | ||
|
|
||
| export interface SchemaRowProps { | ||
| column: BuilderColumn; | ||
| /** Names of columns this one references, shown inline as `{{ name }}` relationship tags. */ | ||
| references: string[]; | ||
| selected: boolean; | ||
| onSelect: () => void; | ||
| onDelete: () => void; | ||
| } | ||
|
|
||
| /** | ||
| * One column rendered as a row in the schema list: a generation-step number, an icon badge, | ||
| * the column name, a type badge, a one-line summary, and its relationship tags. Selecting the | ||
| * row opens the same config pane the DAG canvas uses; the trailing button deletes the column. | ||
| */ | ||
| export const SchemaRow: FC<SchemaRowProps> = ({ | ||
| column, | ||
| references, | ||
| selected, | ||
| onSelect, | ||
| onDelete, | ||
| }) => { | ||
| const { option } = column; | ||
| const { typeLabel, detail } = describeColumn(column); | ||
| const Icon = option.icon ?? Box; | ||
|
|
||
| return ( | ||
| <Flex | ||
| align="stretch" | ||
| className={`group overflow-hidden rounded-md border bg-surface-raised transition-colors has-[[data-select]:focus-visible]:ring-2 has-[[data-select]:focus-visible]:ring-(--color-brand,#76b900) ${ | ||
| selected ? 'border-strong' : 'border-base hover:border-strong' | ||
| }`} | ||
| > | ||
| <button | ||
| type="button" | ||
| data-select="" | ||
| onClick={onSelect} | ||
| aria-pressed={selected} | ||
| className="flex min-w-0 flex-1 items-center gap-density-md px-density-lg py-density-md text-left focus-visible:outline-none cursor-pointer" | ||
| > | ||
| <CardIconBadge> | ||
| <Icon size={16} className={ACCENT_ICON_CLASS[option.color] ?? ''} aria-hidden /> | ||
| </CardIconBadge> | ||
|
|
||
| <Stack gap="density-xxs" className="min-w-0 flex-1"> | ||
| <Flex align="center" gap="density-sm" className="min-w-0"> | ||
| <Text kind="body/semibold/sm" className="truncate text-primary"> | ||
| {column.name || option.label} | ||
| </Text> | ||
| <Tag color={option.color} kind="outline" density="compact" readOnly> | ||
| {typeLabel} | ||
| </Tag> | ||
| </Flex> | ||
| {detail ? ( | ||
| <Text kind="body/regular/xs" className="truncate text-secondary"> | ||
| {detail} | ||
| </Text> | ||
| ) : null} | ||
| {references.length > 0 ? ( | ||
| <Flex wrap="wrap" gap="density-xs" className="mt-density-xxs"> | ||
| {references.map((name) => ( | ||
| <Badge key={name} color="blue" kind="solid" className="text-[10px]"> | ||
| {`{{${name}}}`} | ||
| </Badge> | ||
| ))} | ||
| </Flex> | ||
| ) : null} | ||
| </Stack> | ||
| </button> | ||
|
|
||
| <Flex align="center" className="shrink-0 border-l border-base"> | ||
| <Button | ||
| kind="tertiary" | ||
| color="danger" | ||
| size="tiny" | ||
| onClick={onDelete} | ||
| aria-label={`Delete ${column.name || option.label}`} | ||
| className="h-full rounded-none opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100" | ||
| > | ||
| <Trash2 size={16} aria-hidden /> | ||
| </Button> | ||
| </Flex> | ||
| </Flex> | ||
| ); | ||
| }; |
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.
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.