Skip to content
Open
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
26 changes: 26 additions & 0 deletions frontend/relay-workflows-lib/lib/components/BaseWorkflowRelay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,24 @@ export const BaseWorkflowRelayFragment = graphql`
}
status {
__typename

... on WorkflowRunningStatus {
startTime
}

... on WorkflowSucceededStatus {
startTime
}

... on WorkflowFailedStatus {
startTime
}

... on WorkflowErroredStatus {
startTime
}
}

...WorkflowTasksFragment
}
`;
Expand All @@ -50,6 +67,14 @@ export default function BaseWorkflowRelay({
const navigate = useNavigate();
const data = useFragment(BaseWorkflowRelayFragment, fragmentRef);
const statusText = data.status?.__typename ?? "Unknown";
const submittedTime =
data.status?.__typename === "WorkflowRunningStatus" ||
data.status?.__typename === "WorkflowSucceededStatus" ||
data.status?.__typename === "WorkflowFailedStatus" ||
data.status?.__typename === "WorkflowErroredStatus"
? data.status.startTime
: undefined;

const [selectedTaskIds, setSelectedTaskIds] = useSelectedTaskIds();

const onNavigate = React.useCallback(
Expand Down Expand Up @@ -94,6 +119,7 @@ export default function BaseWorkflowRelay({
instrumentSession: data.visit,
status: statusText as WorkflowStatus,
creator: data.creator.creatorId,
submittedTime,
}}
workflowLink={workflowLink}
expanded={expanded}
Expand Down
18 changes: 10 additions & 8 deletions frontend/relay-workflows-lib/lib/views/SingleWorkflowView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ export default function SingleWorkflowView(props: SingleWorkflowViewProps) {
name: props.workflowName,
},
);
const finished =
queryData.workflow?.status?.__typename &&
finishedStatuses.has(queryData.workflow.status.__typename);

const [isNull, setIsNull] = useState<boolean>(false);

const onNullSubscriptionData = () => {
setIsNull(true);
};

return finished || isNull ? (
<BaseSingleWorkflowView
fragmentRef={queryData.workflow ?? null}
taskIds={props.taskIds}
/>
const workflow = queryData.workflow;

const finished =
workflow?.status != null &&
finishedStatuses.has(workflow.status.__typename);

return workflow && (finished || isNull) ? (
<BaseSingleWorkflowView fragmentRef={workflow} taskIds={props.taskIds} />
) : (
<LiveSingleWorkflowView
{...props}
Expand Down
5 changes: 4 additions & 1 deletion frontend/relay-workflows-lib/relay.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"language": "typescript",
"schema": "./supergraph.graphql",
"exclude": ["**/node_modules/**", "**/__mocks__/**", "**/__generated__/**"],
"eagerEsModules": true
"eagerEsModules": true,
"customScalarTypes": {
"DateTime": "string"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ const WorkflowAccordion: React.FC<WorkflowProps> = ({
<Typography color="#757575">
Creator: {workflow.creator || "Unknown"}
</Typography>

{workflow.submittedTime && (
<Typography color="#757575">
Submitted: {new Date(workflow.submittedTime).toLocaleString()}
</Typography>
)}
</Box>
</AccordionSummary>
<AccordionDetails>{children}</AccordionDetails>
Expand Down
1 change: 1 addition & 0 deletions frontend/workflows-lib/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface Workflow {
instrumentSession: Visit;
status: WorkflowStatus;
creator: string;
submittedTime?: string;
}

export interface Visit {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, if possible please squash the commit history into a single commit to keep the commit history tidy

Expand Down
Loading