Skip to content

Commit

Permalink
feat: show launch plan information in workflow's schedules (#739)
Browse files Browse the repository at this point in the history
* feat: show launch plan in schedules

Signed-off-by: Pradithya Aria Pura <[email protected]>

* fix: fix unit test

Signed-off-by: Pradithya Aria Pura <[email protected]>

---------

Signed-off-by: Pradithya Aria Pura <[email protected]>
  • Loading branch information
pradithya authored Apr 11, 2023
1 parent 7115a06 commit c5fc069
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 17 deletions.
1 change: 0 additions & 1 deletion packages/console/src/components/Entities/EntityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const useStyles = makeStyles((theme: Theme) => ({
},
schedulesContainer: {
flex: '1 2 auto',
marginRight: theme.spacing(30),
},
inputsContainer: {
display: 'flex',
Expand Down
75 changes: 60 additions & 15 deletions packages/console/src/components/Entities/EntitySchedules.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Typography } from '@material-ui/core';
import {
Paper,
Typography,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
} from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
import {
getScheduleFrequencyString,
Expand All @@ -11,6 +20,7 @@ import { ResourceIdentifier } from 'models/Common/types';
import { identifierToString } from 'models/Common/utils';
import { LaunchPlan } from 'models/Launch/types';
import * as React from 'react';
import { LaunchPlanLink } from 'components/LaunchPlan/LaunchPlanLink';
import { entityStrings } from './constants';
import t, { patternKey } from './strings';

Expand All @@ -25,26 +35,61 @@ const useStyles = makeStyles((theme: Theme) => ({
borderBottom: `1px solid ${theme.palette.divider}`,
marginBottom: theme.spacing(1),
},
headCell: {
color: theme.palette.grey[400],
},
}));

const RenderSchedules: React.FC<{
launchPlans: LaunchPlan[];
}> = ({ launchPlans }) => {
const commonStyles = useCommonStyles();
const styles = useStyles();
return (
<ul className={commonStyles.listUnstyled}>
{launchPlans.map(launchPlan => {
const { schedule } = launchPlan.spec.entityMetadata;
const frequencyString = getScheduleFrequencyString(schedule);
const offsetString = getScheduleOffsetString(schedule);
const scheduleString = offsetString
? `${frequencyString} (offset by ${offsetString})`
: frequencyString;
return (
<li key={identifierToString(launchPlan.id)}>{scheduleString}</li>
);
})}
</ul>
<TableContainer component={Paper}>
<Table size="small">
<TableHead>
<TableRow>
<TableCell>
<Typography className={styles.headCell} variant="h4">
{t(patternKey('launchPlan', 'frequency'))}
</Typography>
</TableCell>
<TableCell className={styles.headCell}>
<Typography className={styles.headCell} variant="h4">
{t(patternKey('launchPlan', 'name'))}
</Typography>
</TableCell>
<TableCell className={styles.headCell}>
<Typography className={styles.headCell} variant="h4">
{t(patternKey('launchPlan', 'version'))}
</Typography>
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{launchPlans.map(launchPlan => {
const { schedule } = launchPlan.spec.entityMetadata;
const frequencyString = getScheduleFrequencyString(schedule);
const offsetString = getScheduleOffsetString(schedule);
const scheduleString = offsetString
? `${frequencyString} (offset by ${offsetString})`
: frequencyString;

return (
<TableRow key={launchPlan.id.name}>
<TableCell>{scheduleString}</TableCell>
<TableCell>
<LaunchPlanLink id={launchPlan.id} color="disabled">
{launchPlan.id.name}
</LaunchPlanLink>
</TableCell>
<TableCell>{launchPlan.id.version}</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</TableContainer>
);
};

Expand Down
3 changes: 3 additions & 0 deletions packages/console/src/components/Entities/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const str = {
configTestSplitRatio: 'test_split_ratio',
noExpectedInputs: 'This launch plan has no expected inputs.',
noFixedInputs: 'This launch plan has no fixed inputs.',
launchPlan_frequency: 'Frequency',
launchPlan_name: 'Launch Plan',
launchPlan_version: 'Version',
};

export { patternKey } from '@flyteorg/locale';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ResourceIdentifier, ResourceType } from 'models/Common/types';
import { listLaunchPlans } from 'models/Launch/api';
import { LaunchPlan, LaunchPlanState } from 'models/Launch/types';
import * as React from 'react';
import { MemoryRouter } from 'react-router';
import { EntitySchedules } from '../EntitySchedules';
import t from '../strings';

Expand All @@ -26,7 +27,11 @@ describe('EntitySchedules', () => {
let launchPlans: LaunchPlan[];

const renderSchedules = async () => {
const result = render(<EntitySchedules id={id} />);
const result = render(
<MemoryRouter>
<EntitySchedules id={id} />
</MemoryRouter>,
);
await waitFor(() => result.getByText(t('schedulesHeader')));
return result;
};
Expand Down

0 comments on commit c5fc069

Please sign in to comment.