From 50b5ef51951301fb828ee0cf6f5bfc6cb1546920 Mon Sep 17 00:00:00 2001 From: Nastya <55718143+anrusina@users.noreply.github.com> Date: Mon, 14 Mar 2022 10:49:53 -0700 Subject: [PATCH] fix: long node-id obscures task type (#308) Signed-off-by: Nastya Rusina --- .../Tables/nodeExecutionColumns.tsx | 375 ++++++++---------- 1 file changed, 171 insertions(+), 204 deletions(-) diff --git a/src/components/Executions/Tables/nodeExecutionColumns.tsx b/src/components/Executions/Tables/nodeExecutionColumns.tsx index cb85543a6..d1e976443 100644 --- a/src/components/Executions/Tables/nodeExecutionColumns.tsx +++ b/src/components/Executions/Tables/nodeExecutionColumns.tsx @@ -1,9 +1,5 @@ -import { Typography } from '@material-ui/core'; -import { - formatDateLocalTimezone, - formatDateUTC, - millisecondsToHMS -} from 'common/formatters'; +import { Tooltip, Typography } from '@material-ui/core'; +import { formatDateLocalTimezone, formatDateUTC, millisecondsToHMS } from 'common/formatters'; import { timestampToDate } from 'common/utils'; import { useCommonStyles } from 'components/common/styles'; import { Core } from 'flyteidl'; @@ -17,226 +13,197 @@ import { NodeExecutionCacheStatus } from '../NodeExecutionCacheStatus'; import { getNodeExecutionTimingMS } from '../utils'; import { SelectNodeExecutionLink } from './SelectNodeExecutionLink'; import { useColumnStyles } from './styles'; -import { - NodeExecutionCellRendererData, - NodeExecutionColumnDefinition -} from './types'; +import { NodeExecutionCellRendererData, NodeExecutionColumnDefinition } from './types'; -const ExecutionName: React.FC = ({ - execution, - state -}) => { - const detailsContext = useNodeExecutionContext(); - const [displayName, setDisplayName] = React.useState(); +const ExecutionName: React.FC = ({ execution, state }) => { + const detailsContext = useNodeExecutionContext(); + const [displayName, setDisplayName] = React.useState(); - React.useEffect(() => { - let isCurrent = true; - detailsContext.getNodeExecutionDetails(execution).then(res => { - if (isCurrent) { - setDisplayName(res.displayName); - } - }); - return () => { - isCurrent = false; - }; + React.useEffect(() => { + let isCurrent = true; + detailsContext.getNodeExecutionDetails(execution).then(res => { + if (isCurrent) { + setDisplayName(res.displayName); + } }); + return () => { + isCurrent = false; + }; + }); - const commonStyles = useCommonStyles(); - const styles = useColumnStyles(); + const commonStyles = useCommonStyles(); + const styles = useColumnStyles(); - const isSelected = - state.selectedExecution != null && - isEqual(execution.id, state.selectedExecution); + const isSelected = state.selectedExecution != null && isEqual(execution.id, state.selectedExecution); - const name = displayName ?? execution.id.nodeId; - const truncatedName = name?.split('.').pop() || name; + const name = displayName ?? execution.id.nodeId; + const truncatedName = name?.split('.').pop() || name; - const readableName = isSelected ? ( - - {truncatedName} - - ) : ( - - ); + const readableName = isSelected ? ( + + {truncatedName} + + ) : ( + + ); - return ( - <> - {readableName} - - {displayName} - - - ); + return ( + <> + {readableName} + + {displayName} + + + ); }; const DisplayId: React.FC = ({ execution }) => { - const detailsContext = useNodeExecutionContext(); - const [displayId, setDisplayId] = React.useState(); + const commonStyles = useCommonStyles(); + const detailsContext = useNodeExecutionContext(); + const [displayId, setDisplayId] = React.useState(); - React.useEffect(() => { - let isCurrent = true; - detailsContext.getNodeExecutionDetails(execution).then(res => { - if (isCurrent) { - setDisplayId(res.displayId); - } - }); - return () => { - isCurrent = false; - }; + React.useEffect(() => { + let isCurrent = true; + detailsContext.getNodeExecutionDetails(execution).then(res => { + if (isCurrent) { + setDisplayId(res.displayId); + } }); + return () => { + isCurrent = false; + }; + }); - return <>{displayId ?? execution.id.nodeId}; + const nodeId = displayId ?? execution.id.nodeId; + return ( + +
{nodeId}
+
+ ); }; -const DisplayType: React.FC = ({ - execution -}) => { - const detailsContext = useNodeExecutionContext(); - const [type, setType] = React.useState(); +const DisplayType: React.FC = ({ execution }) => { + const detailsContext = useNodeExecutionContext(); + const [type, setType] = React.useState(); - React.useEffect(() => { - let isCurrent = true; - detailsContext.getNodeExecutionDetails(execution).then(res => { - if (isCurrent) { - setType(res.displayType); - } - }); - return () => { - isCurrent = false; - }; + React.useEffect(() => { + let isCurrent = true; + detailsContext.getNodeExecutionDetails(execution).then(res => { + if (isCurrent) { + setType(res.displayType); + } }); + return () => { + isCurrent = false; + }; + }); - return {type}; + return {type}; }; -const hiddenCacheStatuses = [ - Core.CatalogCacheStatus.CACHE_MISS, - Core.CatalogCacheStatus.CACHE_DISABLED -]; -function hasCacheStatus( - taskNodeMetadata?: TaskNodeMetadata -): taskNodeMetadata is TaskNodeMetadata { - if (!taskNodeMetadata) { - return false; - } - const { cacheStatus } = taskNodeMetadata; - return !hiddenCacheStatuses.includes(cacheStatus); +const hiddenCacheStatuses = [Core.CatalogCacheStatus.CACHE_MISS, Core.CatalogCacheStatus.CACHE_DISABLED]; +function hasCacheStatus(taskNodeMetadata?: TaskNodeMetadata): taskNodeMetadata is TaskNodeMetadata { + if (!taskNodeMetadata) { + return false; + } + const { cacheStatus } = taskNodeMetadata; + return !hiddenCacheStatuses.includes(cacheStatus); } -export function generateColumns( - styles: ReturnType -): NodeExecutionColumnDefinition[] { - return [ - { - cellRenderer: props => , - className: styles.columnName, - key: 'name', - label: 'task name' - }, - { - cellRenderer: props => , - className: styles.columnNodeId, - key: 'nodeId', - label: 'node id' - }, - { - cellRenderer: props => , - className: styles.columnType, - key: 'type', - label: 'type' - }, - { - cellRenderer: ({ - execution: { - closure: { - phase = NodeExecutionPhase.UNDEFINED, - taskNodeMetadata - } - } - }) => ( - <> - - {hasCacheStatus(taskNodeMetadata) ? ( - - ) : null} - - ), - className: styles.columnStatus, - key: 'phase', - label: 'status' - }, - { - cellRenderer: ({ execution: { closure } }) => { - const { startedAt } = closure; - if (!startedAt) { - return ''; - } - const startedAtDate = timestampToDate(startedAt); - return ( - <> - - {formatDateUTC(startedAtDate)} - - - {formatDateLocalTimezone(startedAtDate)} - - - ); - }, - className: styles.columnStartedAt, - key: 'startedAt', - label: 'start time' - }, - { - cellRenderer: ({ execution }) => { - const timing = getNodeExecutionTimingMS(execution); - if (timing === null) { - return ''; - } - return ( - <> - - {millisecondsToHMS(timing.duration)} - - - ); - }, - className: styles.columnDuration, - key: 'duration', - label: () => ( - <> - - duration - - - Queued Time - - - ) - }, - { - cellRenderer: ({ execution, state }) => ( - - ), - className: styles.columnLogs, - key: 'logs', - label: 'logs' +export function generateColumns(styles: ReturnType): NodeExecutionColumnDefinition[] { + return [ + { + cellRenderer: props => , + className: styles.columnName, + key: 'name', + label: 'task name' + }, + { + cellRenderer: props => , + className: styles.columnNodeId, + key: 'nodeId', + label: 'node id' + }, + { + cellRenderer: props => , + className: styles.columnType, + key: 'type', + label: 'type' + }, + { + cellRenderer: ({ + execution: { + closure: { phase = NodeExecutionPhase.UNDEFINED, taskNodeMetadata } + } + }) => ( + <> + + {hasCacheStatus(taskNodeMetadata) ? ( + + ) : null} + + ), + className: styles.columnStatus, + key: 'phase', + label: 'status' + }, + { + cellRenderer: ({ execution: { closure } }) => { + const { startedAt } = closure; + if (!startedAt) { + return ''; + } + const startedAtDate = timestampToDate(startedAt); + return ( + <> + {formatDateUTC(startedAtDate)} + + {formatDateLocalTimezone(startedAtDate)} + + + ); + }, + className: styles.columnStartedAt, + key: 'startedAt', + label: 'start time' + }, + { + cellRenderer: ({ execution }) => { + const timing = getNodeExecutionTimingMS(execution); + if (timing === null) { + return ''; } - ]; + return ( + <> + {millisecondsToHMS(timing.duration)} + + ); + }, + className: styles.columnDuration, + key: 'duration', + label: () => ( + <> + + duration + + + Queued Time + + + ) + }, + { + cellRenderer: ({ execution, state }) => ( + + ), + className: styles.columnLogs, + key: 'logs', + label: 'logs' + } + ]; }