From 8cf0b87f5f958bbb492bc7f0b4041bfc01ca8104 Mon Sep 17 00:00:00 2001 From: Benoit Schweblin Date: Sun, 16 Jun 2019 14:49:50 +0100 Subject: [PATCH] Added account management modal --- .gitignore | 1 + src/assets/iconGoogle.svg | 13 + src/components/Modal.vue | 2 + src/components/SideBar.vue | 1 - src/components/menus/MainMenu.vue | 107 ++++++- src/components/menus/PublishMenu.vue | 10 +- src/components/menus/SyncMenu.vue | 8 +- src/components/menus/WorkspacesMenu.vue | 8 +- src/components/modals/AboutModal.vue | 2 +- .../modals/AccountManagementModal.vue | 267 ++++++++++++++++++ src/components/modals/ImageModal.vue | 6 +- .../modals/PublishManagementModal.vue | 4 +- src/components/modals/SyncManagementModal.vue | 4 +- .../modals/WorkspaceManagementModal.vue | 6 +- src/icons/Key.vue | 5 + src/icons/Provider.vue | 4 + src/icons/index.js | 2 + .../providers/helpers/googleHelper.js | 49 ++-- src/store/data.js | 6 +- src/styles/variables.scss | 2 +- static/landing/index.html | 2 +- 21 files changed, 445 insertions(+), 64 deletions(-) create mode 100644 src/assets/iconGoogle.svg create mode 100644 src/components/modals/AccountManagementModal.vue create mode 100644 src/icons/Key.vue diff --git a/.gitignore b/.gitignore index 23a42a30..cc4299cf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ dist/ .history +.idea npm-debug.log* .vscode stackedit_v4 diff --git a/src/assets/iconGoogle.svg b/src/assets/iconGoogle.svg new file mode 100644 index 00000000..956716df --- /dev/null +++ b/src/assets/iconGoogle.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/src/components/Modal.vue b/src/components/Modal.vue index 191eb671..8208baf1 100644 --- a/src/components/Modal.vue +++ b/src/components/Modal.vue @@ -36,6 +36,7 @@ import ImageModal from './modals/ImageModal'; import SyncManagementModal from './modals/SyncManagementModal'; import PublishManagementModal from './modals/PublishManagementModal'; import WorkspaceManagementModal from './modals/WorkspaceManagementModal'; +import AccountManagementModal from './modals/AccountManagementModal'; import SponsorModal from './modals/SponsorModal'; // Providers @@ -86,6 +87,7 @@ export default { SyncManagementModal, PublishManagementModal, WorkspaceManagementModal, + AccountManagementModal, SponsorModal, // Providers GooglePhotoModal, diff --git a/src/components/SideBar.vue b/src/components/SideBar.vue index 5660f9ef..5d58775a 100644 --- a/src/components/SideBar.vue +++ b/src/components/SideBar.vue @@ -56,7 +56,6 @@ const panelNames = { history: 'File history', export: 'Export to disk', import: 'Import from disk', - more: 'More', }; export default { diff --git a/src/components/menus/MainMenu.vue b/src/components/menus/MainMenu.vue index 6d819e95..998c72e5 100644 --- a/src/components/menus/MainMenu.vue +++ b/src/components/menus/MainMenu.vue @@ -88,8 +88,44 @@ Print
- - More... + + +
Settings
+ Tweak application and keyboard shortcuts. +
+ + +
Templates
+ Configure Handlebars templates for your exports. +
+ + +
User accounts
+ Manage access to your external accounts. +
+
+ + + Export workspace backup + + + + + +
Reset application
+ Sign out and clean all workspaces. +
+
+ + + About StackEdit @@ -102,6 +138,8 @@ import UserImage from '../UserImage'; import googleHelper from '../../services/providers/helpers/googleHelper'; import syncSvc from '../../services/syncSvc'; import userSvc from '../../services/userSvc'; +import backupSvc from '../../services/backupSvc'; +import utils from '../../services/utils'; import store from '../../store'; export default { @@ -131,6 +169,13 @@ export default { publishLocationCount() { return Object.keys(store.getters['publishLocation/current']).length; }, + templateCount() { + return Object.keys(store.getters['data/allTemplatesById']).length; + }, + accountCount() { + return Object.values(store.getters['data/tokensByType']) + .reduce((count, tokensBySub) => count + Object.values(tokensBySub).length, 0); + }, }, methods: { ...mapActions('data', { @@ -154,6 +199,64 @@ export default { print() { window.print(); }, + onImportBackup(evt) { + const file = evt.target.files[0]; + if (file) { + const reader = new FileReader(); + reader.onload = (e) => { + const text = e.target.result; + if (text.match(/\uFFFD/)) { + store.dispatch('notification/error', 'File is not readable.'); + } else { + backupSvc.importBackup(text); + } + }; + const blob = file.slice(0, 10000000); + reader.readAsText(blob); + } + }, + exportWorkspace() { + window.location.href = utils.addQueryParams('app', { + ...utils.queryParams, + exportWorkspace: true, + }, true); + window.location.reload(); + }, + async settings() { + try { + const settings = await store.dispatch('modal/open', 'settings'); + store.dispatch('data/setSettings', settings); + } catch (e) { + // Cancel + } + }, + async templates() { + try { + const { templates } = await store.dispatch('modal/open', 'templates'); + store.dispatch('data/setTemplatesById', templates); + } catch (e) { + // Cancel + } + }, + async accounts() { + try { + await store.dispatch('modal/open', 'accountManagement'); + } catch (e) { + // Cancel + } + }, + async reset() { + try { + await store.dispatch('modal/open', 'reset'); + window.location.href = '#reset=true'; + window.location.reload(); + } catch (e) { + // Cancel + } + }, + about() { + store.dispatch('modal/open', 'about'); + }, }, }; diff --git a/src/components/menus/PublishMenu.vue b/src/components/menus/PublishMenu.vue index 6d4cd48b..c44775a4 100644 --- a/src/components/menus/PublishMenu.vue +++ b/src/components/menus/PublishMenu.vue @@ -1,23 +1,23 @@