@@ -13,7 +13,8 @@ import {
13
13
mdiPaperclip ,
14
14
mdiBookOpen ,
15
15
mdiSync ,
16
- mdiPlus ,
16
+ mdiTextBoxPlusOutline ,
17
+ mdiFolderMultiplePlusOutline ,
17
18
} from '@mdi/js'
18
19
import FolderNavigatorFragment from './FolderNavigatorFragment'
19
20
import TagListFragment from './TagListFragment'
@@ -155,23 +156,27 @@ const StorageNavigatorFragment = ({
155
156
const attachmentsPagePathname = `/app/storages/${ storage . id } /attachments`
156
157
const attachmentsPageIsActive = routeParams . name === 'storages.attachments'
157
158
159
+ const createNewNoteInRootFolder = useCallback ( ( ) => {
160
+ createNoteInFolderAndRedirect ( '/' )
161
+ } , [ createNoteInFolderAndRedirect ] )
162
+
163
+ const createNewFolderInRootFolder = useCallback ( ( ) => {
164
+ showPromptToCreateFolder ( '/' )
165
+ } , [ showPromptToCreateFolder ] )
166
+
158
167
const openWorkspaceContextMenu : MouseEventHandler = useCallback (
159
168
( event ) => {
160
169
event . preventDefault ( )
161
170
const contentMenuItems : MenuItemConstructorOptions [ ] = [
162
171
{
163
172
type : 'normal' ,
164
173
label : 'New Note' ,
165
- click : async ( ) => {
166
- createNoteInFolderAndRedirect ( '/' )
167
- } ,
174
+ click : createNewNoteInRootFolder ,
168
175
} ,
169
176
{
170
177
type : 'normal' ,
171
178
label : t ( 'folder.create' ) ,
172
- click : async ( ) => {
173
- showPromptToCreateFolder ( '/' )
174
- } ,
179
+ click : createNewFolderInRootFolder ,
175
180
} ,
176
181
]
177
182
@@ -188,7 +193,7 @@ const StorageNavigatorFragment = ({
188
193
submitButtonLabel : t ( 'storage.rename' ) ,
189
194
onClose : async ( value : string | null ) => {
190
195
if ( value == null ) return
191
- await renameStorage ( storage . id , value )
196
+ renameStorage ( storage . id , value )
192
197
} ,
193
198
} )
194
199
} ,
@@ -242,8 +247,8 @@ const StorageNavigatorFragment = ({
242
247
storage ,
243
248
prompt ,
244
249
messageBox ,
245
- createNoteInFolderAndRedirect ,
246
- showPromptToCreateFolder ,
250
+ createNewNoteInRootFolder ,
251
+ createNewFolderInRootFolder ,
247
252
sync ,
248
253
t ,
249
254
push ,
@@ -252,31 +257,6 @@ const StorageNavigatorFragment = ({
252
257
]
253
258
)
254
259
255
- const openNewContextMenu : MouseEventHandler = useCallback (
256
- ( event ) => {
257
- event . preventDefault ( )
258
- openContextMenu ( {
259
- menuItems : [
260
- {
261
- type : 'normal' ,
262
- label : 'New Note' ,
263
- click : async ( ) => {
264
- createNoteInFolderAndRedirect ( '/' )
265
- } ,
266
- } ,
267
- {
268
- type : 'normal' ,
269
- label : 'New Folder' ,
270
- click : async ( ) => {
271
- showPromptToCreateFolder ( '/' )
272
- } ,
273
- } ,
274
- ] ,
275
- } )
276
- } ,
277
- [ createNoteInFolderAndRedirect , showPromptToCreateFolder ]
278
- )
279
-
280
260
const attachments = useMemo ( ( ) => Object . values ( storage . attachmentMap ) , [
281
261
storage . attachmentMap ,
282
262
] )
@@ -287,6 +267,10 @@ const StorageNavigatorFragment = ({
287
267
288
268
const syncing = storage . type !== 'fs' && storage . sync != null
289
269
270
+ const folded = useMemo ( ( ) => {
271
+ return ! sideNavOpenedItemSet . has ( rootFolderNavId )
272
+ } , [ sideNavOpenedItemSet , rootFolderNavId ] )
273
+
290
274
return (
291
275
< >
292
276
< NavigatorItem
@@ -296,13 +280,24 @@ const StorageNavigatorFragment = ({
296
280
active = { rootFolderIsActive }
297
281
onClick = { ( ) => push ( rootFolderPathname ) }
298
282
onContextMenu = { openWorkspaceContextMenu }
299
- folded = { ! sideNavOpenedItemSet . has ( rootFolderNavId ) }
283
+ folded = { folded }
284
+ visibleControl = { true }
300
285
onFoldButtonClick = { ( ) => {
301
286
toggleSideNavOpenedItem ( rootFolderNavId )
302
287
} }
303
288
control = {
304
289
< >
305
- < NavigatorButton onClick = { openNewContextMenu } iconPath = { mdiPlus } />
290
+ < NavigatorButton
291
+ onClick = { createNewNoteInRootFolder }
292
+ iconPath = { mdiTextBoxPlusOutline }
293
+ title = 'New Note'
294
+ />
295
+ < NavigatorButton
296
+ onClick = { createNewFolderInRootFolder }
297
+ iconPath = { mdiFolderMultiplePlusOutline }
298
+ title = 'New Folder'
299
+ />
300
+
306
301
{ storage . type !== 'fs' && storage . cloudStorage != null && (
307
302
< NavigatorButton
308
303
active = { syncing }
0 commit comments