From d75dd874ca7489786cd70e4444d400609f402a23 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Mon, 15 Oct 2018 08:24:21 +0200 Subject: [PATCH 1/2] create note with selected tags --- browser/lib/newNote.js | 12 ++++++++++-- browser/main/NewNoteButton/index.js | 7 ++++--- browser/main/modals/NewNoteModal.js | 8 ++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/browser/lib/newNote.js b/browser/lib/newNote.js index bed69735..855de0d0 100644 --- a/browser/lib/newNote.js +++ b/browser/lib/newNote.js @@ -3,14 +3,18 @@ import dataApi from 'browser/main/lib/dataApi' import ee from 'browser/main/lib/eventEmitter' import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig' -export function createMarkdownNote (storage, folder, dispatch, location) { +export function createMarkdownNote (storage, folder, dispatch, location, params) { AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN') AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE') + + const tags = location.pathname.match(/\/tags/) ? params.tagname.split(' ') : [] + return dataApi .createNote(storage, { type: 'MARKDOWN_NOTE', folder: folder, title: '', + tags, content: '' }) .then(note => { @@ -29,14 +33,18 @@ export function createMarkdownNote (storage, folder, dispatch, location) { }) } -export function createSnippetNote (storage, folder, dispatch, location, config) { +export function createSnippetNote (storage, folder, dispatch, location, params, config) { AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET') AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE') + + const tags = location.pathname.match(/\/tags/) ? params.tagname.split(' ') : [] + return dataApi .createNote(storage, { type: 'SNIPPET_NOTE', folder: folder, title: '', + tags, description: '', snippets: [ { diff --git a/browser/main/NewNoteButton/index.js b/browser/main/NewNoteButton/index.js index e739a550..2b756ef4 100644 --- a/browser/main/NewNoteButton/index.js +++ b/browser/main/NewNoteButton/index.js @@ -35,19 +35,20 @@ class NewNoteButton extends React.Component { } handleNewNoteButtonClick (e) { - const { location, dispatch, config } = this.props + const { location, params, dispatch, config } = this.props const { storage, folder } = this.resolveTargetFolder() if (config.ui.defaultNote === 'MARKDOWN_NOTE') { - createMarkdownNote(storage.key, folder.key, dispatch, location) + createMarkdownNote(storage.key, folder.key, dispatch, location, params) } else if (config.ui.defaultNote === 'SNIPPET_NOTE') { - createSnippetNote(storage.key, folder.key, dispatch, location, config) + createSnippetNote(storage.key, folder.key, dispatch, location, params, config) } else { modal.open(NewNoteModal, { storage: storage.key, folder: folder.key, dispatch, location, + params, config }) } diff --git a/browser/main/modals/NewNoteModal.js b/browser/main/modals/NewNoteModal.js index 8b16f2a2..44a08dcc 100644 --- a/browser/main/modals/NewNoteModal.js +++ b/browser/main/modals/NewNoteModal.js @@ -21,8 +21,8 @@ class NewNoteModal extends React.Component { } handleMarkdownNoteButtonClick (e) { - const { storage, folder, dispatch, location } = this.props - createMarkdownNote(storage, folder, dispatch, location).then(() => { + const { storage, folder, dispatch, location, params } = this.props + createMarkdownNote(storage, folder, dispatch, location, params).then(() => { setTimeout(this.props.close, 200) }) } @@ -35,8 +35,8 @@ class NewNoteModal extends React.Component { } handleSnippetNoteButtonClick (e) { - const { storage, folder, dispatch, location, config } = this.props - createSnippetNote(storage, folder, dispatch, location, config).then(() => { + const { storage, folder, dispatch, location, params, config } = this.props + createSnippetNote(storage, folder, dispatch, location, params, config).then(() => { setTimeout(this.props.close, 200) }) } From d0d813552c7a666da5b862a78e51cf5a214885b5 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Thu, 8 Nov 2018 18:22:52 +0100 Subject: [PATCH 2/2] add option to tag the new notes with the filtering tags, or not... --- browser/lib/newNote.js | 12 +++++++++--- browser/main/NewNoteButton/index.js | 2 +- browser/main/modals/NewNoteModal.js | 4 ++-- browser/main/modals/PreferencesModal/UiTab.js | 11 +++++++++++ locales/en.json | 3 ++- locales/fr.json | 3 ++- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/browser/lib/newNote.js b/browser/lib/newNote.js index 855de0d0..0b64d0e1 100644 --- a/browser/lib/newNote.js +++ b/browser/lib/newNote.js @@ -3,11 +3,14 @@ import dataApi from 'browser/main/lib/dataApi' import ee from 'browser/main/lib/eventEmitter' import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig' -export function createMarkdownNote (storage, folder, dispatch, location, params) { +export function createMarkdownNote (storage, folder, dispatch, location, params, config) { AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN') AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE') - const tags = location.pathname.match(/\/tags/) ? params.tagname.split(' ') : [] + let tags = [] + if (config.ui.tagNewNoteWithFilteringTags && location.pathname.match(/\/tags/)) { + tags = params.tagname.split(' ') + } return dataApi .createNote(storage, { @@ -37,7 +40,10 @@ export function createSnippetNote (storage, folder, dispatch, location, params, AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET') AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE') - const tags = location.pathname.match(/\/tags/) ? params.tagname.split(' ') : [] + let tags = [] + if (config.ui.tagNewNoteWithFilteringTags && location.pathname.match(/\/tags/)) { + tags = params.tagname.split(' ') + } return dataApi .createNote(storage, { diff --git a/browser/main/NewNoteButton/index.js b/browser/main/NewNoteButton/index.js index 2b756ef4..c34443be 100644 --- a/browser/main/NewNoteButton/index.js +++ b/browser/main/NewNoteButton/index.js @@ -39,7 +39,7 @@ class NewNoteButton extends React.Component { const { storage, folder } = this.resolveTargetFolder() if (config.ui.defaultNote === 'MARKDOWN_NOTE') { - createMarkdownNote(storage.key, folder.key, dispatch, location, params) + createMarkdownNote(storage.key, folder.key, dispatch, location, params, config) } else if (config.ui.defaultNote === 'SNIPPET_NOTE') { createSnippetNote(storage.key, folder.key, dispatch, location, params, config) } else { diff --git a/browser/main/modals/NewNoteModal.js b/browser/main/modals/NewNoteModal.js index 44a08dcc..a190602c 100644 --- a/browser/main/modals/NewNoteModal.js +++ b/browser/main/modals/NewNoteModal.js @@ -21,8 +21,8 @@ class NewNoteModal extends React.Component { } handleMarkdownNoteButtonClick (e) { - const { storage, folder, dispatch, location, params } = this.props - createMarkdownNote(storage, folder, dispatch, location, params).then(() => { + const { storage, folder, dispatch, location, params, config } = this.props + createMarkdownNote(storage, folder, dispatch, location, params, config).then(() => { setTimeout(this.props.close, 200) }) } diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 97f3877c..8bc81b43 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -68,6 +68,7 @@ class UiTab extends React.Component { theme: this.refs.uiTheme.value, language: this.refs.uiLanguage.value, defaultNote: this.refs.defaultNote.value, + tagNewNoteWithFilteringTags: this.refs.tagNewNoteWithFilteringTags.checked, showCopyNotification: this.refs.showCopyNotification.checked, confirmDeletion: this.refs.confirmDeletion.checked, showOnlyRelatedTags: this.refs.showOnlyRelatedTags.checked, @@ -226,6 +227,16 @@ class UiTab extends React.Component { +
+ +