@@ -21,17 +21,31 @@ const CollectionListRowBase = (props) => {
21
21
const renameInputRef = useRef ( null ) ;
22
22
23
23
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 ;
25
26
26
27
const onFocusComponent = ( ) => {
27
28
setIsFocused ( true ) ;
28
29
} ;
29
30
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
+
30
45
const onBlurComponent = ( ) => {
31
46
setIsFocused ( false ) ;
32
47
setTimeout ( ( ) => {
33
48
if ( ! isFocused ) {
34
- // eslint-disable-next-line no-use-before-define
35
49
closeAll ( ) ;
36
50
}
37
51
} , 200 ) ;
@@ -53,21 +67,11 @@ const CollectionListRowBase = (props) => {
53
67
}
54
68
} ;
55
69
56
- const closeAll = ( ) => {
57
- setOptionsOpen ( false ) ;
58
- setRenameOpen ( false ) ;
59
- } ;
60
-
61
70
const handleAddSketches = ( ) => {
62
71
closeAll ( ) ;
63
72
props . onAddSketches ( ) ;
64
73
} ;
65
74
66
- const handleDropdownOpen = ( ) => {
67
- closeAll ( ) ;
68
- openOptions ( ) ;
69
- } ;
70
-
71
75
const handleCollectionDelete = ( ) => {
72
76
closeAll ( ) ;
73
77
if (
@@ -91,31 +95,18 @@ const CollectionListRowBase = (props) => {
91
95
92
96
const handleRenameEnter = ( e ) => {
93
97
if ( e . key === 'Enter' ) {
94
- // eslint-disable-next-line no-use-before-define
95
98
updateName ( ) ;
96
99
closeAll ( ) ;
97
100
}
98
101
} ;
99
102
100
103
const handleRenameBlur = ( ) => {
101
- // eslint-disable-next-line no-use-before-define
102
104
updateName ( ) ;
103
105
closeAll ( ) ;
104
106
} ;
105
107
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
-
115
108
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 ;
119
110
const userIsOwner = user . username === username ;
120
111
121
112
return (
@@ -127,11 +118,7 @@ const CollectionListRowBase = (props) => {
127
118
onFocus = { onFocusComponent }
128
119
aria-label = { props . t ( 'CollectionListRow.ToggleCollectionOptionsARIA' ) }
129
120
>
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" />
135
122
</ button >
136
123
{ optionsOpen && (
137
124
< ul className = "sketch-list__action-dialogue" >
@@ -177,8 +164,6 @@ const CollectionListRowBase = (props) => {
177
164
178
165
const renderCollectionName = ( ) => {
179
166
const { collection, username } = props ;
180
- // eslint-disable-next-line no-shadow, no-use-before-define
181
- const { renameOpen } = renameOpen ;
182
167
183
168
return (
184
169
< React . Fragment >
@@ -204,19 +189,16 @@ const CollectionListRowBase = (props) => {
204
189
) ;
205
190
} ;
206
191
207
- const { collection, mobile } = props ;
192
+ const { collection } = props ;
208
193
209
194
return (
210
195
< tr className = "sketches-table__row" key = { collection . id } >
211
196
< th scope = "row" >
212
197
< span className = "sketches-table__name" > { renderCollectionName ( ) } </ span >
213
198
</ 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 >
220
202
< td className = "sketch-list__dropdown-column" > { renderActions ( ) } </ td >
221
203
</ tr >
222
204
) ;
@@ -239,11 +221,8 @@ CollectionListRowBase.propTypes = {
239
221
} )
240
222
)
241
223
} ) . isRequired ,
242
- // eslint-disable-next-line react/require-default-props
243
- mobile : PropTypes . bool ,
244
224
user : PropTypes . shape ( {
245
- username : PropTypes . string ,
246
- authenticated : PropTypes . bool . isRequired
225
+ username : PropTypes . string
247
226
} ) . isRequired ,
248
227
deleteCollection : PropTypes . func . isRequired ,
249
228
editCollection : PropTypes . func . isRequired ,
0 commit comments