From 614e9b6d555b57dda61a0902782e7ce6a48981a0 Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Sat, 27 Jan 2018 14:16:29 +0200 Subject: [PATCH 01/10] feat(NoteList): add ability to clone note --- browser/main/NoteList/index.js | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 8adaf1a0..356f5fb2 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,45 @@ class NoteList extends React.Component { this.setState({ selectedNoteKeys: [] }) } + cloneNote () { + const { selectedNoteKeys } = this.state + const { dispatch } = this.props + const { router } = this.context + const { storage, folder } = this.resolveTargetFolder() + const notes = this.notes.map((note) => Object.assign({}, note)) + const selectedNotes = findNotesByKeys(notes, selectedNoteKeys) + const firstNote = selectedNotes[0] + + AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN') + AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE') + dataApi + .createNote(storage.key, { + type: firstNote.type, + folder: folder.key, + title: firstNote.title + ' copy', + content: firstNote.content + }) + .then((note) => { + console.log(note) + dispatch({ + type: 'UPDATE_NOTE', + note: note + }) + let uniqueKey = note.storage + '-'+ note.key; + + this.setState({ + selectedNoteKeys: [uniqueKey] + }) + + router.push({ + pathname: location.pathname, + query: { + key: uniqueKey + } + }) + }) + } + importFromFile () { const options = { filters: [ From ca5b1eea138fa17b7b3e2e1d34959f93b94fecb8 Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Sat, 27 Jan 2018 17:33:22 +0200 Subject: [PATCH 02/10] chore: removing console.log --- browser/main/NoteList/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 356f5fb2..6f60d44b 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -567,7 +567,6 @@ class NoteList extends React.Component { content: firstNote.content }) .then((note) => { - console.log(note) dispatch({ type: 'UPDATE_NOTE', note: note @@ -577,7 +576,7 @@ class NoteList extends React.Component { this.setState({ selectedNoteKeys: [uniqueKey] }) - + router.push({ pathname: location.pathname, query: { From 4c2b233722a075fcbe488d34ab3bc12d92a5243e Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Sat, 27 Jan 2018 17:45:50 +0200 Subject: [PATCH 03/10] fix: resolve ci issues --- browser/main/NoteList/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 6f60d44b..1b33cb87 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -571,7 +571,7 @@ class NoteList extends React.Component { type: 'UPDATE_NOTE', note: note }) - let uniqueKey = note.storage + '-'+ note.key; + let uniqueKey = note.storage + '-' + note.key this.setState({ selectedNoteKeys: [uniqueKey] From d5da6de86c533927109432b945bb5fe49aa51b84 Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Mon, 29 Jan 2018 09:13:09 +0200 Subject: [PATCH 04/10] fix(NoteList): fix router issue --- browser/main/NoteList/index.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 1b33cb87..63788f04 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -556,8 +556,9 @@ class NoteList extends React.Component { 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('ADD_MARKDOWN') + AwsMobileAnalyticsConfig.recordDynamicCustomEvent(eventName) AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE') dataApi .createNote(storage.key, { @@ -571,18 +572,12 @@ class NoteList extends React.Component { type: 'UPDATE_NOTE', note: note }) - let uniqueKey = note.storage + '-' + note.key + + const uniqueKey = note.storage + '-' + note.key this.setState({ selectedNoteKeys: [uniqueKey] }) - - router.push({ - pathname: location.pathname, - query: { - key: uniqueKey - } - }) }) } From 9f14a503d83dcb3dcdd9d43a1c076ef543ce5384 Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Mon, 29 Jan 2018 09:24:12 +0200 Subject: [PATCH 05/10] fix(history): use hashHistory --- browser/main/NoteList/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 63788f04..566cd013 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -550,7 +550,7 @@ class NoteList extends React.Component { cloneNote () { const { selectedNoteKeys } = this.state - const { dispatch } = this.props + const { dispatch, location } = this.props const { router } = this.context const { storage, folder } = this.resolveTargetFolder() const notes = this.notes.map((note) => Object.assign({}, note)) @@ -578,6 +578,11 @@ class NoteList extends React.Component { this.setState({ selectedNoteKeys: [uniqueKey] }) + + hashHistory.push({ + pathname: location.pathname, + query: {key: note.storage + '-' + note.key} + }) }) } From 4cb7e63421cab6fc3d2c5ddd6c2873e6f7005553 Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Mon, 29 Jan 2018 09:25:01 +0200 Subject: [PATCH 06/10] chore: clean up --- browser/main/NoteList/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 566cd013..4ac50991 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -581,7 +581,7 @@ class NoteList extends React.Component { hashHistory.push({ pathname: location.pathname, - query: {key: note.storage + '-' + note.key} + query: {key: uniqueKey} }) }) } From 184839423f19a5670f1429db63be7ecc7ab510b5 Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Tue, 30 Jan 2018 10:37:58 +0200 Subject: [PATCH 07/10] fix(NoteList): remove router --- browser/main/NoteList/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 4ac50991..5c172e0b 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -551,7 +551,6 @@ class NoteList extends React.Component { cloneNote () { const { selectedNoteKeys } = this.state const { dispatch, location } = this.props - const { router } = this.context const { storage, folder } = this.resolveTargetFolder() const notes = this.notes.map((note) => Object.assign({}, note)) const selectedNotes = findNotesByKeys(notes, selectedNoteKeys) From edda3a4d232ce63730ede2fbfc48efba7a882fed Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Tue, 30 Jan 2018 11:45:47 +0200 Subject: [PATCH 08/10] chore: cleanup --- browser/main/NoteList/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 5c172e0b..bd7cf5b5 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -567,6 +567,7 @@ class NoteList extends React.Component { content: firstNote.content }) .then((note) => { + dispatch({ type: 'UPDATE_NOTE', note: note From 34a335797c8055b8acdcc55f471fad594072a689 Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Tue, 30 Jan 2018 11:49:39 +0200 Subject: [PATCH 09/10] chore: remove trailing space --- browser/main/NoteList/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index bd7cf5b5..3e15ecc8 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -567,14 +567,11 @@ class NoteList extends React.Component { content: firstNote.content }) .then((note) => { - + const uniqueKey = note.storage + '-' + note.key dispatch({ type: 'UPDATE_NOTE', note: note }) - - const uniqueKey = note.storage + '-' + note.key - this.setState({ selectedNoteKeys: [uniqueKey] }) From ef5639ff4b9bb9e35f4455dc178d3887f5a4891f Mon Sep 17 00:00:00 2001 From: Georges Indrianjafy Date: Tue, 30 Jan 2018 11:56:59 +0200 Subject: [PATCH 10/10] chore: removing space --- browser/main/NoteList/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 3e15ecc8..c164b35f 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -572,6 +572,7 @@ class NoteList extends React.Component { type: 'UPDATE_NOTE', note: note }) + this.setState({ selectedNoteKeys: [uniqueKey] })