Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix workflow selection for scheduled events #1020

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from "react";
import { Formik, FormikErrors } from "formik";
import { Formik } from "formik";
import {
deletingWorkflow as getDeletingWorkflow,
getBaseWorkflow,
Expand All @@ -14,7 +14,6 @@ import Notifications from "../../../shared/Notifications";
import RenderWorkflowConfig from "../wizards/RenderWorkflowConfig";
import { getUserInformation } from "../../../../selectors/userInfoSelectors";
import { hasAccess, parseBooleanInObject } from "../../../../utils/utils";
import { setDefaultConfig } from "../../../../utils/workflowPanelUtils";
import DropDown from "../../../shared/DropDown";
import { useAppDispatch, useAppSelector } from "../../../../store";
import {
Expand All @@ -24,7 +23,6 @@ import {
saveWorkflowConfig,
setModalWorkflowId,
setModalWorkflowTabHierarchy,
updateWorkflow,
} from "../../../../slices/eventDetailsSlice";
import { removeNotificationWizardForm } from "../../../../slices/notificationSlice";
import { renderValidDate } from "../../../../utils/dateUtils";
Expand Down Expand Up @@ -96,20 +94,6 @@ const EventDetailsWorkflowTab = ({
return true;
};

const changeWorkflow = (value: string, changeFormikValue: (field: string, value: unknown) => Promise<void | FormikErrors<any>>) => {
let currentConfiguration = {};

if (value === baseWorkflow.workflowId) {
currentConfiguration = parseBooleanInObject(baseWorkflow.configuration as { [key: string]: any });
} else {
currentConfiguration = setDefaultConfig(workflowDefinitions, value);
}

changeFormikValue("configuration", currentConfiguration);
changeFormikValue("workflowDefinition", value);
dispatch(updateWorkflow(value));
};

const setInitialValues = () => {
let initialConfig = undefined;

Expand Down Expand Up @@ -357,10 +341,7 @@ const EventDetailsWorkflowTab = ({
required={true}
handleChange={(element) => {
if (element) {
changeWorkflow(
element.value,
formik.setFieldValue
)
formik.setFieldValue("workflowDefinition", element.value)
}
}}
placeholder={
Expand Down Expand Up @@ -453,10 +434,6 @@ const EventDetailsWorkflowTab = ({
<button
type="reset"
onClick={() => {
changeWorkflow(
baseWorkflow.workflowId,
formik.setFieldValue
);
formik.resetForm();
}}
disabled={!formik.isValid}
Expand Down
21 changes: 0 additions & 21 deletions src/slices/eventDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
getMetadata,
getExtendedMetadata,
getSchedulingSource,
getWorkflowDefinitions,
getWorkflows,
getStatistics,
} from "../selectors/eventDetailsSelectors";
Expand Down Expand Up @@ -1841,19 +1840,6 @@ export const deleteCommentReply = createAppAsyncThunk('eventDetails/deleteCommen
return true;
});

export const updateWorkflow = createAppAsyncThunk('eventDetails/updateWorkflow', async (workflowId: string, { dispatch, getState }) => {
const state = getState();
const workflowDefinitions = getWorkflowDefinitions(state);
const workflowDef = workflowDefinitions.find((def) => def.id === workflowId);
await dispatch(
setEventWorkflow({
workflowId: workflowId,
description: workflowDef?.description,
configuration: workflowDef?.configuration_panel_json // previously `workflowDef.configuration`. Might cause error
})
);
});

export const saveWorkflowConfig = createAppAsyncThunk('eventDetails/saveWorkflowConfig', async (params: {
values: {
workflowDefinition: string,
Expand Down Expand Up @@ -2565,13 +2551,6 @@ const eventDetailsSlice = createSlice({
.addCase(deleteComment.rejected, (state, action) => {
console.error(action.error);
})
.addCase(updateWorkflow.fulfilled, (state, action) => {
if ("workflowId" in state.workflows.workflow && !!state.workflows.workflow.workflowId) {
state.workflowConfiguration = state.workflows.workflow;
} else {
state.workflowConfiguration = state.baseWorkflow;
}
})
// fetch Tobira data
.addCase(fetchEventDetailsTobira.pending, (state) => {
state.statusTobiraData = 'loading';
Expand Down
Loading