From a852f0431b67016288bf6f3bf4f1767d61f2b76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavol=20Porubsk=C3=BD?= Date: Fri, 12 Nov 2021 13:55:29 +0100 Subject: [PATCH] fix types; add external storage to task detail; fix storage in exec workflow detail (#283) --- .../src/common/task-modal.tsx | 320 ++++++++++-------- .../workflow-json-tab.tsx | 2 +- .../executed-workflow-detail.tsx | 23 +- .../executed-workflow-detail/task-table.tsx | 6 +- packages/frinx-workflow-ui/src/types/task.ts | 23 -- packages/frinx-workflow-ui/src/types/types.ts | 41 ++- 6 files changed, 224 insertions(+), 191 deletions(-) diff --git a/packages/frinx-workflow-ui/src/common/task-modal.tsx b/packages/frinx-workflow-ui/src/common/task-modal.tsx index a3892325c..40aa404e6 100644 --- a/packages/frinx-workflow-ui/src/common/task-modal.tsx +++ b/packages/frinx-workflow-ui/src/common/task-modal.tsx @@ -1,5 +1,5 @@ // @flow -import React, { useState } from 'react'; +import React, { useState, VoidFunctionComponent } from 'react'; import { Box, Modal, @@ -21,29 +21,31 @@ import { Divider, Button, } from '@chakra-ui/react'; -import type { Task } from '../types/task'; +import type { ExecutedWorkflowTask } from '../types/types'; import { jsonParse } from './utils'; import { CopyIcon } from '@chakra-ui/icons'; import unescapeJs from 'unescape-js'; +import ExternalStorageModal from '../pages/executed-workflow-detail/executed-workflow-detail-tabs/external-storage-modal'; type Props = { - task: Task; + task: ExecutedWorkflowTask; isOpen: boolean; onClose: () => void; }; -function renderTaskDescription(task: Task) { +function renderTaskDescription(task: ExecutedWorkflowTask) { return ( jsonParse(task?.workflowTask?.description)?.description || jsonParse(task?.workflowTask?.taskDefinition?.description)?.description ); } -const TaskModal = ({ task, isOpen, onClose }: Props) => { +const TaskModal: VoidFunctionComponent = ({ task, isOpen, onClose }) => { const [isEscaped, setIsEscaped] = useState(true); - const { inputData, outputData, logs } = task; + const { inputData, outputData, logs, externalInputPayloadStoragePath, externalOutputPayloadStoragePath } = task; + const [payload, setPayload] = useState<{ type: 'Input' | 'Output'; data: string } | null>(null); - function getUnescapedJSON(data: Task | Object) { + function getUnescapedJSON(data: ExecutedWorkflowTask | Record) { const jsonString = JSON.stringify(data, null, 2); if (!jsonString) { @@ -68,150 +70,182 @@ const TaskModal = ({ task, isOpen, onClose }: Props) => { }; return ( - - - - - {task.taskType} ({task.status}) - - - - - - Summary - JSON - Logs - - - - + <> + {payload && ( + { + setPayload(null); + }} + storagePath={payload.data} + /> + )} + + + + + {task.taskType} ({task.status}) + + + + + + Summary + JSON + Logs + + + + + + Task Ref. Name: + {task.referenceTaskName} + + + Callback After: + {task.callbackAfterSeconds ? task.callbackAfterSeconds : 0} (second) + + + Poll Count: + {task.pollCount} + + + Description: + {renderTaskDescription(task)} + + + - Task Ref. Name: - {task.referenceTaskName} + + + Input + + } + size="sm" + className="clp" + onClick={() => copyToClipBoard(inputData)} + /> + + {externalInputPayloadStoragePath != null && ( + + )} + +