Remove all instances of inject, replace with VueX store

This commit is contained in:
Alicia Sykes
2021-10-09 19:24:51 +01:00
parent 8a8166bb47
commit b55f96c839
16 changed files with 97 additions and 75 deletions

View File

@@ -69,7 +69,29 @@ export default {
IconOpen,
IconClose,
},
inject: ['visibleComponents'],
computed: {
/**
* Determines which button should display, based on the user type
* 0 = Auth not configured, don't show anything
* 1 = Auth condifured, and user logged in, show logout button
* 2 = Auth configured, guest access enabled, and not logged in, show login
* Note that if auth is enabled, but not guest access, and user not logged in,
* then they will never be able to view the homepage, so no button needed
*/
userState() {
return getUserState();
},
/* Object indicating which components should be hidden, based on user preferences */
visibleComponents() {
return this.$store.getters.visibleComponents;
},
},
data() {
return {
settingsVisible: this.getSettingsVisibility(),
searchVisible: (this.visibleComponents || defaultVisibleComponents).searchBar,
};
},
methods: {
userIsTypingSomething(something) {
this.$emit('user-is-searchin', something);
@@ -104,25 +126,6 @@ export default {
|| (this.visibleComponents || defaultVisibleComponents).settings);
},
},
computed: {
/**
* Determines which button should display, based on the user type
* 0 = Auth not configured, don't show anything
* 1 = Auth condifured, and user logged in, show logout button
* 2 = Auth configured, guest access enabled, and not logged in, show login
* Note that if auth is enabled, but not guest access, and user not logged in,
* then they will never be able to view the homepage, so no button needed
*/
userState() {
return getUserState();
},
},
data() {
return {
settingsVisible: this.getSettingsVisibility(),
searchVisible: (this.visibleComponents || defaultVisibleComponents).searchBar,
};
},
};
</script>