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 | import getCurrentTask from "../playbook/task/getCurrentTask.ts"; import handleErrorMessage from "../playbook/handleErrorMessage.tsx"; import { StepStateType, StepStates } from "./StepStates.ts"; function handleTaskState(taskId: string, log?: any) { const [task] = getCurrentTask(taskId); Iif (!task) { return { state: StepStates.DEFAULT, errorMessage: undefined, }; } const isLoading = task.ui_requirement.outputLoading; const hasError = !isLoading && (task.ui_requirement.showError || Object.keys(task.ui_requirement?.errors ?? {}).length > 0); const errorMessage: React.ReactNode = handleErrorMessage(taskId); const hasSuccess = !isLoading && !hasError && !task.ui_requirement.outputLoading && task.ui_requirement.showOutput && (task.ui_requirement?.outputs?.length ?? 0) > 0 && (task.ui_requirement?.outputs as any[]).every((output: any) => { return output?.error === undefined; }); let state: StepStateType = StepStates.DEFAULT; Iif (log) { if (!log?.evaluation_result) { state = StepStates.ERROR; } else { state = StepStates.SUCCESS; } return { state, errorMessage, }; } if (isLoading) { state = StepStates.LOADING; } else if (hasError) { state = StepStates.ERROR; } else if (hasSuccess) { state = StepStates.SUCCESS; } else { state = StepStates.DEFAULT; } return { state, errorMessage, }; } export default handleTaskState; |