-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace comparison with lodash isEqual
Signed-off-by: Olga Nad <[email protected]>
- Loading branch information
1 parent
950432b
commit 63e0d24
Showing
4 changed files
with
174 additions
and
14 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
packages/zapp/console/src/components/Executions/ExecutionDetails/Timeline/ChartHeader.tsx
This file contains 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,68 @@ | ||
import * as React from 'react'; | ||
import * as moment from 'moment-timezone'; | ||
import makeStyles from '@material-ui/core/styles/makeStyles'; | ||
import { COLOR_SPECTRUM } from 'components/Theme/colorSpectrum'; | ||
import { useScaleContext } from './scaleContext'; | ||
import { TimeZone } from './helpers'; | ||
|
||
interface StyleProps { | ||
chartWidth: number; | ||
labelInterval: number; | ||
} | ||
|
||
const useStyles = makeStyles((_theme) => ({ | ||
chartHeader: (props: StyleProps) => ({ | ||
height: 41, | ||
display: 'flex', | ||
alignItems: 'center', | ||
width: `${props.chartWidth}px`, | ||
}), | ||
taskDurationsLabelItem: (props: StyleProps) => ({ | ||
fontSize: 12, | ||
fontFamily: 'Open Sans', | ||
fontWeight: 'bold', | ||
color: COLOR_SPECTRUM.gray40.color, | ||
paddingLeft: 10, | ||
width: `${props.labelInterval}px`, | ||
}), | ||
})); | ||
|
||
interface HeaderProps extends StyleProps { | ||
chartTimezone: string; | ||
totalDurationSec: number; | ||
startedAt: Date; | ||
} | ||
|
||
export const ChartHeader = (props: HeaderProps) => { | ||
const styles = useStyles(props); | ||
|
||
const { chartInterval: chartTimeInterval, setMaxValue } = useScaleContext(); | ||
const { startedAt, chartTimezone, totalDurationSec } = props; | ||
|
||
React.useEffect(() => { | ||
setMaxValue(props.totalDurationSec); | ||
}, [props.totalDurationSec, setMaxValue]); | ||
|
||
const labels = React.useMemo(() => { | ||
const len = Math.ceil(totalDurationSec / chartTimeInterval); | ||
const lbs = len > 0 ? new Array(len).fill('') : []; | ||
return lbs.map((_, idx) => { | ||
const time = moment.utc(new Date(startedAt.getTime() + idx * chartTimeInterval * 1000)); | ||
return chartTimezone === TimeZone.UTC | ||
? time.format('hh:mm:ss A') | ||
: time.local().format('hh:mm:ss A'); | ||
}); | ||
}, [chartTimezone, startedAt, chartTimeInterval, totalDurationSec]); | ||
|
||
return ( | ||
<div className={styles.chartHeader}> | ||
{labels.map((label) => { | ||
return ( | ||
<div className={styles.taskDurationsLabelItem} key={label}> | ||
{label} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; |
This file contains 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
99 changes: 99 additions & 0 deletions
99
packages/zapp/console/src/components/Executions/ExecutionDetails/Timeline/TaskNames.tsx
This file contains 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,99 @@ | ||
import * as React from 'react'; | ||
import { makeStyles, Theme, Typography } from '@material-ui/core'; | ||
|
||
import { RowExpander } from 'components/Executions/Tables/RowExpander'; | ||
import { getNodeTemplateName } from 'components/WorkflowGraph/utils'; | ||
import { dNode } from 'models/Graph/types'; | ||
import { NodeExecutionName } from './NodeExecutionName'; | ||
import { NodeExecutionsTimelineContext } from './context'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
taskNamesList: { | ||
overflowY: 'scroll', | ||
flex: 1, | ||
}, | ||
namesContainer: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'flex-start', | ||
justifyContent: 'left', | ||
padding: '0 10px', | ||
height: 56, | ||
width: 256, | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
whiteSpace: 'nowrap', | ||
}, | ||
namesContainerExpander: { | ||
display: 'flex', | ||
marginTop: 'auto', | ||
marginBottom: 'auto', | ||
}, | ||
namesContainerBody: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'flex-start', | ||
justifyContent: 'center', | ||
whiteSpace: 'nowrap', | ||
height: '100%', | ||
overflow: 'hidden', | ||
}, | ||
displayName: { | ||
marginTop: 4, | ||
textOverflow: 'ellipsis', | ||
width: '100%', | ||
overflow: 'hidden', | ||
}, | ||
leaf: { | ||
width: 30, | ||
}, | ||
})); | ||
|
||
interface TaskNamesProps { | ||
nodes: dNode[]; | ||
onScroll: () => void; | ||
onToggle: (id: string, scopeId: string, level: number) => void; | ||
} | ||
|
||
export const TaskNames = React.forwardRef<HTMLDivElement, TaskNamesProps>((props, ref) => { | ||
const state = React.useContext(NodeExecutionsTimelineContext); | ||
const { nodes, onScroll, onToggle } = props; | ||
const styles = useStyles(); | ||
|
||
return ( | ||
<div className={styles.taskNamesList} ref={ref} onScroll={onScroll}> | ||
{nodes.map((node) => { | ||
const templateName = getNodeTemplateName(node); | ||
const nodeLevel = node?.level ?? 0; | ||
return ( | ||
<div | ||
className={styles.namesContainer} | ||
key={`level=${nodeLevel}-id=${node.id}-name=${node.scopedId}`} | ||
style={{ paddingLeft: nodeLevel * 16 }} | ||
> | ||
<div className={styles.namesContainerExpander}> | ||
{node.nodes?.length ? ( | ||
<RowExpander | ||
expanded={node.expanded || false} | ||
onClick={() => onToggle(node.id, node.scopedId, nodeLevel)} | ||
/> | ||
) : ( | ||
<div className={styles.leaf} /> | ||
)} | ||
</div> | ||
|
||
<div className={styles.namesContainerBody}> | ||
<NodeExecutionName | ||
name={node.name} | ||
execution={node.execution!} // some nodes don't have associated execution | ||
state={state} | ||
/> | ||
<Typography variant="subtitle1" color="textSecondary" className={styles.displayName}> | ||
{templateName} | ||
</Typography> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}); |
This file contains 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