mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-27 10:32:58 +02:00
Desktop: Add context menu and menu item to create sub-notebook (#1984)
* add context menu and menu item to create sub-notebook closes #1978 (create sub-notebook by right-clicking on notebook) * simplify code, remove async
This commit is contained in:
parent
0eb51e6bb0
commit
22398e69c5
@ -474,6 +474,18 @@ class Application extends BaseApplication {
|
||||
},
|
||||
};
|
||||
|
||||
const newSubNotebookItem = {
|
||||
label: _('New sub-notebook'),
|
||||
screens: ['Main'],
|
||||
click: () => {
|
||||
this.dispatch({
|
||||
type: 'WINDOW_COMMAND',
|
||||
name: 'newSubNotebook',
|
||||
activeFolderId: Setting.value('activeFolderId'),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const printItem = {
|
||||
label: _('Print'),
|
||||
accelerator: 'CommandOrControl+P',
|
||||
@ -617,7 +629,8 @@ class Application extends BaseApplication {
|
||||
},
|
||||
shim.isMac() ? noItem : newNoteItem,
|
||||
shim.isMac() ? noItem : newTodoItem,
|
||||
shim.isMac() ? noItem : newNotebookItem, {
|
||||
shim.isMac() ? noItem : newNotebookItem,
|
||||
shim.isMac() ? noItem : newSubNotebookItem, {
|
||||
type: 'separator',
|
||||
visible: shim.isMac() ? false : true,
|
||||
}, {
|
||||
@ -672,7 +685,8 @@ class Application extends BaseApplication {
|
||||
submenu: [
|
||||
newNoteItem,
|
||||
newTodoItem,
|
||||
newNotebookItem, {
|
||||
newNotebookItem,
|
||||
newSubNotebookItem, {
|
||||
label: _('Close Window'),
|
||||
platforms: ['darwin'],
|
||||
accelerator: 'Command+W',
|
||||
|
@ -102,7 +102,7 @@ class MainScreenComponent extends React.Component {
|
||||
} else {
|
||||
await createNewNote(null, true);
|
||||
}
|
||||
} else if (command.name === 'newNotebook') {
|
||||
} else if (command.name === 'newNotebook' || (command.name === 'newSubNotebook' && command.activeFolderId)) {
|
||||
this.setState({
|
||||
promptOptions: {
|
||||
label: _('Notebook title:'),
|
||||
@ -111,6 +111,7 @@ class MainScreenComponent extends React.Component {
|
||||
let folder = null;
|
||||
try {
|
||||
folder = await Folder.save({ title: answer }, { userSideValidation: true });
|
||||
if (command.name === 'newSubNotebook') folder = await Folder.moveToFolder(folder.id, command.activeFolderId);
|
||||
} catch (error) {
|
||||
bridge().showErrorMessageBox(error.message);
|
||||
}
|
||||
|
@ -286,6 +286,21 @@ class SideBarComponent extends React.Component {
|
||||
item = BaseModel.byId(this.props.folders, itemId);
|
||||
}
|
||||
|
||||
if (itemType === BaseModel.TYPE_FOLDER && !item.encryption_applied) {
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: _('New sub-notebook'),
|
||||
click: () => {
|
||||
this.props.dispatch({
|
||||
type: 'WINDOW_COMMAND',
|
||||
name: 'newSubNotebook',
|
||||
activeFolderId: itemId,
|
||||
});
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: buttonLabel,
|
||||
|
Loading…
Reference in New Issue
Block a user