fix lint.

This commit is contained in:
Simon Larsen
2023-02-14 21:37:15 +00:00
parent 53338d15ce
commit 641db23180
12 changed files with 117 additions and 134 deletions

View File

@@ -12,18 +12,18 @@ const components: Array<ComponentMetadata> = [
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: [
{

View File

@@ -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;

View File

@@ -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<ComponentProps> = (

View File

@@ -201,7 +201,8 @@ const ComponentsModal: FunctionComponent<ComponentProps> = (
'',
nodeType:
NodeType.Node,
returnValues: {},
returnValues:
{},
isPreview:
true,
id: '',

View File

@@ -30,7 +30,6 @@ const RunForm: FunctionComponent<ComponentProps> = (
Dictionary<boolean>
>({});
useEffect(() => {
props.onHasFormValidatonErrors(hasFormValidationErrors);
}, [hasFormValidationErrors]);
@@ -46,7 +45,9 @@ const RunForm: FunctionComponent<ComponentProps> = (
Return Values from Trigger
</h2>
<p className="text-sm font-medium text-gray-400 mb-5">
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.
</p>
{component.metadata.returnValues &&
component.metadata.returnValues.length === 0 && (
@@ -88,7 +89,7 @@ const RunForm: FunctionComponent<ComponentProps> = (
(returnValue: ReturnValue) => {
return {
title: `${returnValue.name}`,
description: `${
returnValue.required
? 'Required'
@@ -98,11 +99,14 @@ const RunForm: FunctionComponent<ComponentProps> = (
[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<ComponentProps> = (
/>
)}
</div>
</div>
);
};

View File

@@ -29,25 +29,23 @@ const RunModal: FunctionComponent<ComponentProps> = (
const [showFormValidationErrors, setShowFormValidationErrors] =
useState<boolean>(false);
return (
<SideOver
title={"Run Workflow"}
description={"You can run this workflow manually. This can be helpful to test the workflow."}
title={'Run Workflow'}
description={
'You can run this workflow manually. This can be helpful to test the workflow.'
}
onClose={props.onClose}
submitButtonDisabled={component.nodeType === NodeType.PlaceholderNode}
submitButtonDisabled={
component.nodeType === NodeType.PlaceholderNode
}
submitButtonText={'Run Workflow'}
onSubmit={() => {
if (Object.keys(hasFormValidationErrors).length > 0) {
setShowFormValidationErrors(true)
setShowFormValidationErrors(true);
} else {
setShowRunConfirmation(true);
}
}}
>
<>
@@ -68,12 +66,10 @@ const RunModal: FunctionComponent<ComponentProps> = (
/>
)}
{showRunSuccessConfirmation && (
<ConfirmModal
title={`Workflow Started...`}
description={`This workflow is scheduled to execute soon. You can see the status of the run in the Runs and Logs section.`}
submitButtonText={'Close'}
onSubmit={() => {
setShowRunSuccessConfirmation(false);
@@ -83,7 +79,6 @@ const RunModal: FunctionComponent<ComponentProps> = (
/>
)}
{showFormValidationErrors && (
<ConfirmModal
title={`Please fix errors`}
@@ -96,27 +91,26 @@ const RunModal: FunctionComponent<ComponentProps> = (
/>
)}
{component.nodeType === NodeType.Node && (
<RunForm
component={component}
onFormChange={(component: NodeDataProp) => {
setComponent({ ...component });
}}
onHasFormValidatonErrors={(
value: Dictionary<boolean>
) => {
setHasFormValidatonErrors({
...hasFormValidationErrors,
...value,
});
}}
/>
)}
{component.nodeType === NodeType.Node && <RunForm
component={component}
onFormChange={(component: NodeDataProp) => {
setComponent({ ...component });
}}
onHasFormValidatonErrors={(value: Dictionary<boolean>) => {
setHasFormValidatonErrors({
...hasFormValidationErrors,
...value,
});
}}
/>}
{component.nodeType === NodeType.PlaceholderNode && <ErrorMessage error='No trigger added. Please add a trigger in order to run this workflow' />}
{component.nodeType === NodeType.PlaceholderNode && (
<ErrorMessage error="No trigger added. Please add a trigger in order to run this workflow" />
)}
</>
</SideOver>
);

View File

@@ -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<ComponentProps> = (props: ComponentProps) => {
@@ -141,7 +141,6 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
}
}, [props.showComponentsPickerModal]);
useEffect(() => {
if (props.showRunModal) {
setShowRunModal(true);
@@ -267,8 +266,7 @@ const Workflow: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
const [showComponentsModal, setShowComponentsModal] =
useState<boolean>(false);
const [showRunModal, setShowRunModal] =
useState<boolean>(false);
const [showRunModal, setShowRunModal] = useState<boolean>(false);
const [showComponentType, setShowComponentsType] = useState<ComponentType>(
ComponentType.Component
@@ -390,7 +388,7 @@ const Workflow: FunctionComponent<ComponentProps> = (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<ComponentProps> = (props: ComponentProps) => {
/>
)}
{showRunModal && (
<RunModal
trigger={(nodes.find((i)=>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);
}}
/>
)}
</div>
);
};

View File

@@ -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<ComponentProps> = (
props: ComponentProps
): ReactElement => {
if (props.status === WorkflowStatus.Success) {
return (
<Pill color={Green} text="Success" />
);
return <Pill color={Green} text="Success" />;
}
if (props.status === WorkflowStatus.Running) {
return (
<Pill color={Yellow} text="Running" />
);
return <Pill color={Yellow} text="Running" />;
}
if (props.status === WorkflowStatus.Scheduled) {
return (
<Pill color={Yellow} text="Scheduled" />
);
return <Pill color={Yellow} text="Scheduled" />;
}
if (props.status === WorkflowStatus.Error) {
return (
<Pill color={Red} text="Error" />
);
return <Pill color={Red} text="Error" />;
}
return (
<Pill color={Yellow} text="Unknown" />
);
return <Pill color={Yellow} text="Unknown" />;
};
export default WorkflowStatusElement;

View File

@@ -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<PageComponentProps> = (
_props: PageComponentProps
@@ -118,10 +118,10 @@ const Workflows: FunctionComponent<PageComponentProps> = (
},
{
field: {
workflowStatus: true
workflowStatus: true,
},
isFilterable: true,
title: 'Workflow Status',
type: FieldType.Text,
getElement: (item: JSONObject): ReactElement => {
@@ -130,10 +130,14 @@ const Workflows: FunctionComponent<PageComponentProps> = (
'Workflow Status not found'
);
}
return (
<WorkflowStatusElement
status={item['workflowStatus'] as WorkflowStatus}
status={
item[
'workflowStatus'
] as WorkflowStatus
}
/>
);
},

View File

@@ -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<PageComponentProps> = (
_props: PageComponentProps
@@ -49,8 +52,7 @@ const Delete: FunctionComponent<PageComponentProps> = (
const [showComponentPickerModal, setShowComponentPickerModal] =
useState<boolean>(false);
const [showRunModal, setShowRunModal] =
useState<boolean>(false);
const [showRunModal, setShowRunModal] = useState<boolean>(false);
const loadGraph: Function = async (): Promise<void> => {
try {
@@ -103,18 +105,18 @@ const Delete: FunctionComponent<PageComponentProps> = (
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<PageComponentProps> = (
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<PageComponentProps> = (
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<PageComponentProps> = (
setEdges(edges);
await saveGraph(nodes, edges);
}}
onRun={(component: NodeDataProp)=> {
console.log(component);
}}
onRun={(_component: NodeDataProp) => {}}
/>
) : (
<></>

View File

@@ -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<PageComponentProps> = (
_props: PageComponentProps
@@ -137,10 +137,10 @@ const Delete: FunctionComponent<PageComponentProps> = (
},
{
field: {
workflowStatus: true
workflowStatus: true,
},
isFilterable: true,
title: 'Workflow Status',
type: FieldType.Text,
getElement: (item: JSONObject): ReactElement => {
@@ -149,10 +149,14 @@ const Delete: FunctionComponent<PageComponentProps> = (
'Workflow Status not found'
);
}
return (
<WorkflowStatusElement
status={item['workflowStatus'] as WorkflowStatus}
status={
item[
'workflowStatus'
] as WorkflowStatus
}
/>
);
},

View File

@@ -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,