Skip to content

Commit 80ee149

Browse files
Rokt33rDavy-c
authored andcommitted
Rename vars and methods of new folder row
1 parent 5e5e281 commit 80ee149

1 file changed

Lines changed: 24 additions & 26 deletions

File tree

src/cloud/components/Views/Table/TableViewContentManagerNewFolderRow.tsx

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,72 +22,72 @@ const TableViewContentManagerNewFolderRow = ({
2222
folderId,
2323
className,
2424
}: TableViewContentManagerNewFolderRowProps) => {
25-
const [newFolderRowState, setNewFolderRowState] = useState<
26-
'idle' | 'editing' | 'submitting'
27-
>('idle')
25+
const [formState, setFormState] = useState<'idle' | 'editing' | 'submitting'>(
26+
'idle'
27+
)
2828

2929
const { translate } = useI18n()
3030
const { createFolder } = useCloudApi()
31-
const [newFolderName, setNewFolderName] = useState('')
31+
const [newName, setNewName] = useState('')
3232
const compositionStateRef = useRef(false)
33-
const newFolderInputRef = useRef<HTMLInputElement>(null)
33+
const newNameInputRef = useRef<HTMLInputElement>(null)
3434

3535
useEffect(() => {
36-
if (newFolderInputRef.current != null && newFolderRowState === 'editing') {
37-
newFolderInputRef.current.focus()
36+
if (newNameInputRef.current != null && formState === 'editing') {
37+
newNameInputRef.current.focus()
3838
}
39-
}, [newFolderRowState])
39+
}, [formState])
4040

4141
const createNewFolder = useCallback(async () => {
42-
setNewFolderRowState('submitting')
42+
setFormState('submitting')
4343
if (workspaceId != null) {
4444
await createFolder(
4545
team,
4646
{
47-
folderName: newFolderName,
47+
folderName: newName,
4848
description: '',
4949
workspaceId: workspaceId,
5050
parentFolderId: folderId,
5151
},
5252
{ skipRedirect: true }
5353
)
5454
}
55-
setNewFolderName('')
56-
setNewFolderRowState('idle')
57-
}, [workspaceId, folderId, createFolder, team, newFolderName])
55+
setNewName('')
56+
setFormState('idle')
57+
}, [workspaceId, folderId, createFolder, team, newName])
5858

5959
const cancelEditing = useCallback(() => {
60-
setNewFolderRowState('idle')
61-
setNewFolderName('')
60+
setFormState('idle')
61+
setNewName('')
6262
}, [])
6363

6464
return (
6565
<TableContentManagerRow className={className}>
66-
{newFolderRowState === 'idle' ? (
66+
{formState === 'idle' ? (
6767
<Button
6868
className='content__manager--no-padding'
6969
onClick={() => {
70-
setNewFolderRowState('editing')
70+
setFormState('editing')
7171
}}
7272
variant='transparent'
7373
iconPath={mdiPlus}
7474
>
7575
{translate(lngKeys.ModalsCreateNewFolder)}
7676
</Button>
77-
) : newFolderRowState === 'editing' ? (
77+
) : formState === 'editing' ? (
7878
<FormInput
79-
ref={newFolderInputRef}
80-
value={newFolderName}
79+
ref={newNameInputRef}
80+
value={newName}
8181
onChange={(event) => {
82-
setNewFolderName(event.target.value)
82+
setNewName(event.target.value)
8383
}}
8484
onCompositionStart={() => {
8585
compositionStateRef.current = true
8686
}}
8787
onCompositionEnd={() => {
8888
compositionStateRef.current = false
89-
if (newFolderInputRef.current != null) {
90-
newFolderInputRef.current.focus()
89+
if (newNameInputRef.current != null) {
90+
newNameInputRef.current.focus()
9191
}
9292
}}
9393
onKeyPress={(event) => {
@@ -105,9 +105,7 @@ const TableViewContentManagerNewFolderRow = ({
105105
return
106106
}
107107
}}
108-
onBlur={() => {
109-
cancelEditing()
110-
}}
108+
onBlur={cancelEditing}
111109
/>
112110
) : (
113111
<Spinner />

0 commit comments

Comments
 (0)