-
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.
feat: add advanced launch options to execution details (#242)
* feat: add advanced launch options to execution details Signed-off-by: csirius <[email protected]> * feat: add mock function for get launch plan Signed-off-by: csirius <[email protected]>
- Loading branch information
Showing
5 changed files
with
96 additions
and
2 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
85 changes: 85 additions & 0 deletions
85
src/components/Executions/ExecutionDetails/ExecutionMetadataExtra.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,85 @@ | ||
import { Typography } from '@material-ui/core'; | ||
import { makeStyles, Theme } from '@material-ui/core/styles'; | ||
import * as classnames from 'classnames'; | ||
import { useCommonStyles } from 'components/common/styles'; | ||
import { Execution } from 'models/Execution/types'; | ||
import * as React from 'react'; | ||
import { ExecutionMetadataLabels } from './constants'; | ||
import { getLaunchPlan } from 'models/Launch/api'; | ||
import { LaunchPlanSpec } from 'models/Launch/types'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => { | ||
return { | ||
detailItem: { | ||
flexShrink: 0, | ||
marginLeft: theme.spacing(4) | ||
} | ||
}; | ||
}); | ||
|
||
interface DetailItem { | ||
className?: string; | ||
label: React.ReactNode; | ||
value: React.ReactNode; | ||
} | ||
|
||
/** | ||
* Renders extra metadata details about a given Execution | ||
* @param execution | ||
* @constructor | ||
*/ | ||
export const ExecutionMetadataExtra: React.FC<{ | ||
execution: Execution; | ||
}> = ({ execution }) => { | ||
const commonStyles = useCommonStyles(); | ||
const styles = useStyles(); | ||
|
||
const { launchPlan: launchPlanId, maxParallelism } = execution.spec; | ||
const [launchPlanSpec, setLaunchPlanSpec] = React.useState< | ||
Partial<LaunchPlanSpec> | ||
>({}); | ||
|
||
React.useEffect(() => { | ||
getLaunchPlan(launchPlanId).then(({ spec }) => setLaunchPlanSpec(spec)); | ||
}, [launchPlanId]); | ||
|
||
const details: DetailItem[] = [ | ||
{ | ||
label: ExecutionMetadataLabels.serviceAccount, | ||
value: launchPlanSpec?.authRole?.kubernetesServiceAccount | ||
}, | ||
{ | ||
label: ExecutionMetadataLabels.rawOutputPrefix, | ||
value: launchPlanSpec?.rawOutputDataConfig?.outputLocationPrefix | ||
}, | ||
{ | ||
label: ExecutionMetadataLabels.parallelism, | ||
value: maxParallelism | ||
} | ||
]; | ||
|
||
return ( | ||
<> | ||
{details.map(({ className, label, value }, idx) => ( | ||
<div | ||
className={classnames(styles.detailItem, className)} | ||
key={idx} | ||
> | ||
<Typography | ||
className={commonStyles.truncateText} | ||
variant="subtitle1" | ||
> | ||
{label} | ||
</Typography> | ||
<Typography | ||
className={commonStyles.truncateText} | ||
variant="h6" | ||
data-testid={`metadata-${label}`} | ||
> | ||
{value} | ||
</Typography> | ||
</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
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