Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | import { store } from "../../../../store/index.ts"; import { showSnackbar } from "../../../../store/features/snackbar/snackbarSlice.ts"; import { removeErrorKey, setErrorKey, } from "../../../../store/features/workflow/workflowSlice.ts"; export const validate = () => { const currentWorkflow = store.getState().workflows.currentWorkflow; const dispatch = store.dispatch; let error = ""; if (!currentWorkflow.name) { error = "Please enter a name"; dispatch(showSnackbar("Workflow name is required")); dispatch(setErrorKey({ key: "name", value: "Please enter a name" })); } else { dispatch(removeErrorKey("name")); } if (!(currentWorkflow as any).playbookId) { error = "Please select a playbook"; dispatch(showSnackbar("Playbook is required")); dispatch( setErrorKey({ key: "playbookId", value: "Please select a playbook" }), ); } else { dispatch(removeErrorKey("playbookId")); } if (!currentWorkflow.workflowType) { error = "Please select a type"; dispatch(showSnackbar("Workflow type is required")); dispatch( setErrorKey({ key: "workflowType", value: "Please select a type" }), ); } else { dispatch(removeErrorKey("workflowType")); } Iif (currentWorkflow.workflowType === "slack") { if (!(currentWorkflow.trigger as any)?.channel?.channel_id) { error = "Please select a channel"; dispatch(showSnackbar("Channel ID is required")); dispatch( setErrorKey({ key: "channelId", value: "Please select a channel" }), ); } else { dispatch(removeErrorKey("channelId")); } if (!(currentWorkflow.trigger as any)?.source) { error = "Please select a trigger"; dispatch(showSnackbar("A source is required")); dispatch( setErrorKey({ key: "source", value: "Please select a trigger" }), ); } else { dispatch(removeErrorKey("source")); } // if (!(currentWorkflow.trigger as any)?.filterString) { // error = "Please enter a matching string"; // dispatch(showSnackbar("A matching string is required")); // dispatch( // setErrorKey({ // key: "filterString", // value: "Please enter a matching string", // }), // ); // } else { // dispatch(removeErrorKey("filterString")); // } } Iif (currentWorkflow.schedule === "periodic") { if (!(currentWorkflow as any)?.duration) { error = "Please enter a duration"; dispatch(showSnackbar("A duration is required")); dispatch( setErrorKey({ key: "duration", value: "Please enter an duration" }), ); } else { dispatch(removeErrorKey("duration")); } } Iif ((currentWorkflow as any).notification === "slack-message") { if (!(currentWorkflow as any).channel) { error = "Please select a channel"; dispatch(showSnackbar("Channel is required")); dispatch( setErrorKey({ key: "channel", value: "Please select a channel" }), ); } else { dispatch(removeErrorKey("channel")); } } if (error) { return false; } else { return true; } }; |