Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add advanced launch options to execution details #242

Merged
merged 2 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Link as RouterLink } from 'react-router-dom';
import { Routes } from 'routes/routes';
import { ExpandableExecutionError } from '../Tables/ExpandableExecutionError';
import { ExecutionMetadataLabels } from './constants';
import { ExecutionMetadataExtra } from './ExecutionMetadataExtra';

const useStyles = makeStyles((theme: Theme) => {
return {
Expand Down Expand Up @@ -138,6 +139,7 @@ export const ExecutionMetadata: React.FC<{
</Typography>
</div>
))}
<ExecutionMetadataExtra execution={execution} />
</div>

{error || abortMetadata ? (
Expand Down
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>
))}
</>
);
};
5 changes: 4 additions & 1 deletion src/components/Executions/ExecutionDetails/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export enum ExecutionMetadataLabels {
duration = 'Duration',
time = 'Time',
relatedTo = 'Related to',
version = 'Version'
version = 'Version',
serviceAccount = 'Service Account',
rawOutputPrefix = 'Raw Output Prefix',
parallelism = 'Parallelism'
}

export const tabs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const clusterTestId = `metadata-${ExecutionMetadataLabels.cluster}`;
const startTimeTestId = `metadata-${ExecutionMetadataLabels.time}`;
const durationTestId = `metadata-${ExecutionMetadataLabels.duration}`;

jest.mock('models/Launch/api', () => ({
getLaunchPlan: jest.fn(() => Promise.resolve({ spec: {} }))
}));

describe('ExecutionMetadata', () => {
let execution: Execution;
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/models/Launch/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getLaunchPlan = (id: Identifier, config?: RequestConfig) =>
getAdminEntity<Admin.LaunchPlan, LaunchPlan>(
{
path: makeIdentifierPath(endpointPrefixes.launchPlan, id),
messageType: Admin.Task
messageType: Admin.LaunchPlan
},
config
);