🔥 Use VueX store instead of props for router

This commit is contained in:
Alicia Sykes 2021-10-09 19:42:51 +01:00
parent 5e6f78e6e7
commit 0e5eca1b7b
8 changed files with 45 additions and 42 deletions

View File

@ -71,10 +71,16 @@ export default {
IconWorkspaceView, IconWorkspaceView,
IconMinimalView, IconMinimalView,
}, },
props: { computed: {
sections: Array, sections() {
pageInfo: Object, return this.$store.getters.sections;
appConfig: Object, },
appConfig() {
return this.$store.getters.appConfig;
},
pageInfo() {
return this.$store.getters.pageInfo;
},
}, },
methods: { methods: {
showEditor: function show() { showEditor: function show() {

View File

@ -11,8 +11,7 @@
:confTheme="getInitialTheme()" :userThemes="getUserThemes()" /> :confTheme="getInitialTheme()" :userThemes="getUserThemes()" />
<LayoutSelector :displayLayout="displayLayout" @layoutUpdated="updateDisplayLayout"/> <LayoutSelector :displayLayout="displayLayout" @layoutUpdated="updateDisplayLayout"/>
<ItemSizeSelector :iconSize="iconSize" @iconSizeUpdated="updateIconSize" /> <ItemSizeSelector :iconSize="iconSize" @iconSizeUpdated="updateIconSize" />
<ConfigLauncher :sections="sections" :pageInfo="pageInfo" :appConfig="appConfig" <ConfigLauncher @modalChanged="modalChanged" />
@modalChanged="modalChanged" />
<AuthButtons v-if="userState != 'noone'" :userType="userState" /> <AuthButtons v-if="userState != 'noone'" :userType="userState" />
</div> </div>
<div :class="`show-hide-container ${settingsVisible? 'hide-btn' : 'show-btn'}`"> <div :class="`show-hide-container ${settingsVisible? 'hide-btn' : 'show-btn'}`">

View File

@ -62,37 +62,30 @@ const router = new Router({
path: '/', path: '/',
name: `landing-page-${getStartingView()}`, name: `landing-page-${getStartingView()}`,
component: getStartingComponent(), component: getStartingComponent(),
props: config,
meta: makeMetaTags('Home Page'), meta: makeMetaTags('Home Page'),
}, },
{ // Default home page { // Default home page
path: routePaths.home, path: routePaths.home,
name: 'home', name: 'home',
component: Home, component: Home,
props: config,
meta: makeMetaTags('Home Page'), meta: makeMetaTags('Home Page'),
}, },
{ // Workspace view page { // Workspace view page
path: routePaths.workspace, path: routePaths.workspace,
name: 'workspace', name: 'workspace',
component: Workspace, component: Workspace,
props: config,
meta: makeMetaTags('Workspace'), meta: makeMetaTags('Workspace'),
}, },
{ // Minimal view page { // Minimal view page
path: routePaths.minimal, path: routePaths.minimal,
name: 'minimal', name: 'minimal',
component: Minimal, component: Minimal,
props: config,
meta: makeMetaTags('Start Page'), meta: makeMetaTags('Start Page'),
}, },
{ // The login page { // The login page
path: routePaths.login, path: routePaths.login,
name: 'login', name: 'login',
component: Login, component: Login,
props: {
appConfig: config.appConfig,
},
beforeEnter: (to, from, next) => { beforeEnter: (to, from, next) => {
// If the user already logged in + guest mode not enabled, then redirect home // If the user already logged in + guest mode not enabled, then redirect home
if (isAuthenticated() && !isGuestAccessEnabled()) router.push({ path: '/' }); if (isAuthenticated() && !isGuestAccessEnabled()) router.push({ path: '/' });
@ -109,7 +102,6 @@ const router = new Router({
path: routePaths.download, path: routePaths.download,
name: 'download', name: 'download',
component: () => import('./views/DownloadConfig.vue'), component: () => import('./views/DownloadConfig.vue'),
props: config,
meta: makeMetaTags('Download Config'), meta: makeMetaTags('Download Config'),
}, },
{ // Page not found, any non-defined routes will land here { // Page not found, any non-defined routes will land here

View File

@ -7,18 +7,13 @@ import JsonToYaml from '@/utils/JsonToYaml';
export default { export default {
name: 'DownloadConfig', name: 'DownloadConfig',
props: { computed: {
sections: Array, config() {
appConfig: Object, return this.$store.state.config;
pageInfo: Object, },
}, },
data() { data() {
return { return {
config: {
appConfig: this.appConfig,
pageInfo: this.pageInfo,
sections: this.sections,
},
jsonParser: JsonToYaml, jsonParser: JsonToYaml,
}; };
}, },

View File

@ -55,11 +55,6 @@ import Defaults, { localStorageKeys, iconCdns } from '@/utils/defaults';
export default { export default {
name: 'home', name: 'home',
props: {
sections: Array, // Main site content
appConfig: Object, // Main site configuation (optional)
pageInfo: Object, // Page metadata (optional)
},
components: { components: {
SettingsContainer, SettingsContainer,
Section, Section,
@ -71,6 +66,15 @@ export default {
modalOpen: false, // When true, keybindings are disabled modalOpen: false, // When true, keybindings are disabled
}), }),
computed: { 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 */ /* Get class for num columns, if specified by user */
colCount() { colCount() {
let { colCount } = this.appConfig; let { colCount } = this.appConfig;

View File

@ -91,9 +91,6 @@ export default {
Button, Button,
Input, Input,
}, },
props: {
appConfig: Object,
},
data() { data() {
return { return {
username: '', username: '',
@ -104,6 +101,9 @@ export default {
}; };
}, },
computed: { computed: {
appConfig() {
return this.$store.getters.appConfig;
},
/* Data for timeout dropdown menu, translated label + value in ms */ /* Data for timeout dropdown menu, translated label + value in ms */
dropDownMenu() { dropDownMenu() {
return [ return [

View File

@ -2,8 +2,7 @@
<div class="minimal-home" :style="getBackgroundImage() + setColumnCount()"> <div class="minimal-home" :style="getBackgroundImage() + setColumnCount()">
<!-- Buttons for config and home page --> <!-- Buttons for config and home page -->
<div class="minimal-buttons"> <div class="minimal-buttons">
<ConfigLauncher :sections="sections" :pageInfo="pageInfo" :appConfig="appConfig" <ConfigLauncher @modalChanged="modalChanged" class="config-launcher" />
@modalChanged="modalChanged" class="config-launcher" />
</div> </div>
<!-- Page title and search bar --> <!-- Page title and search bar -->
<div class="title-and-search"> <div class="title-and-search">
@ -60,11 +59,6 @@ import ConfigLauncher from '@/components/Settings/ConfigLauncher';
export default { export default {
name: 'home', name: 'home',
props: {
sections: Array, // Main site content
appConfig: Object, // Main site configuation (optional)
pageInfo: Object,
},
components: { components: {
MinimalSection, MinimalSection,
MinimalHeading, MinimalHeading,
@ -79,6 +73,17 @@ export default {
tabbedView: true, // By default use tabs, when searching then show all instead tabbedView: true, // By default use tabs, when searching then show all instead
theme: GetTheme(), theme: GetTheme(),
}), }),
computed: {
sections() {
return this.$store.getters.sections;
},
appConfig() {
return this.$store.getters.appConfig;
},
pageInfo() {
return this.$store.getters.pageInfo;
},
},
watch: { watch: {
/* When the theme changes, then call the update method */ /* When the theme changes, then call the update method */
searchValue() { searchValue() {

View File

@ -16,10 +16,6 @@ import { GetTheme, ApplyLocalTheme, ApplyCustomVariables } from '@/utils/ThemeHe
export default { export default {
name: 'Workspace', name: 'Workspace',
props: {
sections: Array,
appConfig: Object,
},
data: () => ({ data: () => ({
url: '', url: '',
GetTheme, GetTheme,
@ -27,6 +23,12 @@ export default {
ApplyCustomVariables, ApplyCustomVariables,
}), }),
computed: { computed: {
sections() {
return this.$store.getters.sections;
},
appConfig() {
return this.$store.getters.appConfig;
},
isMultiTaskingEnabled() { isMultiTaskingEnabled() {
return this.appConfig.enableMultiTasking || false; return this.appConfig.enableMultiTasking || false;
}, },