Skip to content

Commit c0ed7eb

Browse files
committed
Separate folder nav item control button
1 parent 8bee0db commit c0ed7eb

File tree

1 file changed

+29
-35
lines changed

1 file changed

+29
-35
lines changed

src/components/molecules/FolderNavigatorItem.tsx

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import { useGeneralStatus } from '../../lib/generalStatus'
66
import { getFolderItemId } from '../../lib/nav'
77
import { getTransferrableNoteData } from '../../lib/dnd'
88
import { useTranslation } from 'react-i18next'
9-
import { mdiFolderOpen, mdiFolder, mdiDotsVertical, mdiPlus } from '@mdi/js'
9+
import {
10+
mdiFolderOpen,
11+
mdiFolder,
12+
mdiDotsVertical,
13+
mdiTextBoxPlusOutline,
14+
mdiFolderMultiplePlusOutline,
15+
} from '@mdi/js'
1016
import NavigatorButton from '../atoms/NavigatorButton'
1117
import { useRouter } from '../../lib/router'
1218
import { openContextMenu } from '../../lib/electronOnly'
@@ -75,6 +81,14 @@ const FolderNavigatorItem = ({
7581
)
7682
}, [storageId, folderPathname, push])
7783

84+
const createNoteInFolder = useCallback(() => {
85+
createNoteInFolderAndRedirect(folderPathname)
86+
}, [createNoteInFolderAndRedirect, folderPathname])
87+
88+
const createSubFolder = useCallback(() => {
89+
showPromptToCreateFolder(folderPathname)
90+
}, [showPromptToCreateFolder, folderPathname])
91+
7892
const showFolderRemoveMessageBox = useCallback(() => {
7993
messageBox({
8094
title: `Remove "${folderPathname}" folder`,
@@ -103,16 +117,12 @@ const FolderNavigatorItem = ({
103117
{
104118
type: 'normal',
105119
label: 'New Note',
106-
click: async () => {
107-
createNoteInFolderAndRedirect(folderPathname)
108-
},
120+
click: createNoteInFolder,
109121
},
110122
{
111123
type: 'normal',
112124
label: 'New Subfolder',
113-
click: async () => {
114-
showPromptToCreateFolder(folderPathname)
115-
},
125+
click: createSubFolder,
116126
},
117127
{
118128
type: 'separator',
@@ -135,38 +145,13 @@ const FolderNavigatorItem = ({
135145
[
136146
folderPathname,
137147
t,
138-
createNoteInFolderAndRedirect,
139-
showPromptToCreateFolder,
148+
createNoteInFolder,
149+
createSubFolder,
140150
showRenamePrompt,
141151
showFolderRemoveMessageBox,
142152
]
143153
)
144154

145-
const openPlusContextMenu = useCallback(
146-
(event: React.MouseEvent) => {
147-
event.preventDefault()
148-
openContextMenu({
149-
menuItems: [
150-
{
151-
type: 'normal',
152-
label: 'New Note',
153-
click: async () => {
154-
createNoteInFolderAndRedirect(folderPathname)
155-
},
156-
},
157-
{
158-
type: 'normal',
159-
label: 'New Subfolder',
160-
click: async () => {
161-
showPromptToCreateFolder(folderPathname)
162-
},
163-
},
164-
],
165-
})
166-
},
167-
[folderPathname, createNoteInFolderAndRedirect, showPromptToCreateFolder]
168-
)
169-
170155
const openMoreContextMenu = useCallback(
171156
(event: React.MouseEvent) => {
172157
event.preventDefault()
@@ -251,7 +236,16 @@ const FolderNavigatorItem = ({
251236
onFoldButtonClick={toggleFolded}
252237
control={
253238
<>
254-
<NavigatorButton onClick={openPlusContextMenu} iconPath={mdiPlus} />
239+
<NavigatorButton
240+
title='New Note'
241+
onClick={createNoteInFolder}
242+
iconPath={mdiTextBoxPlusOutline}
243+
/>
244+
<NavigatorButton
245+
title='New Subfolder'
246+
onClick={createSubFolder}
247+
iconPath={mdiFolderMultiplePlusOutline}
248+
/>
255249
<NavigatorButton
256250
onClick={openMoreContextMenu}
257251
iconPath={mdiDotsVertical}

0 commit comments

Comments
 (0)