Skip to content

Commit

Permalink
feat: work on the node component
Browse files Browse the repository at this point in the history
  • Loading branch information
yamankatby committed May 3, 2023
1 parent 2ffffdb commit 2921c17
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/Workflow/HttpTriggerNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function HttpTriggerNode() {
htmlFor="method"
paramKey="method"
paramConfig={{
type: "string",
type: "select",
label: "Method",
description: "The HTTP method to listen for",
options: [
Expand Down
24 changes: 13 additions & 11 deletions src/components/Workflow/NodeParam/NodeParam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface NodeParamProps {

paramKey: string;

paramConfig: ParamConfig;
paramConfig?: ParamConfig;

value: any;

Expand All @@ -22,7 +22,7 @@ const NodeParam: FC<NodeParamProps> = ({
value,
onChange,
}) => {
if (paramConfig.type === "object" || paramConfig.type === "array")
if (paramConfig?.type === "object" || paramConfig?.type === "array")
return (
<NodeParamField
htmlFor={htmlFor}
Expand All @@ -34,7 +34,7 @@ const NodeParam: FC<NodeParamProps> = ({
);
return (
<Stack direction="row">
<Tooltip title={paramConfig.description}>
<Tooltip title={paramConfig?.description}>
<Typography
component="label"
htmlFor={htmlFor}
Expand All @@ -44,16 +44,18 @@ const NodeParam: FC<NodeParamProps> = ({
textOverflow="ellipsis"
sx={{ whiteSpace: "nowrap" }}
>
{paramConfig.label ?? paramKey}
{paramConfig?.label ?? paramKey}
</Typography>
</Tooltip>
<NodeParamField
htmlFor={htmlFor}
paramKey={paramKey}
paramConfig={paramConfig}
value={value}
onChange={onChange}
/>
{paramConfig && (
<NodeParamField
htmlFor={htmlFor}
paramKey={paramKey}
paramConfig={paramConfig}
value={value}
onChange={onChange}
/>
)}
</Stack>
);
};
Expand Down
3 changes: 3 additions & 0 deletions src/components/Workflow/NodeParam/NodeSelectParam.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { FormControl, InputBase, MenuItem, Select } from "@mui/material";
import { ParamConfig } from "@src/components/Workflow/types";
import { NodeParamProps } from "./NodeParam";

interface NodeSelectParamProps extends NodeParamProps {
paramConfig: ParamConfig;

value: string;

onChange: (value: string) => void;
Expand Down
6 changes: 3 additions & 3 deletions src/components/Workflow/ScriptNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ const ScriptNode: FC<IScriptNodeProps> = () => {

const { params, result, meta } = eval(scriptWithExports);

setParams(params);
setParams(params ?? {});
setMeta(meta ?? {});
setResult(result);
setResult(result ?? {});
} catch {}
}, [script]);

Expand Down Expand Up @@ -133,7 +133,7 @@ const ScriptNode: FC<IScriptNodeProps> = () => {
open={isEditing}
onClose={() => setIsEditing(false)}
>
<Stack width={440} p={2}>
<Stack width={480} p={2}>
<Stack
p={4}
alignItems="center"
Expand Down
8 changes: 5 additions & 3 deletions src/pages/Workflow/WorkflowPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ export default function WorkflowPage() {

return (
<Stack alignItems="center">
<Button startIcon={<PlusIcon />} {...bindToggle(addTriggerPopupState)}>
Add trigger
</Button>
{false && (
<Button startIcon={<PlusIcon />} {...bindToggle(addTriggerPopupState)}>
Add trigger
</Button>
)}
<Menu
{...bindPopover(addTriggerPopupState)}
anchorOrigin={{ horizontal: "center", vertical: "bottom" }}
Expand Down

0 comments on commit 2921c17

Please sign in to comment.