From 0e5eca1b7bc1594025c8e061c9ee7be6f9d74e5f Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 9 Oct 2021 19:42:51 +0100 Subject: [PATCH] :fire: Use VueX store instead of props for router --- src/components/Settings/ConfigLauncher.vue | 14 ++++++++++---- src/components/Settings/SettingsContainer.vue | 3 +-- src/router.js | 8 -------- src/views/DownloadConfig.vue | 13 ++++--------- src/views/Home.vue | 14 +++++++++----- src/views/Login.vue | 6 +++--- src/views/Minimal.vue | 19 ++++++++++++------- src/views/Workspace.vue | 10 ++++++---- 8 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/components/Settings/ConfigLauncher.vue b/src/components/Settings/ConfigLauncher.vue index 796c05e0..152119fc 100644 --- a/src/components/Settings/ConfigLauncher.vue +++ b/src/components/Settings/ConfigLauncher.vue @@ -71,10 +71,16 @@ export default { IconWorkspaceView, IconMinimalView, }, - props: { - sections: Array, - pageInfo: Object, - appConfig: Object, + computed: { + sections() { + return this.$store.getters.sections; + }, + appConfig() { + return this.$store.getters.appConfig; + }, + pageInfo() { + return this.$store.getters.pageInfo; + }, }, methods: { showEditor: function show() { diff --git a/src/components/Settings/SettingsContainer.vue b/src/components/Settings/SettingsContainer.vue index 57a21b70..2d148a38 100644 --- a/src/components/Settings/SettingsContainer.vue +++ b/src/components/Settings/SettingsContainer.vue @@ -11,8 +11,7 @@ :confTheme="getInitialTheme()" :userThemes="getUserThemes()" /> - +
diff --git a/src/router.js b/src/router.js index e76efe42..a41918e9 100644 --- a/src/router.js +++ b/src/router.js @@ -62,37 +62,30 @@ const router = new Router({ path: '/', name: `landing-page-${getStartingView()}`, component: getStartingComponent(), - props: config, meta: makeMetaTags('Home Page'), }, { // Default home page path: routePaths.home, name: 'home', component: Home, - props: config, meta: makeMetaTags('Home Page'), }, { // Workspace view page path: routePaths.workspace, name: 'workspace', component: Workspace, - props: config, meta: makeMetaTags('Workspace'), }, { // Minimal view page path: routePaths.minimal, name: 'minimal', component: Minimal, - props: config, meta: makeMetaTags('Start Page'), }, { // The login page path: routePaths.login, name: 'login', component: Login, - props: { - appConfig: config.appConfig, - }, beforeEnter: (to, from, next) => { // If the user already logged in + guest mode not enabled, then redirect home if (isAuthenticated() && !isGuestAccessEnabled()) router.push({ path: '/' }); @@ -109,7 +102,6 @@ const router = new Router({ path: routePaths.download, name: 'download', component: () => import('./views/DownloadConfig.vue'), - props: config, meta: makeMetaTags('Download Config'), }, { // Page not found, any non-defined routes will land here diff --git a/src/views/DownloadConfig.vue b/src/views/DownloadConfig.vue index 9a695052..ef3bf58c 100644 --- a/src/views/DownloadConfig.vue +++ b/src/views/DownloadConfig.vue @@ -7,18 +7,13 @@ import JsonToYaml from '@/utils/JsonToYaml'; export default { name: 'DownloadConfig', - props: { - sections: Array, - appConfig: Object, - pageInfo: Object, + computed: { + config() { + return this.$store.state.config; + }, }, data() { return { - config: { - appConfig: this.appConfig, - pageInfo: this.pageInfo, - sections: this.sections, - }, jsonParser: JsonToYaml, }; }, diff --git a/src/views/Home.vue b/src/views/Home.vue index 6c36bb2f..c73c11e4 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -55,11 +55,6 @@ import Defaults, { localStorageKeys, iconCdns } from '@/utils/defaults'; export default { name: 'home', - props: { - sections: Array, // Main site content - appConfig: Object, // Main site configuation (optional) - pageInfo: Object, // Page metadata (optional) - }, components: { SettingsContainer, Section, @@ -71,6 +66,15 @@ export default { modalOpen: false, // When true, keybindings are disabled }), computed: { + sections() { + return this.$store.getters.sections; + }, + appConfig() { + return this.$store.getters.appConfig; + }, + pageInfo() { + return this.$store.getters.pageInfo; + }, /* Get class for num columns, if specified by user */ colCount() { let { colCount } = this.appConfig; diff --git a/src/views/Login.vue b/src/views/Login.vue index 27030208..cea52489 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -91,9 +91,6 @@ export default { Button, Input, }, - props: { - appConfig: Object, - }, data() { return { username: '', @@ -104,6 +101,9 @@ export default { }; }, computed: { + appConfig() { + return this.$store.getters.appConfig; + }, /* Data for timeout dropdown menu, translated label + value in ms */ dropDownMenu() { return [ diff --git a/src/views/Minimal.vue b/src/views/Minimal.vue index cf2b9aa9..95e6b101 100644 --- a/src/views/Minimal.vue +++ b/src/views/Minimal.vue @@ -2,8 +2,7 @@
- +