Skip to content

Commit 1c7c97f

Browse files
feat(frontend): display creator name in workflow list
1 parent 6cea1b2 commit 1c7c97f

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

frontend/relay-workflows-lib/lib/components/BaseWorkflowRelay.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export const BaseWorkflowRelayFragment = graphql`
1919
proposalNumber
2020
number
2121
}
22+
creator {
23+
creatorId
24+
}
2225
status {
2326
__typename
2427
}
@@ -90,6 +93,7 @@ export default function BaseWorkflowRelay({
9093
name: data.name,
9194
instrumentSession: data.visit,
9295
status: statusText as WorkflowStatus,
96+
creator: data.creator.creatorId,
9397
}}
9498
workflowLink={workflowLink}
9599
expanded={expanded}

frontend/workflows-lib/lib/components/workflow/WorkflowAccordion.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const WorkflowAccordion: React.FC<WorkflowProps> = ({
4747
onChange={onChange}
4848
>
4949
<AccordionSummary expandIcon={<ArrowDropDownIcon />}>
50-
<Box sx={{ display: "flex", flexGrow: 1, gap: 2 }}>
50+
<Box sx={{ display: "flex", flexBasis: 0, flexGrow: 5, gap: 2 }}>
5151
{getWorkflowStatusIcon(workflow.status)}
5252
{workflowLink && (
5353
<Link
@@ -63,6 +63,11 @@ const WorkflowAccordion: React.FC<WorkflowProps> = ({
6363
})}
6464
<Typography>{workflow.name}</Typography>
6565
</Box>
66+
<Box flexBasis={0} flexGrow={1}>
67+
<Typography color="grey">
68+
Creator: {workflow.creator || "Unknown"}
69+
</Typography>
70+
</Box>
6671
</AccordionSummary>
6772
<AccordionDetails>{children}</AccordionDetails>
6873
</Accordion>

frontend/workflows-lib/lib/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface Workflow {
4444
name: string;
4545
instrumentSession: Visit;
4646
status: WorkflowStatus;
47+
creator: string;
4748
}
4849

4950
export interface Visit {

frontend/workflows-lib/stories/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export const fakeWorkflowA = {
216216
status: "Failed" as WorkflowStatus,
217217
workflow: "workflow1",
218218
instrumentSession: instrumentSession,
219+
creator: "abc73575",
219220
};
220221

221222
export const numpySchema = {

frontend/workflows-lib/tests/components/WorkflowAccordion.test.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ describe("WorkflowAccordion Component", () => {
2222
tasks: [
2323
{ id: "Task-1", name: "Task 1", status: "Succeeded" as TaskStatus },
2424
],
25+
creator: "abc12345",
2526
};
2627

28+
const mockNoCreatorWorkflow = { ...mockWorkflow, creator: "" };
29+
2730
const MockChildComponent = <div>Mocked ChildComponent</div>;
2831
it("should render the workflow name and status icon", () => {
2932
const { getByText } = render(
@@ -37,6 +40,21 @@ describe("WorkflowAccordion Component", () => {
3740
expect(getByText("Mocked WorkflowStatusIcon")).toBeInTheDocument();
3841
});
3942

43+
test.each([
44+
// [test description, expected result, mock workflow]
45+
["should display creator name", "abc12345", mockWorkflow],
46+
["should display unknown if no creator", "Unknown", mockNoCreatorWorkflow],
47+
])("%s", (_, expectedResult, workflow) => {
48+
const { getByText } = render(
49+
<MemoryRouter>
50+
<WorkflowAccordion workflow={workflow}>
51+
{MockChildComponent}
52+
</WorkflowAccordion>
53+
</MemoryRouter>,
54+
);
55+
expect(getByText(`Creator: ${expectedResult}`)).toBeInTheDocument();
56+
});
57+
4058
it("should expand the accordion and render children when clicked", () => {
4159
const { getByText } = render(
4260
<MemoryRouter>

0 commit comments

Comments
 (0)