-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(orchestrator): the instance details card content is cropped (#1196)
- Loading branch information
Showing
4 changed files
with
208 additions
and
62 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
plugins/orchestrator/src/__fixtures__/fakeWorkflowRunDetails.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,12 @@ | ||
import { WorkflowRunDetail } from '../components/WorkflowRunDetail'; | ||
|
||
export const fakeWorkflowRunDetail: WorkflowRunDetail = { | ||
id: '1691fab4-45ce-44d8-840d-5573dfe809b8', | ||
name: 'Assessment Workflow', | ||
workflowId: 'assessment', | ||
started: '2/13/2024, 10:58:26 AM', | ||
duration: 'a few seconds', | ||
category: 'assessment', | ||
status: 'COMPLETED', | ||
description: 'Simple workflow to simulate assessment', | ||
}; |
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
77 changes: 77 additions & 0 deletions
77
plugins/orchestrator/src/components/WorkflowRunDetails.stories.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,77 @@ | ||
import React from 'react'; | ||
|
||
import { Content, InfoCard } from '@backstage/core-components'; | ||
import { wrapInTestApp } from '@backstage/test-utils'; | ||
|
||
import { makeStyles } from '@material-ui/core'; | ||
import Grid from '@material-ui/core/Grid/Grid'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { fakeCompletedInstance } from '../__fixtures__/fakeProcessInstance'; | ||
import { fakeWorkflowRunDetail } from '../__fixtures__/fakeWorkflowRunDetails'; | ||
import { veryLongString } from '../__fixtures__/veryLongString'; | ||
import { orchestratorRootRouteRef } from '../routes'; | ||
import { WorkflowRunDetails } from './WorkflowRunDetails'; | ||
|
||
const useStyles = makeStyles(_ => ({ | ||
topRowCard: { | ||
height: '20rem', | ||
}, | ||
})); | ||
|
||
const meta = { | ||
title: 'Orchestrator/WorkflowDetails', | ||
component: WorkflowRunDetails, | ||
parameters: { | ||
backgrounds: { | ||
default: 'dark', | ||
}, | ||
layout: 'padded', | ||
}, | ||
decorators: [ | ||
Story => | ||
wrapInTestApp( | ||
<Content noPadding> | ||
<Grid container spacing={2}> | ||
<Grid item xs={6}> | ||
<InfoCard | ||
title="Details" | ||
divider={false} | ||
className={useStyles().topRowCard} | ||
> | ||
<Story /> | ||
</InfoCard> | ||
</Grid> | ||
<Grid item xs={6}> | ||
<InfoCard | ||
title="Another card" | ||
divider={false} | ||
className={useStyles().topRowCard} | ||
> | ||
<p>Nothing fancy here...</p> | ||
</InfoCard> | ||
</Grid> | ||
</Grid> | ||
</Content>, | ||
{ | ||
mountedRoutes: { | ||
'/orchestrator': orchestratorRootRouteRef, | ||
}, | ||
}, | ||
), | ||
], | ||
} satisfies Meta<typeof WorkflowRunDetails>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Story1: Story = { | ||
name: 'Very long description', | ||
args: { | ||
assessedBy: fakeCompletedInstance, | ||
details: { | ||
...fakeWorkflowRunDetail, | ||
description: veryLongString, | ||
}, | ||
}, | ||
}; |
110 changes: 110 additions & 0 deletions
110
plugins/orchestrator/src/components/WorkflowRunDetails.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,110 @@ | ||
import React from 'react'; | ||
|
||
import { Link } from '@backstage/core-components'; | ||
import { useRouteRef } from '@backstage/core-plugin-api'; | ||
import { AboutField } from '@backstage/plugin-catalog'; | ||
|
||
import { Grid, makeStyles, Typography } from '@material-ui/core'; | ||
|
||
import { | ||
ProcessInstance, | ||
ProcessInstanceStateValues, | ||
} from '@janus-idp/backstage-plugin-orchestrator-common'; | ||
|
||
import { VALUE_UNAVAILABLE } from '../constants'; | ||
import { workflowInstanceRouteRef } from '../routes'; | ||
import { capitalize } from '../utils/StringUtils'; | ||
import { WorkflowInstanceStatusIndicator } from './WorkflowInstanceStatusIndicator'; | ||
import { WorkflowRunDetail } from './WorkflowRunDetail'; | ||
|
||
type WorkflowDetailsCardProps = { | ||
assessedBy?: ProcessInstance; | ||
details: WorkflowRunDetail; | ||
}; | ||
|
||
const useStyles = makeStyles({ | ||
root: { | ||
overflowY: 'auto', | ||
height: '15rem', | ||
}, | ||
}); | ||
|
||
export const WorkflowRunDetails: React.FC<WorkflowDetailsCardProps> = ({ | ||
assessedBy, | ||
details, | ||
}) => { | ||
const styles = useStyles(); | ||
const workflowInstanceLink = useRouteRef(workflowInstanceRouteRef); | ||
|
||
return ( | ||
<Grid container className={styles.root} alignContent="flex-start"> | ||
<Grid item md={4} key="Category"> | ||
<AboutField label="Category"> | ||
<Typography variant="subtitle2" component="div"> | ||
<b>{capitalize(details.category ?? VALUE_UNAVAILABLE)}</b> | ||
</Typography> | ||
</AboutField> | ||
</Grid> | ||
<Grid item md={4} key="Status"> | ||
<AboutField label="Status"> | ||
<Typography variant="subtitle2" component="div"> | ||
<b> | ||
<WorkflowInstanceStatusIndicator | ||
status={details.status as ProcessInstanceStateValues} | ||
/> | ||
</b> | ||
</Typography> | ||
</AboutField> | ||
</Grid> | ||
<Grid item md={4} key="Duration"> | ||
<AboutField label="Duration"> | ||
<Typography variant="subtitle2" component="div"> | ||
<b>{details.duration}</b> | ||
</Typography> | ||
</AboutField> | ||
</Grid> | ||
|
||
<Grid item md={8} key="ID"> | ||
<AboutField label="ID"> | ||
<Typography variant="subtitle2" component="div"> | ||
<b>{details.id}</b> | ||
</Typography> | ||
</AboutField> | ||
</Grid> | ||
<Grid item md={4} key="Started"> | ||
<AboutField label="Started"> | ||
<Typography variant="subtitle2" component="div"> | ||
<b>{details.started}</b> | ||
</Typography> | ||
</AboutField> | ||
</Grid> | ||
|
||
{assessedBy ? ( | ||
<Grid item md={12} key="Assessed by"> | ||
<AboutField label="Assessed by"> | ||
<Typography variant="subtitle2" component="div"> | ||
<b> | ||
<Link | ||
to={workflowInstanceLink({ | ||
instanceId: assessedBy.id, | ||
})} | ||
> | ||
{assessedBy.processName} | ||
</Link> | ||
</b> | ||
</Typography> | ||
</AboutField> | ||
</Grid> | ||
) : null} | ||
|
||
<Grid item md={12} key="Description"> | ||
<AboutField label="Description"> | ||
<Typography variant="subtitle2" component="div"> | ||
<b>{details.description ?? VALUE_UNAVAILABLE}</b> | ||
</Typography> | ||
</AboutField> | ||
</Grid> | ||
</Grid> | ||
); | ||
}; | ||
WorkflowRunDetails.displayName = 'WorkflowDetails'; |