From c5fc069c6d5dfeacb21afa166c4fc3141cac3974 Mon Sep 17 00:00:00 2001 From: aria Date: Wed, 12 Apr 2023 06:01:36 +0800 Subject: [PATCH] feat: show launch plan information in workflow's schedules (#739) * feat: show launch plan in schedules Signed-off-by: Pradithya Aria Pura * fix: fix unit test Signed-off-by: Pradithya Aria Pura --------- Signed-off-by: Pradithya Aria Pura --- .../src/components/Entities/EntityDetails.tsx | 1 - .../components/Entities/EntitySchedules.tsx | 75 +++++++++++++++---- .../src/components/Entities/strings.ts | 3 + .../Entities/test/EntitySchedules.test.tsx | 7 +- 4 files changed, 69 insertions(+), 17 deletions(-) diff --git a/packages/console/src/components/Entities/EntityDetails.tsx b/packages/console/src/components/Entities/EntityDetails.tsx index c37171f0f..283f13143 100644 --- a/packages/console/src/components/Entities/EntityDetails.tsx +++ b/packages/console/src/components/Entities/EntityDetails.tsx @@ -38,7 +38,6 @@ const useStyles = makeStyles((theme: Theme) => ({ }, schedulesContainer: { flex: '1 2 auto', - marginRight: theme.spacing(30), }, inputsContainer: { display: 'flex', diff --git a/packages/console/src/components/Entities/EntitySchedules.tsx b/packages/console/src/components/Entities/EntitySchedules.tsx index d1b9c5520..6c16cca4a 100644 --- a/packages/console/src/components/Entities/EntitySchedules.tsx +++ b/packages/console/src/components/Entities/EntitySchedules.tsx @@ -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, @@ -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'; @@ -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 ( -
    - {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 ( -
  • {scheduleString}
  • - ); - })} -
+ + + + + + + {t(patternKey('launchPlan', 'frequency'))} + + + + + {t(patternKey('launchPlan', 'name'))} + + + + + {t(patternKey('launchPlan', 'version'))} + + + + + + {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 ( + + {scheduleString} + + + {launchPlan.id.name} + + + {launchPlan.id.version} + + ); + })} + +
+
); }; diff --git a/packages/console/src/components/Entities/strings.ts b/packages/console/src/components/Entities/strings.ts index 8c0a62d9b..3ceeb18a8 100644 --- a/packages/console/src/components/Entities/strings.ts +++ b/packages/console/src/components/Entities/strings.ts @@ -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'; diff --git a/packages/console/src/components/Entities/test/EntitySchedules.test.tsx b/packages/console/src/components/Entities/test/EntitySchedules.test.tsx index d6138ba28..a6f1429b7 100644 --- a/packages/console/src/components/Entities/test/EntitySchedules.test.tsx +++ b/packages/console/src/components/Entities/test/EntitySchedules.test.tsx @@ -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'; @@ -26,7 +27,11 @@ describe('EntitySchedules', () => { let launchPlans: LaunchPlan[]; const renderSchedules = async () => { - const result = render(); + const result = render( + + + , + ); await waitFor(() => result.getByText(t('schedulesHeader'))); return result; };