1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 10:16:26 +00:00

use context.popup on NoteList

This commit is contained in:
Sosuke Suzuki
2018-06-30 16:08:13 +09:00
parent ae493cbd0e
commit 0a42b0f61f

View File

@@ -21,6 +21,7 @@ import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
import Markdown from '../../lib/markdown' import Markdown from '../../lib/markdown'
import i18n from 'browser/lib/i18n' import i18n from 'browser/lib/i18n'
import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote' import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote'
import context from 'browser/lib/context'
const { remote } = require('electron') const { remote } = require('electron')
const { Menu, MenuItem, dialog } = remote const { Menu, MenuItem, dialog } = remote
@@ -491,55 +492,51 @@ class NoteList extends React.Component {
const updateLabel = i18n.__('Update Blog') const updateLabel = i18n.__('Update Blog')
const openBlogLabel = i18n.__('Open Blog') const openBlogLabel = i18n.__('Open Blog')
const menu = new Menu() const templates = []
if (location.pathname.match(/\/trash/)) { if (location.pathname.match(/\/trash/)) {
menu.append(new MenuItem({ templates.push({
label: restoreNote, label: restoreNote,
click: this.restoreNote click: this.restoreNote
})) }, {
menu.append(new MenuItem({
label: deleteLabel, label: deleteLabel,
click: this.deleteNote click: this.deleteNote
})) })
} else { } else {
if (!location.pathname.match(/\/starred/)) { if (!location.pathname.match(/\/starred/)) {
menu.append(new MenuItem({ templates.push({
label: pinLabel, label: pinLabel,
click: this.pinToTop click: this.pinToTop
})) })
} }
menu.append(new MenuItem({ templates.push({
label: deleteLabel, label: deleteLabel,
click: this.deleteNote click: this.deleteNote
})) }, {
menu.append(new MenuItem({
label: cloneNote, label: cloneNote,
click: this.cloneNote.bind(this) click: this.cloneNote.bind(this)
})) }, {
menu.append(new MenuItem({
label: copyNoteLink, label: copyNoteLink,
click: this.copyNoteLink(note) click: this.copyNoteLink(note)
})) })
if (note.type === 'MARKDOWN_NOTE') { if (note.type === 'MARKDOWN_NOTE') {
if (note.blog && note.blog.blogLink && note.blog.blogId) { if (note.blog && note.blog.blogLink && note.blog.blogId) {
menu.append(new MenuItem({ templates.push({
label: updateLabel, label: updateLabel,
click: this.publishMarkdown.bind(this) click: this.publishMarkdown.bind(this)
})) }, {
menu.append(new MenuItem({
label: openBlogLabel, label: openBlogLabel,
click: () => this.openBlog.bind(this)(note) click: () => this.openBlog.bind(this)(note)
})) })
} else { } else {
menu.append(new MenuItem({ templates.push({
label: publishLabel, label: publishLabel,
click: this.publishMarkdown.bind(this) click: this.publishMarkdown.bind(this)
})) })
} }
} }
} }
menu.popup() context.popup(templates)
} }
updateSelectedNotes (updateFunc, cleanSelection = true) { updateSelectedNotes (updateFunc, cleanSelection = true) {