Skip to content

Commit 920eed3

Browse files
committed
v4.1.0
added ability for custom Icons to use node path and node name. Previously we only know the icon type that is clicked, added path and name prop to custom Icon enable more custom functionalities, such as doing somthing when clicked that node.
1 parent ef8fe84 commit 920eed3

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/components/EditableName/EditableName.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const EditableName = ({
1313
onNameChange,
1414
OKIcon,
1515
CancelIcon,
16+
path,
1617
}) => {
1718
const [inputVal, setInputVal] = useState(name);
1819

@@ -39,10 +40,14 @@ const EditableName = ({
3940
<OKIcon
4041
className={ iconClassName('OKIcon') }
4142
onClick={ handleNameChange }
43+
path={ path }
44+
name={ name }
4245
/>
4346
<CancelIcon
4447
className={ iconClassName('CancelIcon') }
4548
onClick={ cancelEditing }
49+
path={ path }
50+
name={ name }
4651
/>
4752
</span>
4853
</span>
@@ -68,6 +73,7 @@ EditableName.propTypes = {
6873
onNameChange: PropTypes.func.isRequired,
6974
OKIcon: PropTypes.func.isRequired,
7075
CancelIcon: PropTypes.func.isRequired,
76+
path: PropTypes.array.isRequired,
7177
};
7278

7379
export default EditableName;

src/components/TreeNode/TreeNode.jsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ const TreeNode = ({
6666
} = iconComponents;
6767

6868
let TypeIcon = FileIcon;
69+
let TypeIconType = 'FileIcon';
6970
if (isFolder) {
7071
TypeIcon = isOpen
7172
? FolderOpenIcon
7273
: FolderIcon;
74+
75+
TypeIconType = isOpen
76+
? 'FolderOpenIcon'
77+
: 'FolderIcon';
7378
}
7479

7580
const handleCheckBoxChange = e => {
@@ -100,21 +105,29 @@ const TreeNode = ({
100105
<EditIcon
101106
className={ iconClassName('EditIcon') }
102107
onClick={ editMe }
108+
path={ path }
109+
name={ name }
103110
/>
104111
<DeleteIcon
105112
className={ iconClassName('DeleteIcon') }
106113
onClick={ deleteMe }
114+
path={ path }
115+
name={ name }
107116
/>
108117
{
109118
isFolder && (
110119
<>
111120
<AddFileIcon
112121
className={ iconClassName('AddFileIcon') }
113122
onClick={ addFile }
123+
path={ path }
124+
name={ name }
114125
/>
115126
<AddFolderIcon
116127
className={ iconClassName('AddFolderIcon') }
117128
onClick={ addFolder }
129+
path={ path }
130+
name={ name }
118131
/>
119132
</>
120133
)
@@ -123,6 +136,8 @@ const TreeNode = ({
123136
<CancelIcon
124137
className={ iconClassName('CancelIcon') }
125138
onClick={ unSelectMe }
139+
path={ path }
140+
name={ name }
126141
/>
127142
</span>
128143
);
@@ -137,12 +152,16 @@ const TreeNode = ({
137152
<CaretDownIcon
138153
className={ iconClassName('CaretDownIcon') }
139154
onClick={ closeMe }
155+
path={ path }
156+
name={ name }
140157
/>
141158
)
142159
: (
143160
<CaretRightIcon
144161
className={ iconClassName('CaretRightIcon') }
145162
onClick={ openMe }
163+
path={ path }
164+
name={ name }
146165
/>
147166
)
148167
}
@@ -161,8 +180,10 @@ const TreeNode = ({
161180

162181
<span className={ iconContainerClassName('typeIconContainer') }>
163182
<TypeIcon
164-
className={ iconClassName('TypeIcon') }
183+
className={ iconClassName(TypeIconType) }
165184
onClick={ selectMe }
185+
path={ path }
186+
name={ name }
166187
/>
167188
</span>
168189

@@ -177,6 +198,7 @@ const TreeNode = ({
177198
onNameChange={ onNameChange }
178199
OKIcon={ OKIcon }
179200
CancelIcon={ CancelIcon }
201+
path={ path }
180202
/>
181203
</span>
182204
{ isSelected && TreeNodeToolBar }

0 commit comments

Comments
 (0)