Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #174 from RichardW98/report-url
Browse files Browse the repository at this point in the history
additional info link
  • Loading branch information
RichardW98 committed Jun 19, 2023
2 parents fba5ca5 + 5d70f6a commit 85164cb
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 32 deletions.
40 changes: 12 additions & 28 deletions plugins/parodos/src/components/workflow/WorkflowsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export const WorkflowsTable: React.FC<{
endDate: workflow.endDate
? formatDate.format(Date.parse(workflow.endDate))
: undefined,
additionalInfos: workflow.additionalInfos,
} as WorkflowTableData;
})
.filter(workflow =>
Expand Down Expand Up @@ -273,34 +274,17 @@ export const WorkflowsTable: React.FC<{
<AccordionDetails
className={classes.workflowDescriptionDetails}
>
<Link target="_blank" href="#">
MTA assessment report{' '}
<LaunchIcon
fontSize="inherit"
className={classes.urlIcon}
/>
</Link>
<Link target="_blank" href="#">
Jira ticket{' '}
<LaunchIcon
fontSize="inherit"
className={classes.urlIcon}
/>
</Link>
<Link target="_blank" href="#">
VCS branch{' '}
<LaunchIcon
fontSize="inherit"
className={classes.urlIcon}
/>
</Link>
<Link target="_blank" href="#">
Deployment{' '}
<LaunchIcon
fontSize="inherit"
className={classes.urlIcon}
/>
</Link>
{rowData?.additionalInfos?.map((additionalInfo: any) => {
return (
<Link target="_blank" href={additionalInfo.value}>
{additionalInfo.key}{' '}
<LaunchIcon
fontSize="inherit"
className={classes.urlIcon}
/>
</Link>
);
})}
</AccordionDetails>
</Accordion>
</TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export interface ProjectsPayload {
export function useCreateWorkflow(assessment: string) {
const setWorkflowError = useStore(state => state.setWorkflowError);
const setWorkflowProgress = useStore(state => state.setWorkflowProgress);
const setAssessmentId = useStore(
state => state.setAssessmentWorkflowExecutionId,
);
const { fetch } = useApi(fetchApiRef);
const workflowsUrl = useStore(state => state.getApiUrl(urls.Workflows));
const executeWorkflow = useExecuteWorkflow(assessment);
Expand All @@ -46,7 +49,7 @@ export function useCreateWorkflow(assessment: string) {
workflowsUrl,
executionId: workFlowExecutionId,
});

setAssessmentId(workFlowExecutionId);
const options = displayableWorkflowOptions.flatMap(option => {
const items = workflowOptions[option] ?? [];

Expand All @@ -65,6 +68,7 @@ export function useCreateWorkflow(assessment: string) {
return options;
},
[
setAssessmentId,
executeWorkflow,
fetch,
setWorkflowError,
Expand Down
10 changes: 7 additions & 3 deletions plugins/parodos/src/hooks/useExecuteWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface ExecuteWorkflow {
export function useExecuteWorkflow(assessment: string) {
const { fetch } = useApi(fetchApiRef);
const workflowsUrl = useStore(state => state.getApiUrl(urls.Workflows));
const assessmentId = useStore(state => state.assessmentWorkflowExecutionId);
const workflow = useStore(state =>
state.getWorkDefinitionBy('byName', assessment),
);
Expand All @@ -27,11 +28,14 @@ export function useExecuteWorkflow(assessment: string) {
workflow,
schema: formData,
});

// TODO: task here should be dynamic based on assessment workflow definition
const workFlowResponse = await fetch(workflowsUrl, {
method: 'POST',
body: JSON.stringify(payload),
body: JSON.stringify({
...payload,
invokingExecutionId:
workflow.type.toLowerCase() !== 'assessment' ? assessmentId : null,
}),
});

if (!workFlowResponse.ok) {
Expand All @@ -42,6 +46,6 @@ export function useExecuteWorkflow(assessment: string) {

return workflowExecute.parse(await workFlowResponse.json());
},
[workflow, fetch, workflowsUrl],
[workflow, fetch, workflowsUrl, assessmentId],
);
}
6 changes: 6 additions & 0 deletions plugins/parodos/src/models/workflowTaskSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export const workflowStatusSchema = z.object({
status: transformedStatus,
});

export const additionalInfoSchema = z.object({
key: z.string(),
value: z.string().optional().nullable(),
});

export const projectWorkflowSchema = z.object({
workFlowExecutionId: z.string(),
projectId: z.string(),
Expand All @@ -56,6 +61,7 @@ export const projectWorkflowSchema = z.object({
startDate: z.string(),
endDate: z.string().optional(),
executeBy: z.string(),
additionalInfos: z.array(additionalInfoSchema).optional().nullable(),
});

export const projectWorkflowsSchema = z.array(projectWorkflowSchema);
Expand Down
6 changes: 6 additions & 0 deletions plugins/parodos/src/stores/slices/workflowSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const createWorkflowSlice: StateCreator<
workflowDefinitionsLoading: true,
workflowError: undefined,
workflowProgress: undefined,
assessmentWorkflowExecutionId: undefined,
setWorkflowError(e) {
set(state => {
state.workflowError = e;
Expand All @@ -29,6 +30,11 @@ export const createWorkflowSlice: StateCreator<
state.workflowProgress = percentage;
});
},
setAssessmentWorkflowExecutionId(id) {
set(state => {
state.assessmentWorkflowExecutionId = id;
});
},
cleanUpWorkflow() {
set(state => {
state.workflowError = undefined;
Expand Down
2 changes: 2 additions & 0 deletions plugins/parodos/src/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ export interface WorkflowSlice {
workflowDefinitionsLoading: boolean;
workflowError: unknown | undefined;
workflowProgress: number | undefined;
assessmentWorkflowExecutionId: string | undefined;
setWorkflowError(e: unknown | undefined): void;
setWorkflowProgress(percentage: number): void;
setAssessmentWorkflowExecutionId(id: string): void;
cleanUpWorkflow(): void;
}

Expand Down

0 comments on commit 85164cb

Please sign in to comment.