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 | import { currentPlaybookSelector } from "../../store/features/playbook/playbookSlice.ts"; import { store } from "../../store/index.ts"; import { Playbook, Step, StepRelation, StepRelationContract, Task, } from "../../types/index.ts"; import getCurrentStep from "../playbook/step/getCurrentStep.ts"; import { StepStateType, StepStates } from "./StepStates.ts"; function handleStepState(stepId: string): StepStateType { const currentPlaybook: Playbook | undefined = currentPlaybookSelector( store.getState(), ); const [step, id] = getCurrentStep(stepId); let state: StepStateType = StepStates.DEFAULT; const stepRelations: (StepRelation | StepRelationContract)[] = currentPlaybook?.step_relations ?? []; const tasks: Task[] = currentPlaybook?.ui_requirement.tasks ?? []; const relations = stepRelations.filter((relation) => { const parentId = typeof (relation as StepRelation).parent === "string" ? (relation as StepRelation).parent : ((relation as StepRelation).parent as Step).id; return parentId === id; }); const stepTasks = step?.tasks?.map((task) => tasks.find((t) => t.id === (typeof task === "string" ? task : task.id)), ); const logs = relations.map( (relation) => relation?.ui_requirement?.evaluation?.evaluation_result, ); Iif (!step) { state = StepStates.DEFAULT; } const taskWithError = stepTasks?.findIndex( (task) => task?.ui_requirement.showError, ); const logWithError = logs?.find((log) => !log); Iif (step?.ui_requirement.showOutput) { if (taskWithError !== -1) { state = StepStates.ERROR; } else { state = StepStates.SUCCESS; } } Iif (logWithError) { state = StepStates.ERROR; } return state; } export default handleStepState; |