Skip to content

Commit c285560

Browse files
committed
removed es-lint lines and bug fixes
1 parent bed8b86 commit c285560

File tree

1 file changed

+23
-44
lines changed

1 file changed

+23
-44
lines changed

client/modules/IDE/components/CollectionList/CollectionListRow.jsx

Lines changed: 23 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,31 @@ const CollectionListRowBase = (props) => {
2121
const renameInputRef = useRef(null);
2222

2323
const projectInCollection = (project, collection) =>
24-
collection.items.find((item) => item.project.id === project.id) != null;
24+
collection.items.find((item) => item.project.id === project.id) !==
25+
undefined;
2526

2627
const onFocusComponent = () => {
2728
setIsFocused(true);
2829
};
2930

31+
const closeAll = () => {
32+
setOptionsOpen(false);
33+
setRenameOpen(false);
34+
};
35+
36+
const updateName = () => {
37+
const isValid = renameValue.trim().length !== 0;
38+
if (isValid) {
39+
props.editCollection(props.collection.id, {
40+
name: renameValue.trim()
41+
});
42+
}
43+
};
44+
3045
const onBlurComponent = () => {
3146
setIsFocused(false);
3247
setTimeout(() => {
3348
if (!isFocused) {
34-
// eslint-disable-next-line no-use-before-define
3549
closeAll();
3650
}
3751
}, 200);
@@ -53,21 +67,11 @@ const CollectionListRowBase = (props) => {
5367
}
5468
};
5569

56-
const closeAll = () => {
57-
setOptionsOpen(false);
58-
setRenameOpen(false);
59-
};
60-
6170
const handleAddSketches = () => {
6271
closeAll();
6372
props.onAddSketches();
6473
};
6574

66-
const handleDropdownOpen = () => {
67-
closeAll();
68-
openOptions();
69-
};
70-
7175
const handleCollectionDelete = () => {
7276
closeAll();
7377
if (
@@ -91,31 +95,18 @@ const CollectionListRowBase = (props) => {
9195

9296
const handleRenameEnter = (e) => {
9397
if (e.key === 'Enter') {
94-
// eslint-disable-next-line no-use-before-define
9598
updateName();
9699
closeAll();
97100
}
98101
};
99102

100103
const handleRenameBlur = () => {
101-
// eslint-disable-next-line no-use-before-define
102104
updateName();
103105
closeAll();
104106
};
105107

106-
const updateName = () => {
107-
const isValid = renameValue.trim().length !== 0;
108-
if (isValid) {
109-
props.editCollection(props.collection.id, {
110-
name: renameValue.trim()
111-
});
112-
}
113-
};
114-
115108
const renderActions = () => {
116-
const { mobile, user, username } = props;
117-
// eslint-disable-next-line no-shadow, no-use-before-define
118-
const { optionsOpen } = optionsOpen;
109+
const { user, username } = props;
119110
const userIsOwner = user.username === username;
120111

121112
return (
@@ -127,11 +118,7 @@ const CollectionListRowBase = (props) => {
127118
onFocus={onFocusComponent}
128119
aria-label={props.t('CollectionListRow.ToggleCollectionOptionsARIA')}
129120
>
130-
{mobile ? (
131-
<MoreIconSvg focusable="false" aria-hidden="true" />
132-
) : (
133-
<DownFilledTriangleIcon focusable="false" aria-hidden="true" />
134-
)}
121+
<MoreIconSvg focusable="false" aria-hidden="true" />
135122
</button>
136123
{optionsOpen && (
137124
<ul className="sketch-list__action-dialogue">
@@ -177,8 +164,6 @@ const CollectionListRowBase = (props) => {
177164

178165
const renderCollectionName = () => {
179166
const { collection, username } = props;
180-
// eslint-disable-next-line no-shadow, no-use-before-define
181-
const { renameOpen } = renameOpen;
182167

183168
return (
184169
<React.Fragment>
@@ -204,19 +189,16 @@ const CollectionListRowBase = (props) => {
204189
);
205190
};
206191

207-
const { collection, mobile } = props;
192+
const { collection } = props;
208193

209194
return (
210195
<tr className="sketches-table__row" key={collection.id}>
211196
<th scope="row">
212197
<span className="sketches-table__name">{renderCollectionName()}</span>
213198
</th>
214-
<td>{formatDate(collection.createdAt, mobile)}</td>
215-
<td>{formatDate(collection.updatedAt, mobile)}</td>
216-
<td>
217-
{mobile && 'sketches: '}
218-
{(collection.items || []).length}
219-
</td>
199+
<td>{formatDate(collection.createdAt)}</td>
200+
<td>{formatDate(collection.updatedAt)}</td>
201+
<td>{(collection.items || []).length}</td>
220202
<td className="sketch-list__dropdown-column">{renderActions()}</td>
221203
</tr>
222204
);
@@ -239,11 +221,8 @@ CollectionListRowBase.propTypes = {
239221
})
240222
)
241223
}).isRequired,
242-
// eslint-disable-next-line react/require-default-props
243-
mobile: PropTypes.bool,
244224
user: PropTypes.shape({
245-
username: PropTypes.string,
246-
authenticated: PropTypes.bool.isRequired
225+
username: PropTypes.string
247226
}).isRequired,
248227
deleteCollection: PropTypes.func.isRequired,
249228
editCollection: PropTypes.func.isRequired,

0 commit comments

Comments
 (0)