Skip to content
Open
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
14 changes: 7 additions & 7 deletions src/slices/workflowSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ type ConfigurationPanelField = {
}

export type Workflow = {
configurationPanel: string, // XML
configurationPanelJson: string | ConfigurationPanelField[], // 'string' will always be the empty string
configurationPanelJson: ConfigurationPanelField[],
description: string,
displayOrder: number,
id: string,
Expand All @@ -54,9 +53,10 @@ const initialState: WorkflowState = {

// fetch workflow definitions from server
export const fetchWorkflowDef = createAppAsyncThunk("workflow/fetchWorkflowDef", async (type: string) => {
type backendWorkflow = Omit<Workflow, "configurationPanelJson"> & { configurationPanelJson: string };
type NewProcessing = {
default_workflow_id: string,
workflows: Workflow[],
workflows: backendWorkflow[],
}
let urlParams;

Expand Down Expand Up @@ -90,16 +90,16 @@ export const fetchWorkflowDef = createAppAsyncThunk("workflow/fetchWorkflowDef",
// and then `fulfilled` or `rejected` actions based on the promise.
const res = await axios.get<NewProcessing>("/admin-ng/event/new/processing?", { params: urlParams });

let workflows = camelcaseKeys(res.data.workflows);
const workflows = camelcaseKeys(res.data.workflows);

workflows = workflows.map((workflow: Workflow) => {
const parsedWorkflows = workflows.map(workflow => {
if (workflow.configurationPanelJson.length > 0) {
return {
...workflow,
// TODO: Handle JSON parsing errors
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
configurationPanelJson: JSON.parse(
workflow.configurationPanelJson as string,
workflow.configurationPanelJson,
),
};
} else {
Expand All @@ -109,7 +109,7 @@ export const fetchWorkflowDef = createAppAsyncThunk("workflow/fetchWorkflowDef",

const workflowDef = {
defaultWorkflowId: res.data.default_workflow_id,
workflows: workflows,
workflows: parsedWorkflows,
};

return workflowDef;
Expand Down
Loading