-
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.
chore: separate nodeDetailsPanel + add story for taskExecutionsList (#…
…351) * chore: separate nodeDetailsPanel + add story for taskExecutionsList Signed-off-by: Nastya Rusina <[email protected]> * chore: fix retryAttemptCheck Signed-off-by: Nastya Rusina <[email protected]>
- Loading branch information
Showing
17 changed files
with
256 additions
and
153 deletions.
There are no files selected for viewing
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
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
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
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
82 changes: 82 additions & 0 deletions
82
src/components/Executions/ExecutionDetails/NodeExecutionTabs/index.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,82 @@ | ||
import * as React from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { Tab, Tabs } from '@material-ui/core'; | ||
import { NodeExecution } from 'models/Execution/types'; | ||
import { TaskTemplate } from 'models/Task/types'; | ||
import { useTabState } from 'components/hooks/useTabState'; | ||
import { PanelSection } from 'components/common/PanelSection'; | ||
import { DumpJSON } from 'components/common/DumpJSON'; | ||
import { TaskExecutionsList } from '../../TaskExecutionsList/TaskExecutionsList'; | ||
import { NodeExecutionInputs } from './NodeExecutionInputs'; | ||
import { NodeExecutionOutputs } from './NodeExecutionOutputs'; | ||
|
||
const useStyles = makeStyles((theme) => { | ||
return { | ||
content: { | ||
overflowY: 'auto', | ||
}, | ||
tabs: { | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
}, | ||
}; | ||
}); | ||
|
||
const tabIds = { | ||
executions: 'executions', | ||
inputs: 'inputs', | ||
outputs: 'outputs', | ||
task: 'task', | ||
}; | ||
|
||
const defaultTab = tabIds.executions; | ||
|
||
export const NodeExecutionTabs: React.FC<{ | ||
nodeExecution: NodeExecution; | ||
taskTemplate?: TaskTemplate | null; | ||
}> = ({ nodeExecution, taskTemplate }) => { | ||
const styles = useStyles(); | ||
const tabState = useTabState(tabIds, defaultTab); | ||
|
||
if (tabState.value === tabIds.task && !taskTemplate) { | ||
// Reset tab value, if task tab is selected, while no taskTemplate is avaible | ||
// can happen when user switches between nodeExecutions without closing the drawer | ||
tabState.onChange(() => { | ||
/* */ | ||
}, defaultTab); | ||
} | ||
|
||
let tabContent: JSX.Element | null = null; | ||
switch (tabState.value) { | ||
case tabIds.executions: { | ||
tabContent = <TaskExecutionsList nodeExecution={nodeExecution} />; | ||
break; | ||
} | ||
case tabIds.inputs: { | ||
tabContent = <NodeExecutionInputs execution={nodeExecution} />; | ||
break; | ||
} | ||
case tabIds.outputs: { | ||
tabContent = <NodeExecutionOutputs execution={nodeExecution} />; | ||
break; | ||
} | ||
case tabIds.task: { | ||
tabContent = taskTemplate ? ( | ||
<PanelSection> | ||
<DumpJSON value={taskTemplate} /> | ||
</PanelSection> | ||
) : null; | ||
break; | ||
} | ||
} | ||
return ( | ||
<> | ||
<Tabs {...tabState} className={styles.tabs}> | ||
<Tab value={tabIds.executions} label="Executions" /> | ||
<Tab value={tabIds.inputs} label="Inputs" /> | ||
<Tab value={tabIds.outputs} label="Outputs" /> | ||
{!!taskTemplate && <Tab value={tabIds.task} label="Task" />} | ||
</Tabs> | ||
<div className={styles.content}>{tabContent}</div> | ||
</> | ||
); | ||
}; |
22 changes: 0 additions & 22 deletions
22
src/components/Executions/ExecutionDetails/NodeExecutionTaskDetails.tsx
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
src/components/Executions/TaskExecutionsList/TaskExecutions.mocks.ts
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,53 @@ | ||
import { Protobuf } from 'flyteidl'; | ||
import { MessageFormat, ResourceType } from 'models/Common/types'; | ||
import { TaskExecutionPhase } from 'models/Execution/enums'; | ||
import { TaskExecution } from 'models/Execution/types'; | ||
|
||
import * as Long from 'long'; | ||
|
||
// we probably will create a new helper function in future, to make testing/storybooks closer to what we see in API Json responses | ||
const getProtobufTimestampFromIsoTime = (isoDateTime: string): Protobuf.ITimestamp => { | ||
const timeMs = Date.parse(isoDateTime); | ||
const timestamp = new Protobuf.Timestamp(); | ||
timestamp.seconds = Long.fromInt(Math.floor(timeMs / 1000)); | ||
timestamp.nanos = (timeMs % 1000) * 1e6; | ||
return timestamp; | ||
}; | ||
|
||
export const MockPythonTaskExecution: TaskExecution = { | ||
id: { | ||
taskId: { | ||
resourceType: ResourceType.TASK, | ||
project: 'flytesnacks', | ||
domain: 'development', | ||
name: 'athena.workflows.example.say_hello', | ||
version: 'v13', | ||
}, | ||
nodeExecutionId: { | ||
nodeId: 'ff65vi3y', | ||
executionId: { | ||
project: 'flytesnacks', | ||
domain: 'development', | ||
name: 'ogaayir2e3', | ||
}, | ||
}, | ||
}, | ||
inputUri: | ||
's3://flyte-demo/metadata/propeller/flytesnacks-development-ogaayir2e3/athenaworkflowsexamplesayhello/data/inputs.pb', | ||
closure: { | ||
outputUri: | ||
's3://flyte-demo/metadata/propeller/flytesnacks-development-ogaayir2e3/athenaworkflowsexamplesayhello/data/0/outputs.pb', | ||
phase: TaskExecutionPhase.SUCCEEDED, | ||
logs: [ | ||
{ | ||
uri: 'https://console.aws.amazon.com/cloudwatch/home?region=us-east-2#logEventViewer:group=/aws/containerinsights/flyte-demo-2/application;stream=var.log.containers.ogaayir2e3-ff65vi3y-0_flytesnacks-development_ogaayir2e3-ff65vi3y-0-380d210ccaac45a6e2314a155822b36a67e044914069d01323bc18832487ac4a.log', | ||
name: 'Cloudwatch Logs (User)', | ||
messageFormat: MessageFormat.JSON, | ||
}, | ||
], | ||
createdAt: getProtobufTimestampFromIsoTime('2022-03-17T21:30:53.469624134Z'), | ||
updatedAt: getProtobufTimestampFromIsoTime('2022-03-17T21:31:04.011303736Z'), | ||
reason: 'task submitted to K8s', | ||
taskType: 'python-task', | ||
}, | ||
}; |
Oops, something went wrong.