From b896a2e086995836a262ea75a3881539a4efef86 Mon Sep 17 00:00:00 2001 From: Benoit Schweblin Date: Fri, 4 May 2018 19:07:28 +0100 Subject: [PATCH] Github workspace (part 2) --- package-lock.json | 12 +- package.json | 4 +- src/components/Explorer.vue | 7 +- src/components/ExplorerNode.vue | 40 ++--- src/components/NavigationBar.vue | 26 ++- src/components/ProviderName.vue | 5 - src/components/gutters/Comment.vue | 2 +- src/components/gutters/CurrentDiscussion.vue | 2 +- src/components/gutters/NewComment.vue | 13 +- src/components/menus/ExportMenu.vue | 8 +- src/components/menus/HistoryMenu.vue | 2 +- src/components/menus/ImportMenu.vue | 13 +- src/components/menus/MainMenu.vue | 7 +- src/components/menus/MoreMenu.vue | 4 +- src/components/menus/PublishMenu.vue | 30 ++-- src/components/menus/SyncMenu.vue | 16 +- src/components/menus/WorkspacesMenu.vue | 8 +- src/components/modals/AboutModal.vue | 2 +- src/components/modals/PandocExportModal.vue | 3 +- src/components/modals/PdfExportModal.vue | 3 +- .../modals/WorkspaceManagementModal.vue | 2 +- src/components/modals/common/ModalInner.vue | 2 +- src/services/backupSvc.js | 37 ++-- src/services/explorerSvc.js | 85 +++++++++ src/services/fileSvc.js | 162 ++++++++++++++++++ src/services/localDbSvc.js | 21 ++- src/services/providers/common/Provider.js | 2 + src/services/providers/dropboxProvider.js | 30 ++-- src/services/providers/githubProvider.js | 27 +-- .../providers/githubWorkspaceProvider.js | 5 +- .../providers/googleDriveAppDataProvider.js | 2 +- src/services/providers/googleDriveProvider.js | 34 ++-- .../providers/googleDriveWorkspaceProvider.js | 5 +- .../providers/helpers/couchdbHelper.js | 6 +- .../providers/helpers/githubHelper.js | 20 ++- .../providers/helpers/googleHelper.js | 2 +- src/services/syncSvc.js | 3 +- src/services/tempFileSvc.js | 7 +- src/services/userSvc.js | 41 ++++- src/services/utils.js | 30 +++- src/store/discussion.js | 2 +- src/store/explorer.js | 80 --------- src/store/index.js | 46 ++--- src/store/modal.js | 20 ++- src/store/moduleTemplate.js | 5 +- src/store/workspace.js | 24 +++ 46 files changed, 588 insertions(+), 319 deletions(-) create mode 100644 src/services/explorerSvc.js create mode 100644 src/services/fileSvc.js diff --git a/package-lock.json b/package-lock.json index b0d751ed..2384fa89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14498,9 +14498,9 @@ } }, "vue": { - "version": "2.5.13", - "resolved": "https://registry.npmjs.org/vue/-/vue-2.5.13.tgz", - "integrity": "sha512-3D+lY7HTkKbtswDM4BBHgqyq+qo8IAEE8lz8va1dz3LLmttjgo0FxairO4r1iN2OBqk8o1FyL4hvzzTFEdQSEw==" + "version": "2.5.16", + "resolved": "https://registry.npmjs.org/vue/-/vue-2.5.16.tgz", + "integrity": "sha512-/ffmsiVuPC8PsWcFkZngdpas19ABm5mh2wA7iDqcltyCTwlgZjHGeJYOXkBMo422iPwIcviOtrTCUpSfXmToLQ==" }, "vue-hot-reload-api": { "version": "2.2.4", @@ -14588,9 +14588,9 @@ "dev": true }, "vuex": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/vuex/-/vuex-2.5.0.tgz", - "integrity": "sha512-5oJPOJySBgSgSzoeO+gZB/BbN/XsapgIF6tz34UwJqnGZMQurzIO3B4KIBf862gfc9ya+oduY5sSkq+5/oOilQ==" + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.0.1.tgz", + "integrity": "sha512-wLoqz0B7DSZtgbWL1ShIBBCjv22GV5U+vcBFox658g6V0s4wZV9P4YjCNyoHSyIBpj1f29JBoNQIqD82cR4O3w==" }, "w3c-hr-time": { "version": "1.0.1", diff --git a/package.json b/package.json index dcd24257..ee9f15ac 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "serve-static": "^1.12.6", "tmp": "^0.0.33", "turndown": "^4.0.1", - "vue": "^2.3.3", - "vuex": "^2.3.1" + "vue": "^2.5.16", + "vuex": "^3.0.1" }, "devDependencies": { "autoprefixer": "^6.7.2", diff --git a/src/components/Explorer.vue b/src/components/Explorer.vue index ec8ff0d5..f412f4c0 100644 --- a/src/components/Explorer.vue +++ b/src/components/Explorer.vue @@ -28,6 +28,7 @@ diff --git a/src/components/gutters/Comment.vue b/src/components/gutters/Comment.vue index 594020ce..df554595 100644 --- a/src/components/gutters/Comment.vue +++ b/src/components/gutters/Comment.vue @@ -51,7 +51,7 @@ export default { this.$store.dispatch('modal/commentDeletion') .then( () => this.$store.dispatch('discussion/cleanCurrentFile', { filterComment: this.comment }), - () => {}); // Cancel + () => { /* Cancel */ }); }, }, mounted() { diff --git a/src/components/gutters/CurrentDiscussion.vue b/src/components/gutters/CurrentDiscussion.vue index 8fa8df66..53671090 100644 --- a/src/components/gutters/CurrentDiscussion.vue +++ b/src/components/gutters/CurrentDiscussion.vue @@ -99,7 +99,7 @@ export default { () => this.$store.dispatch('discussion/cleanCurrentFile', { filterDiscussion: this.currentDiscussion, }), - () => {}); // Cancel + () => { /* Cancel */ }); }, }, }; diff --git a/src/components/gutters/NewComment.vue b/src/components/gutters/NewComment.vue index 127c7161..48e9887b 100644 --- a/src/components/gutters/NewComment.vue +++ b/src/components/gutters/NewComment.vue @@ -3,7 +3,7 @@
- +
{{loginToken.name}}
@@ -33,9 +33,12 @@ export default { components: { UserImage, }, - computed: mapGetters('workspace', [ - 'loginToken', - ]), + computed: { + ...mapGetters('workspace', [ + 'loginToken', + 'userId', + ]), + }, methods: { ...mapMutations('discussion', [ 'setNewCommentFocus', @@ -53,7 +56,7 @@ export default { const discussionId = this.$store.state.discussion.currentDiscussionId; const comment = { discussionId, - sub: this.loginToken.sub, + sub: this.userId, text, created: Date.now(), }; diff --git a/src/components/menus/ExportMenu.vue b/src/components/menus/ExportMenu.vue index 585daa8f..5a9f8d95 100644 --- a/src/components/menus/ExportMenu.vue +++ b/src/components/menus/ExportMenu.vue @@ -35,19 +35,19 @@ export default { exportMarkdown() { const currentFile = this.$store.getters['file/current']; return exportSvc.exportToDisk(currentFile.id, 'md') - .catch(() => {}); // Cancel + .catch(() => { /* Cancel */ }); }, exportHtml() { return this.$store.dispatch('modal/open', 'htmlExport') - .catch(() => {}); // Cancel + .catch(() => { /* Cancel */ }); }, exportPdf() { return this.$store.dispatch('modal/open', 'pdfExport') - .catch(() => {}); // Cancel + .catch(() => { /* Cancel */ }); }, exportPandoc() { return this.$store.dispatch('modal/open', 'pandocExport') - .catch(() => {}); // Cancel + .catch(() => { /* Cancel */ }); }, }, }; diff --git a/src/components/menus/HistoryMenu.vue b/src/components/menus/HistoryMenu.vue index 2481be94..cb6d31f0 100644 --- a/src/components/menus/HistoryMenu.vue +++ b/src/components/menus/HistoryMenu.vue @@ -100,7 +100,7 @@ export default { return googleHelper.signin() .then( () => syncSvc.requestSync(), - () => {}, // Cancel + () => { /* Cancel */ }, ); }, close() { diff --git a/src/components/menus/ImportMenu.vue b/src/components/menus/ImportMenu.vue index a8892e54..2ae25382 100644 --- a/src/components/menus/ImportMenu.vue +++ b/src/components/menus/ImportMenu.vue @@ -29,6 +29,7 @@ import htmlSanitizer from '../../libs/htmlSanitizer'; import MenuEntry from './common/MenuEntry'; import Provider from '../../services/providers/common/Provider'; import store from '../../store'; +import fileSvc from '../../services/fileSvc'; const turndownService = new TurndownService(store.getters['data/computedSettings'].turndown); @@ -55,16 +56,18 @@ export default { onImportMarkdown(evt) { const file = evt.target.files[0]; readFile(file) - .then(content => this.$store.dispatch('createFile', { + .then(content => fileSvc.createFile({ ...Provider.parseContent(content), name: file.name, }) - .then(item => this.$store.commit('file/setCurrentId', item.id))); + .then( + item => this.$store.commit('file/setCurrentId', item.id)), + () => { /* Cancel */ }); }, onImportHtml(evt) { const file = evt.target.files[0]; readFile(file) - .then(content => this.$store.dispatch('createFile', { + .then(content => fileSvc.createFile({ ...Provider.parseContent( turndownService.turndown( htmlSanitizer.sanitizeHtml(content) @@ -72,7 +75,9 @@ export default { )), name: file.name, })) - .then(item => this.$store.commit('file/setCurrentId', item.id)); + .then( + item => this.$store.commit('file/setCurrentId', item.id), + () => { /* Cancel */ }); }, }, }; diff --git a/src/components/menus/MainMenu.vue b/src/components/menus/MainMenu.vue index fab1b4da..3994ad70 100644 --- a/src/components/menus/MainMenu.vue +++ b/src/components/menus/MainMenu.vue @@ -3,7 +3,7 @@