Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit caf60b2

Browse files
committed
cleanup
1 parent 9d212c8 commit caf60b2

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/components/Visualization.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ const Visualization = ({ toggleCatalog }: IVisualization) => {
110110

111111
// if there are no steps, or if the first step isn't a source,
112112
// create a dummy placeholder step
113-
// if (steps.length === 0 || (steps.length > 0 && steps[0].type !== 'START')) {
114-
// steps[0] = { name: 'ADD A STEP' };
115-
// }
116-
if (!steps.length || (steps.length > 0 && steps[0].type !== 'START')) {
113+
if (steps.length === 0 || (steps.length > 0 && steps[0].type !== 'START')) {
117114
// @ts-ignore
118115
steps.unshift({ name: 'ADD A STEP' });
119116
}
@@ -170,6 +167,7 @@ const Visualization = ({ toggleCatalog }: IVisualization) => {
170167
UUID: step.UUID,
171168
onDropChange,
172169
onElementClick,
170+
onElementClickAdd,
173171
},
174172
id: getId(),
175173
position: { x: 0, y: window.innerHeight / 2 },
@@ -182,7 +180,7 @@ const Visualization = ({ toggleCatalog }: IVisualization) => {
182180
stepEdge.id = 'e' + previousStep.id + '-' + inputStep.id;
183181
stepEdge.source = previousStep.id;
184182

185-
// even the last step needs to build the step edge above it, with itself as the target
183+
// even the last step needs to build the step edge before it, with itself as the target
186184
stepEdge.target = inputStep.id;
187185
}
188186

@@ -280,6 +278,11 @@ const Visualization = ({ toggleCatalog }: IVisualization) => {
280278
setIsPanelExpanded(!isPanelExpanded);
281279
};
282280

281+
const onElementClickAdd = (_e: any, element: any) => {
282+
console.log('clicked!', element);
283+
// add mini catalog
284+
};
285+
283286
const onElementsRemove = (elementsToRemove: Elements<IVizStepProps[]>) =>
284287
setElements((els) => removeElements(elementsToRemove, els));
285288

src/components/VisualizationStep.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,31 @@ const VisualizationStep = ({ data }: any) => {
1616

1717
const onDropChange = (event: any) => data.onDropChange(event, data);
1818
const onElementClick = (event: any) => data.onElementClick(event, data);
19+
const onElementClickAdd = (event: any) => data.onElementClickAdd(event, data);
1920

2021
return (
2122
<div
2223
className={'stepNode'}
2324
style={{ border: '2px solid ' + borderColor, borderRadius: '50%' }}
24-
onClick={onElementClick}
2525
onDrop={onDropChange}
2626
>
2727
{data.connectorType !== 'END' && !isLastNode && (
2828
<Handle type="source" position={Position.Right} id="b" style={{ borderRadius: 0 }} />
2929
)}
3030
{data.connectorType !== 'END' && isLastNode && (
31-
<div
32-
className={'stepNode__Add'}
33-
onClick={() => {
34-
console.log('clicked!');
35-
}}
36-
>
31+
<div className={'stepNode__Add'} onClick={onElementClickAdd}>
3732
<PlusCircleIcon />
3833
</div>
3934
)}
40-
<div className={'stepNode__Icon'}>
35+
<div className={'stepNode__Icon'} onClick={onElementClick}>
4136
<img src={data.icon} className="nodrag" alt={data.label} />
4237
</div>
4338
{data.connectorType !== 'START' && (
4439
<Handle type="target" position={Position.Left} id="a" style={{ borderRadius: 0 }} />
4540
)}
46-
<div className={'stepNode__Label'}>{data.label}</div>
41+
<div className={'stepNode__Label'} onClick={onElementClick}>
42+
{data.label}
43+
</div>
4744
</div>
4845
);
4946
};

0 commit comments

Comments
 (0)