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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | 1x 1x 1x 1x 1x 1x 1x 1x | import {
LogicalOperator,
PlaybookUIState,
Step,
StepRelationContract,
Task,
TaskType,
} from "../../../../../types";
import generateUUIDWithoutHyphens from "../../../../../utils/common/generateUUIDWithoutHyphens";
import { v4 as uuidv4 } from "uuid";
import { playbookSlice } from "../../playbookSlice";
const emptyTask: Task = {
execution_configuration: {},
interpreter_type: "BASIC_I",
task_connector_sources: [],
source: "",
ui_requirement: {
isOpen: false,
stepId: "",
},
};
const notificationTask: Task = {
execution_configuration: {},
interpreter_type: "BASIC_I",
task_connector_sources: [],
source: "",
description: "Send a message to slack",
slack: {
type: TaskType.Slack,
send_message: {
message: "",
channel: "",
},
},
ui_requirement: {
isOpen: false,
stepId: "",
model_type: "SLACK_CHANNEL",
},
};
const emptyStep: Step = {
id: "",
tasks: [],
ui_requirement: {
isOpen: false,
showError: false,
},
};
export const createPlaybookForDynamicAlert = (state: PlaybookUIState) => {
const stepId = generateUUIDWithoutHyphens();
const taskId = generateUUIDWithoutHyphens();
const notificationTaskId = generateUUIDWithoutHyphens();
const notificationStepId = generateUUIDWithoutHyphens();
const stepRefId = uuidv4();
const notificationStepRefId = uuidv4();
const notificationTaskRefId = uuidv4();
const taskRefId = uuidv4();
const relationId = `edge-${stepRefId}-${notificationStepId}`;
const relation: StepRelationContract = {
id: relationId,
child: {
reference_id: notificationStepRefId,
},
parent: {
reference_id: stepRefId,
},
condition: {
logical_operator: LogicalOperator.AND_LO,
rule_sets: [
{
rules: [],
step_rules: [],
logical_operator: LogicalOperator.AND_LO,
},
],
},
};
state.currentPlaybook = {
global_variable_set: {},
step_relations: [relation],
steps: [
{ ...emptyStep, id: stepId, tasks: [taskId], reference_id: stepRefId },
{
...emptyStep,
id: notificationStepId,
tasks: [notificationTaskId],
reference_id: notificationStepRefId,
},
],
ui_requirement: {
isExisting: false,
tasks: [
{ ...emptyTask, id: taskId, reference_id: taskRefId },
{
...notificationTask,
id: notificationTaskId,
reference_id: notificationTaskRefId,
},
],
},
};
playbookSlice.caseReducers.addRuleForDynamicAlert(state, {
payload: {
id: relation.id,
ruleSetIndex: 0,
},
type: "",
});
playbookSlice.caseReducers.addStepRule(state, {
payload: {
id: relation.id,
ruleSetIndex: 0,
},
type: "",
});
};
|