forked from DhanushNehru/ToolJet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigHandle.jsx
More file actions
74 lines (72 loc) · 2.28 KB
/
Copy pathConfigHandle.jsx
File metadata and controls
74 lines (72 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { useEditorStore } from '@/_stores/editorStore';
import React from 'react';
export const ConfigHandle = function ConfigHandle({
id,
component,
dragRef,
removeComponent,
position,
widgetTop,
widgetHeight,
isMultipleComponentsSelected = false,
setSelectedComponent = () => null, //! Only Modal widget passes this uses props down. All other widgets use selecto lib
customClassName = '',
configWidgetHandlerForModalComponent = false,
isVersionReleased,
showHandle,
}) {
const shouldShowHandle = useEditorStore((state) => state.hoveredComponent === id) || showHandle;
return (
<div
className={`config-handle ${customClassName}`}
ref={dragRef}
style={{
top: position === 'top' ? '-20px' : widgetTop + widgetHeight - (widgetTop < 10 ? 15 : 10),
visibility: shouldShowHandle && !isMultipleComponentsSelected ? 'visible' : 'hidden',
left: '-1px',
}}
>
<span
style={{
background: configWidgetHandlerForModalComponent && '#c6cad0',
}}
className="badge handle-content"
>
<div
style={{ display: 'flex', alignItems: 'center' }}
onClick={(e) => {
e.preventDefault();
setSelectedComponent(id, component, e.shiftKey);
}}
role="button"
data-cy={`${component.name.toLowerCase()}-config-handle`}
className="text-truncate"
>
<img
style={{ cursor: 'pointer', marginRight: '5px', verticalAlign: 'middle' }}
src="assets/images/icons/settings.svg"
width="12"
height="12"
draggable="false"
/>
<span>{component.name}</span>
</div>
{!isMultipleComponentsSelected && !isVersionReleased && (
<div className="delete-part">
<img
style={{ cursor: 'pointer', marginLeft: '5px' }}
src="assets/images/icons/trash-light.svg"
width="12"
role="button"
height="12"
draggable="false"
onClick={() => removeComponent(id)}
data-cy={`${component.name.toLowerCase()}-delete-button`}
className="delete-icon"
/>
</div>
)}
</span>
</div>
);
};