From 9e2279463bc1c7ccf9cb479dbdd51dfbcabfda7a Mon Sep 17 00:00:00 2001 From: Isaac Hellendag Date: Wed, 8 Jan 2025 16:37:11 -0600 Subject: [PATCH] [ui] Add tabs to evaluation dialog --- .../EvaluationDetailDialog.tsx | 78 +++++++++++-- .../EvaluationListRow.tsx | 108 ++++-------------- 2 files changed, 90 insertions(+), 96 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/EvaluationDetailDialog.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/EvaluationDetailDialog.tsx index a231e84b917ab..f59c61d662c9c 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/EvaluationDetailDialog.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/EvaluationDetailDialog.tsx @@ -7,6 +7,8 @@ import { Mono, NonIdealState, SpinnerWithText, + Tab, + Tabs, Tag, } from '@dagster-io/ui-components'; import {ReactNode, useMemo, useState} from 'react'; @@ -21,15 +23,19 @@ import { import {usePartitionsForAssetKey} from './usePartitionsForAssetKey'; import {useQuery} from '../../apollo-client'; import {DEFAULT_TIME_FORMAT} from '../../app/time/TimestampFormat'; +import {RunsFeedTableWithFilters} from '../../runs/RunsFeedTable'; import {TimestampDisplay} from '../../schedules/TimestampDisplay'; import {AnchorButton} from '../../ui/AnchorButton'; +export type Tab = 'evaluation' | 'runs'; + interface Props { isOpen: boolean; onClose: () => void; assetKeyPath: string[]; assetCheckName?: string; evaluationID: string; + initialTab?: Tab; } export const EvaluationDetailDialog = ({ @@ -38,6 +44,7 @@ export const EvaluationDetailDialog = ({ evaluationID, assetKeyPath, assetCheckName, + initialTab = 'evaluation', }: Props) => { return ( @@ -46,6 +53,7 @@ export const EvaluationDetailDialog = ({ assetKeyPath={assetKeyPath} assetCheckName={assetCheckName} onClose={onClose} + initialTab={initialTab} /> ); @@ -56,6 +64,7 @@ interface ContentProps { assetKeyPath: string[]; assetCheckName?: string; onClose: () => void; + initialTab?: Tab; } const EvaluationDetailDialogContents = ({ @@ -63,8 +72,10 @@ const EvaluationDetailDialogContents = ({ assetKeyPath, assetCheckName, onClose, + initialTab = 'evaluation', }: ContentProps) => { const [selectedPartition, setSelectedPartition] = useState(null); + const [tabId, setTabId] = useState(initialTab); const {data, loading} = useQuery( GET_SLIM_EVALUATIONS_QUERY, @@ -101,6 +112,8 @@ const EvaluationDetailDialogContents = ({ return ( } + selectedTabId={tabId} + onTabChange={setTabId} body={ @@ -117,6 +130,8 @@ const EvaluationDetailDialogContents = ({ return ( } + selectedTabId={tabId} + onTabChange={setTabId} body={ } + selectedTabId={tabId} + onTabChange={setTabId} + onDone={onClose} body={ } - onDone={onClose} /> ); } + const {runIds} = evaluation; + return ( {allPartitions.length > 0 && evaluation.isLegacy ? ( - + } body={ - + tabId === 'evaluation' ? ( + + ) : ( + + ) } viewAllButton={ viewAllPath ? ( @@ -190,7 +220,6 @@ const EvaluationDetailDialogContents = ({ ) : null } - onDone={onClose} /> ); }; @@ -242,14 +271,43 @@ interface BasicContentProps { header: ReactNode; body: ReactNode; viewAllButton?: ReactNode; + selectedTabId: Tab; + onTabChange: (tabId: Tab) => void; onDone: () => void; + runCount?: number; } // Dialog contents for which the body container is scrollable and expands to fill the height. -const DialogContents = ({header, body, onDone, viewAllButton}: BasicContentProps) => { +const DialogContents = ({ + header, + body, + selectedTabId, + onTabChange, + runCount = 0, + viewAllButton, + onDone, +}: BasicContentProps) => { return ( {header} + + + + 0 ? ( + + Runs ({runCount}) + + ) : ( + 'Runs' + ) + } + disabled={runCount === 0} + /> + +
{body}
diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/EvaluationListRow.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/EvaluationListRow.tsx index e918a49b255d9..871e7da1b17b7 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/EvaluationListRow.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/EvaluationListRow.tsx @@ -1,22 +1,11 @@ -import { - Box, - Button, - ButtonLink, - Colors, - Dialog, - DialogFooter, - DialogHeader, - Mono, -} from '@dagster-io/ui-components'; +import {ButtonLink, Colors} from '@dagster-io/ui-components'; import {useState} from 'react'; -import {Link} from 'react-router-dom'; import {AssetKey} from '../types'; -import {EvaluationDetailDialog} from './EvaluationDetailDialog'; +import {EvaluationDetailDialog, Tab} from './EvaluationDetailDialog'; import {EvaluationStatusTag} from './EvaluationStatusTag'; import {AssetConditionEvaluationRecordFragment} from './types/GetEvaluationsQuery.types'; import {DEFAULT_TIME_FORMAT} from '../../app/time/TimestampFormat'; -import {RunsFeedTableWithFilters} from '../../runs/RunsFeedTable'; import {TimestampDisplay} from '../../schedules/TimestampDisplay'; interface Props { @@ -28,12 +17,18 @@ interface Props { export const EvaluationListRow = ({evaluation, assetKey, assetCheckName, isPartitioned}: Props) => { const [isOpen, setIsOpen] = useState(false); + const [tab, setTab] = useState('evaluation'); return ( <> - setIsOpen(true)}> + { + setTab('evaluation'); + setIsOpen(true); + }} + > - + {evaluation.runIds.length > 0 ? ( + { + setTab('runs'); + setIsOpen(true); + }} + > + {evaluation.runIds.length > 1 ? `${evaluation.runIds.length} runs` : '1 run'} + + ) : ( + None + )} ); }; - -interface EvaluationRunInfoProps { - runIds: string[]; - timestamp: number; -} - -const EvaluationRunInfo = ({runIds, timestamp}: EvaluationRunInfoProps) => { - const [isOpen, setIsOpen] = useState(false); - const firstRun = runIds[0]; - - if (!firstRun) { - return None; - } - - if (runIds.length === 1) { - const truncated = firstRun.slice(0, 8); - - // This looks like a backfill ID. Link there. - if (truncated === firstRun) { - return ( - - {firstRun} - - ); - } - - return ( - - {truncated} - - ); - } - - return ( - <> - setIsOpen(true)}>{runIds.length} runs - setIsOpen(false)} - style={{ - width: '80vw', - maxWidth: '1400px', - minWidth: '800px', - height: '80vh', - minHeight: '400px', - maxHeight: '1400px', - }} - > - - - Runs at{' '} - - - } - /> -
- -
- - - -
-
- - ); -};