Implements the checking if things should be visible, at component level

This commit is contained in:
Alicia Sykes 2021-07-04 09:05:38 +01:00
parent b214785c8a
commit 3f4b1575f9
2 changed files with 11 additions and 7 deletions

View File

@ -8,10 +8,11 @@
<script> <script>
import PageTitle from '@/components/PageStrcture/PageTitle.vue'; import PageTitle from '@/components/PageStrcture/PageTitle.vue';
import Nav from '@/components/PageStrcture/Nav.vue'; import Nav from '@/components/PageStrcture/Nav.vue';
import { visibleComponents } from '@/utils/defaults'; import { visibleComponents as defaultVisibleComponents } from '@/utils/defaults';
export default { export default {
name: 'Header', name: 'Header',
inject: ['visibleComponents'],
components: { components: {
PageTitle, PageTitle,
Nav, Nav,
@ -21,9 +22,8 @@ export default {
}, },
data() { data() {
return { return {
hiddenComponents: this.pageInfo.hiddenComponents || {}, titleVisible: (this.visibleComponents || defaultVisibleComponents).pageTitle,
titleVisible: visibleComponents.pageTitle, navVisible: (this.visibleComponents || defaultVisibleComponents).navigation,
navVisible: visibleComponents.navigation,
}; };
}, },
}; };

View File

@ -29,7 +29,6 @@
</template> </template>
<script> <script>
import Defaults, { localStorageKeys } from '@/utils/defaults';
import SearchBar from '@/components/Settings/SearchBar'; import SearchBar from '@/components/Settings/SearchBar';
import ConfigLauncher from '@/components/Settings/ConfigLauncher'; import ConfigLauncher from '@/components/Settings/ConfigLauncher';
import ThemeSelector from '@/components/Settings/ThemeSelector'; import ThemeSelector from '@/components/Settings/ThemeSelector';
@ -41,6 +40,10 @@ import AppInfoModal from '@/components/Configuration/AppInfoModal';
import { logout as registerLogout } from '@/utils/Auth'; import { logout as registerLogout } from '@/utils/Auth';
import IconOpen from '@/assets/interface-icons/config-open-settings.svg'; import IconOpen from '@/assets/interface-icons/config-open-settings.svg';
import IconClose from '@/assets/interface-icons/config-close.svg'; import IconClose from '@/assets/interface-icons/config-close.svg';
import {
localStorageKeys,
visibleComponents as defaultVisibleComponents,
} from '@/utils/defaults';
export default { export default {
name: 'SettingsContainer', name: 'SettingsContainer',
@ -65,6 +68,7 @@ export default {
IconOpen, IconOpen,
IconClose, IconClose,
}, },
inject: ['visibleComponents'],
methods: { methods: {
userIsTypingSomething(something) { userIsTypingSomething(something) {
this.$emit('user-is-searchin', something); this.$emit('user-is-searchin', something);
@ -106,13 +110,13 @@ export default {
}, },
getSettingsVisibility() { getSettingsVisibility() {
return JSON.parse(localStorage[localStorageKeys.HIDE_SETTINGS] return JSON.parse(localStorage[localStorageKeys.HIDE_SETTINGS]
|| Defaults.visibleComponents.settings); || (this.visibleComponents || defaultVisibleComponents).settings);
}, },
}, },
data() { data() {
return { return {
searchVisible: Defaults.visibleComponents.searchBar,
settingsVisible: this.getSettingsVisibility(), settingsVisible: this.getSettingsVisibility(),
searchVisible: (this.visibleComponents || defaultVisibleComponents).searchBar,
}; };
}, },
}; };