diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 8adaf1a0..c164b35f 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -441,6 +441,7 @@ class NoteList extends React.Component { const pinLabel = note.isPinned ? 'Remove pin' : 'Pin to Top' const deleteLabel = 'Delete Note' + const cloneNote = 'Clone Note' const menu = new Menu() if (!location.pathname.match(/\/home|\/starred|\/trash/)) { @@ -453,6 +454,10 @@ class NoteList extends React.Component { label: deleteLabel, click: this.deleteNote })) + menu.append(new MenuItem({ + label: cloneNote, + click: this.cloneNote.bind(this) + })) menu.popup() } @@ -543,6 +548,42 @@ class NoteList extends React.Component { this.setState({ selectedNoteKeys: [] }) } + cloneNote () { + const { selectedNoteKeys } = this.state + const { dispatch, location } = this.props + const { storage, folder } = this.resolveTargetFolder() + const notes = this.notes.map((note) => Object.assign({}, note)) + const selectedNotes = findNotesByKeys(notes, selectedNoteKeys) + const firstNote = selectedNotes[0] + const eventName = firstNote.type === 'MARKDOWN_NOTE' ? 'ADD_MARKDOWN' : 'ADD_SNIPPET' + + AwsMobileAnalyticsConfig.recordDynamicCustomEvent(eventName) + AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE') + dataApi + .createNote(storage.key, { + type: firstNote.type, + folder: folder.key, + title: firstNote.title + ' copy', + content: firstNote.content + }) + .then((note) => { + const uniqueKey = note.storage + '-' + note.key + dispatch({ + type: 'UPDATE_NOTE', + note: note + }) + + this.setState({ + selectedNoteKeys: [uniqueKey] + }) + + hashHistory.push({ + pathname: location.pathname, + query: {key: uniqueKey} + }) + }) + } + importFromFile () { const options = { filters: [