From 641db23180d5dd99cbf02eef58e6ca12d167a608 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Tue, 14 Feb 2023 21:37:15 +0000 Subject: [PATCH] fix lint. --- Common/Types/Workflow/Components/Manual.ts | 22 +++---- Common/Types/Workflow/WorkflowStatus.ts | 10 ++-- CommonUI/src/Components/Link/Link.tsx | 2 +- .../Components/Workflow/ComponentModal.tsx | 3 +- CommonUI/src/Components/Workflow/RunForm.tsx | 15 +++-- CommonUI/src/Components/Workflow/RunModal.tsx | 60 +++++++++---------- CommonUI/src/Components/Workflow/Workflow.tsx | 24 ++++---- .../Components/Workflow/WorkflowStatus.tsx | 29 +++------ Dashboard/src/Pages/Workflow/Logs.tsx | 14 +++-- Dashboard/src/Pages/Workflow/View/Builder.tsx | 32 +++++----- Dashboard/src/Pages/Workflow/View/Logs.tsx | 14 +++-- Model/Models/WorkflowLog.ts | 26 +++----- 12 files changed, 117 insertions(+), 134 deletions(-) diff --git a/Common/Types/Workflow/Components/Manual.ts b/Common/Types/Workflow/Components/Manual.ts index 8b127fa98e..769f7c49e4 100644 --- a/Common/Types/Workflow/Components/Manual.ts +++ b/Common/Types/Workflow/Components/Manual.ts @@ -12,18 +12,18 @@ const components: Array = [ description: 'Run this workflow manually', iconProp: IconProp.Play, componentType: ComponentType.Trigger, - arguments: [ - + arguments: [], + returnValues: [ + { + type: ComponentInputType.JSON, + name: 'JSON', + description: + 'Enter JSON value that you need to run this workflow', + required: false, + id: 'value', + placeholder: '{"key1": "value1", "key2": "value2", ....}', + }, ], - returnValues: [{ - type: ComponentInputType.JSON, - name: 'JSON', - description: - 'Enter JSON value that you need to run this workflow', - required: false, - id: 'value', - placeholder: '{"key1": "value1", "key2": "value2", ....}', - }], inPorts: [], outPorts: [ { diff --git a/Common/Types/Workflow/WorkflowStatus.ts b/Common/Types/Workflow/WorkflowStatus.ts index 129024f745..89df405a37 100644 --- a/Common/Types/Workflow/WorkflowStatus.ts +++ b/Common/Types/Workflow/WorkflowStatus.ts @@ -1,8 +1,8 @@ - enum WorkflowStatus { - Scheduled = 'Scheduled', - Running = 'Running', +enum WorkflowStatus { + Scheduled = 'Scheduled', + Running = 'Running', Success = 'Success', - Error = 'Error' + Error = 'Error', } -export default WorkflowStatus +export default WorkflowStatus; diff --git a/CommonUI/src/Components/Link/Link.tsx b/CommonUI/src/Components/Link/Link.tsx index a923ea2282..be6d8323a7 100644 --- a/CommonUI/src/Components/Link/Link.tsx +++ b/CommonUI/src/Components/Link/Link.tsx @@ -16,7 +16,7 @@ export interface ComponentProps { style?: React.CSSProperties | undefined; onMouseOver?: (() => void) | undefined; onMouseOut?: (() => void) | undefined; - onMouseLeave?:(() => void) | undefined; + onMouseLeave?: (() => void) | undefined; } const Link: FunctionComponent = ( diff --git a/CommonUI/src/Components/Workflow/ComponentModal.tsx b/CommonUI/src/Components/Workflow/ComponentModal.tsx index b881883e1c..5c70cbd826 100644 --- a/CommonUI/src/Components/Workflow/ComponentModal.tsx +++ b/CommonUI/src/Components/Workflow/ComponentModal.tsx @@ -201,7 +201,8 @@ const ComponentsModal: FunctionComponent = ( '', nodeType: NodeType.Node, - returnValues: {}, + returnValues: + {}, isPreview: true, id: '', diff --git a/CommonUI/src/Components/Workflow/RunForm.tsx b/CommonUI/src/Components/Workflow/RunForm.tsx index 60dbb80ee3..42af3174ff 100644 --- a/CommonUI/src/Components/Workflow/RunForm.tsx +++ b/CommonUI/src/Components/Workflow/RunForm.tsx @@ -30,7 +30,6 @@ const RunForm: FunctionComponent = ( Dictionary >({}); - useEffect(() => { props.onHasFormValidatonErrors(hasFormValidationErrors); }, [hasFormValidationErrors]); @@ -46,7 +45,9 @@ const RunForm: FunctionComponent = ( Return Values from Trigger

- This workflow has a trigger to get it to run. Since this trigger returns some values to work. You can pass these return values from trigger manually and test this workflow. + This workflow has a trigger to get it to run. Since this + trigger returns some values to work. You can pass these + return values from trigger manually and test this workflow.

{component.metadata.returnValues && component.metadata.returnValues.length === 0 && ( @@ -88,7 +89,7 @@ const RunForm: FunctionComponent = ( (returnValue: ReturnValue) => { return { title: `${returnValue.name}`, - + description: `${ returnValue.required ? 'Required' @@ -98,11 +99,14 @@ const RunForm: FunctionComponent = ( [returnValue.id]: true, }, required: returnValue.required, - placeholder: returnValue.placeholder, + placeholder: + returnValue.placeholder, ...componentInputTypeToFormFieldType( returnValue.type, component.returnValues && - component.returnValues[returnValue.id] + component.returnValues[ + returnValue.id + ] ? component.returnValues[ returnValue.id ] @@ -115,7 +119,6 @@ const RunForm: FunctionComponent = ( /> )} - ); }; diff --git a/CommonUI/src/Components/Workflow/RunModal.tsx b/CommonUI/src/Components/Workflow/RunModal.tsx index f6216649a5..0f9a217ac3 100644 --- a/CommonUI/src/Components/Workflow/RunModal.tsx +++ b/CommonUI/src/Components/Workflow/RunModal.tsx @@ -29,25 +29,23 @@ const RunModal: FunctionComponent = ( const [showFormValidationErrors, setShowFormValidationErrors] = useState(false); - - - return ( { - if (Object.keys(hasFormValidationErrors).length > 0) { - setShowFormValidationErrors(true) + setShowFormValidationErrors(true); } else { setShowRunConfirmation(true); } - - }} > <> @@ -68,12 +66,10 @@ const RunModal: FunctionComponent = ( /> )} - {showRunSuccessConfirmation && ( { setShowRunSuccessConfirmation(false); @@ -83,7 +79,6 @@ const RunModal: FunctionComponent = ( /> )} - {showFormValidationErrors && ( = ( /> )} + {component.nodeType === NodeType.Node && ( + { + setComponent({ ...component }); + }} + onHasFormValidatonErrors={( + value: Dictionary + ) => { + setHasFormValidatonErrors({ + ...hasFormValidationErrors, + ...value, + }); + }} + /> + )} - - - {component.nodeType === NodeType.Node && { - setComponent({ ...component }); - }} - onHasFormValidatonErrors={(value: Dictionary) => { - setHasFormValidatonErrors({ - ...hasFormValidationErrors, - ...value, - }); - }} - />} - - {component.nodeType === NodeType.PlaceholderNode && } - - - + {component.nodeType === NodeType.PlaceholderNode && ( + + )} ); diff --git a/CommonUI/src/Components/Workflow/Workflow.tsx b/CommonUI/src/Components/Workflow/Workflow.tsx index 412e90c812..320e747057 100644 --- a/CommonUI/src/Components/Workflow/Workflow.tsx +++ b/CommonUI/src/Components/Workflow/Workflow.tsx @@ -88,7 +88,7 @@ export interface ComponentProps { onComponentPickerModalUpdate: (isModalShown: boolean) => void; workflowId: ObjectID; onRunModalUpdate: (isModalShown: boolean) => void; - onRun: (trigger: NodeDataProp)=> void; + onRun: (trigger: NodeDataProp) => void; } const Workflow: FunctionComponent = (props: ComponentProps) => { @@ -141,7 +141,6 @@ const Workflow: FunctionComponent = (props: ComponentProps) => { } }, [props.showComponentsPickerModal]); - useEffect(() => { if (props.showRunModal) { setShowRunModal(true); @@ -267,8 +266,7 @@ const Workflow: FunctionComponent = (props: ComponentProps) => { const [showComponentsModal, setShowComponentsModal] = useState(false); - const [showRunModal, setShowRunModal] = - useState(false); + const [showRunModal, setShowRunModal] = useState(false); const [showComponentType, setShowComponentsType] = useState( ComponentType.Component @@ -390,7 +388,7 @@ const Workflow: FunctionComponent = (props: ComponentProps) => { }} description={ selectedNodeData && - selectedNodeData.metadata.description + selectedNodeData.metadata.description ? selectedNodeData.metadata.description : 'Edit Component Properties and variables here.' } @@ -418,20 +416,26 @@ const Workflow: FunctionComponent = (props: ComponentProps) => { /> )} - {showRunModal && ( i.data.metadata.componentType === ComponentType.Trigger) || getPlaceholderTriggerNode()).data} + trigger={ + ( + nodes.find((i: Node) => { + return ( + i.data.metadata.componentType === + ComponentType.Trigger + ); + }) || getPlaceholderTriggerNode() + ).data + } onClose={() => { setShowRunModal(false); }} onRun={(trigger: NodeDataProp) => { - props.onRun(trigger) + props.onRun(trigger); }} /> )} - - ); }; diff --git a/CommonUI/src/Components/Workflow/WorkflowStatus.tsx b/CommonUI/src/Components/Workflow/WorkflowStatus.tsx index 1309189a44..c3d0e7d666 100644 --- a/CommonUI/src/Components/Workflow/WorkflowStatus.tsx +++ b/CommonUI/src/Components/Workflow/WorkflowStatus.tsx @@ -1,7 +1,7 @@ import { Green, Red, Yellow } from 'Common/Types/BrandColors'; import React, { FunctionComponent, ReactElement } from 'react'; -import WorkflowStatus from "Common/Types/Workflow/WorkflowStatus" -import Pill from "../Pill/Pill"; +import WorkflowStatus from 'Common/Types/Workflow/WorkflowStatus'; +import Pill from '../Pill/Pill'; export interface ComponentProps { status: WorkflowStatus; @@ -10,35 +10,20 @@ export interface ComponentProps { const WorkflowStatusElement: FunctionComponent = ( props: ComponentProps ): ReactElement => { - if (props.status === WorkflowStatus.Success) { - - return ( - - ); + return ; } if (props.status === WorkflowStatus.Running) { - - return ( - - ); + return ; } if (props.status === WorkflowStatus.Scheduled) { - - return ( - - ); + return ; } if (props.status === WorkflowStatus.Error) { - - return ( - - ); + return ; } - return ( - - ); + return ; }; export default WorkflowStatusElement; diff --git a/Dashboard/src/Pages/Workflow/Logs.tsx b/Dashboard/src/Pages/Workflow/Logs.tsx index ec442a2c58..4798af1167 100644 --- a/Dashboard/src/Pages/Workflow/Logs.tsx +++ b/Dashboard/src/Pages/Workflow/Logs.tsx @@ -18,7 +18,7 @@ import { ButtonStyleType } from 'CommonUI/src/Components/Button/Button'; import Modal, { ModalWidth } from 'CommonUI/src/Components/Modal/Modal'; import BadDataException from 'Common/Types/Exception/BadDataException'; import WorkflowStatus from 'Common/Types/Workflow/WorkflowStatus'; -import WorkflowStatusElement from "CommonUI/src/Components/Workflow/WorkflowStatus"; +import WorkflowStatusElement from 'CommonUI/src/Components/Workflow/WorkflowStatus'; const Workflows: FunctionComponent = ( _props: PageComponentProps @@ -118,10 +118,10 @@ const Workflows: FunctionComponent = ( }, { field: { - workflowStatus: true + workflowStatus: true, }, isFilterable: true, - + title: 'Workflow Status', type: FieldType.Text, getElement: (item: JSONObject): ReactElement => { @@ -130,10 +130,14 @@ const Workflows: FunctionComponent = ( 'Workflow Status not found' ); } - + return ( ); }, diff --git a/Dashboard/src/Pages/Workflow/View/Builder.tsx b/Dashboard/src/Pages/Workflow/View/Builder.tsx index 8db44ef65f..cc505c97c0 100644 --- a/Dashboard/src/Pages/Workflow/View/Builder.tsx +++ b/Dashboard/src/Pages/Workflow/View/Builder.tsx @@ -31,7 +31,10 @@ import ComponentMetadata, { ComponentCategory, } from 'Common/Types/Workflow/Component'; import BadDataException from 'Common/Types/Exception/BadDataException'; -import { NodeDataProp, NodeType } from 'CommonUI/src/Components/Workflow/Component'; +import { + NodeDataProp, + NodeType, +} from 'CommonUI/src/Components/Workflow/Component'; const Delete: FunctionComponent = ( _props: PageComponentProps @@ -49,8 +52,7 @@ const Delete: FunctionComponent = ( const [showComponentPickerModal, setShowComponentPickerModal] = useState(false); - const [showRunModal, setShowRunModal] = - useState(false); + const [showRunModal, setShowRunModal] = useState(false); const loadGraph: Function = async (): Promise => { try { @@ -103,18 +105,18 @@ const Delete: FunctionComponent = ( const componentMetdata: | ComponentMetadata | undefined = allComponents.components.find( - (component: ComponentMetadata) => { - return ( - component.id === - nodes[i]?.data.metadataId - ); - } - ); + (component: ComponentMetadata) => { + return ( + component.id === + nodes[i]?.data.metadataId + ); + } + ); if (!componentMetdata) { throw new BadDataException( 'Component Metadata not found for node ' + - nodes[i]?.data.metadataId + nodes[i]?.data.metadataId ); } @@ -157,7 +159,7 @@ const Delete: FunctionComponent = ( try { setError( (err as HTTPErrorResponse).message || - 'Server Error. Please try again' + 'Server Error. Please try again' ); } catch (e) { setError('Server Error. Please try again'); @@ -230,7 +232,7 @@ const Delete: FunctionComponent = ( try { setError( (err as HTTPErrorResponse).message || - 'Server Error. Please try again' + 'Server Error. Please try again' ); } catch (e) { setError('Server Error. Please try again'); @@ -339,9 +341,7 @@ const Delete: FunctionComponent = ( setEdges(edges); await saveGraph(nodes, edges); }} - onRun={(component: NodeDataProp)=> { - console.log(component); - }} + onRun={(_component: NodeDataProp) => {}} /> ) : ( <> diff --git a/Dashboard/src/Pages/Workflow/View/Logs.tsx b/Dashboard/src/Pages/Workflow/View/Logs.tsx index 8dfe9d06bf..fe901a571a 100644 --- a/Dashboard/src/Pages/Workflow/View/Logs.tsx +++ b/Dashboard/src/Pages/Workflow/View/Logs.tsx @@ -20,7 +20,7 @@ import { ButtonStyleType } from 'CommonUI/src/Components/Button/Button'; import Modal, { ModalWidth } from 'CommonUI/src/Components/Modal/Modal'; import BadDataException from 'Common/Types/Exception/BadDataException'; import WorkflowStatus from 'Common/Types/Workflow/WorkflowStatus'; -import WorkflowStatusElement from "CommonUI/src/Components/Workflow/WorkflowStatus"; +import WorkflowStatusElement from 'CommonUI/src/Components/Workflow/WorkflowStatus'; const Delete: FunctionComponent = ( _props: PageComponentProps @@ -137,10 +137,10 @@ const Delete: FunctionComponent = ( }, { field: { - workflowStatus: true + workflowStatus: true, }, isFilterable: true, - + title: 'Workflow Status', type: FieldType.Text, getElement: (item: JSONObject): ReactElement => { @@ -149,10 +149,14 @@ const Delete: FunctionComponent = ( 'Workflow Status not found' ); } - + return ( ); }, diff --git a/Model/Models/WorkflowLog.ts b/Model/Models/WorkflowLog.ts index 82e6544473..35e44437b9 100644 --- a/Model/Models/WorkflowLog.ts +++ b/Model/Models/WorkflowLog.ts @@ -14,7 +14,7 @@ import TableMetadata from 'Common/Types/Database/TableMetadata'; import IconProp from 'Common/Types/Icon/IconProp'; import BaseModel from 'Common/Models/BaseModel'; import Workflow from './Workflow'; -import WorkflowStatus from "Common/Types/Workflow/WorkflowStatus" +import WorkflowStatus from 'Common/Types/Workflow/WorkflowStatus'; @TenantColumn('projectId') @TableAccessControl({ @@ -52,9 +52,7 @@ import WorkflowStatus from "Common/Types/Workflow/WorkflowStatus" }) export default class WorkflowLog extends BaseModel { @ColumnAccessControl({ - create: [ - - ], + create: [], read: [ Permission.ProjectOwner, Permission.ProjectAdmin, @@ -83,9 +81,7 @@ export default class WorkflowLog extends BaseModel { public project?: Project = undefined; @ColumnAccessControl({ - create: [ - - ], + create: [], read: [ Permission.ProjectOwner, Permission.ProjectAdmin, @@ -108,9 +104,7 @@ export default class WorkflowLog extends BaseModel { public projectId?: ObjectID = undefined; @ColumnAccessControl({ - create: [ - - ], + create: [], read: [ Permission.ProjectOwner, Permission.ProjectAdmin, @@ -139,9 +133,7 @@ export default class WorkflowLog extends BaseModel { public workflow?: Workflow = undefined; @ColumnAccessControl({ - create: [ - - ], + create: [], read: [ Permission.ProjectOwner, Permission.ProjectAdmin, @@ -164,9 +156,7 @@ export default class WorkflowLog extends BaseModel { public workflowId?: ObjectID = undefined; @ColumnAccessControl({ - create: [ - - ], + create: [], read: [ Permission.ProjectOwner, Permission.ProjectAdmin, @@ -183,9 +173,7 @@ export default class WorkflowLog extends BaseModel { public logs?: string = undefined; @ColumnAccessControl({ - create: [ - - ], + create: [], read: [ Permission.ProjectOwner, Permission.ProjectAdmin,