diff --git a/docs/alternate-views.md b/docs/alternate-views.md
index e69de29b..de72cd1a 100644
--- a/docs/alternate-views.md
+++ b/docs/alternate-views.md
@@ -0,0 +1,47 @@
+# Alternate Views & Opening Methods
+
+## Views
+As well as the default start view, Dashy has several other start pages, for different tasks. You can switch views with the view-switcher button in the top-right, or set a default starting view using the `appConfig.startingView` attribute (can be `default`, `minimal` or `workspace`).
+
+### Default
+This is the main page that you will land on when you first launch the application. Here all of your sections and items will be visible, you can modify settings and search + launch your applications.
+
+
No Items to Show Yet
@@ -52,10 +51,9 @@
import Item from '@/components/LinkItems/Item.vue';
import Collapsable from '@/components/LinkItems/Collapsable.vue';
import IframeModal from '@/components/LinkItems/IframeModal.vue';
-import { getCurrentUser, isLoggedInAsGuest } from '@/utils/Auth';
export default {
- name: 'ItemGroup',
+ name: 'Section',
inject: ['config'],
props: {
groupId: String,
@@ -87,9 +85,6 @@ export default {
? `grid-template-rows: repeat(${this.displayData.itemCountY}, 1fr);` : '';
return styles;
},
- currentUser() {
- return getCurrentUser();
- },
},
methods: {
/* Returns a unique lowercase string, based on name, for section ID */
@@ -116,35 +111,6 @@ export default {
if (interval < 1) interval = 0;
return interval;
},
- /* Returns false if this section should not be rendered for the current user/ guest */
- isSectionVisibleToUser() {
- const determineVisibility = (visibilityList, currentUser) => {
- let isFound = false;
- visibilityList.forEach((userInList) => {
- if (userInList.toLowerCase() === currentUser) isFound = true;
- });
- return isFound;
- };
- const checkVisiblity = () => {
- if (!this.currentUser) return true;
- const hideFor = this.displayData.hideForUsers || [];
- const currentUser = this.currentUser.user.toLowerCase();
- return !determineVisibility(hideFor, currentUser);
- };
- const checkHiddenability = () => {
- if (!this.currentUser) return true;
- const currentUser = this.currentUser.user.toLowerCase();
- const showForUsers = this.displayData.showForUsers || [];
- if (showForUsers.length < 1) return true;
- return determineVisibility(showForUsers, currentUser);
- };
- const checkIfHideForGuest = () => {
- const hideForGuest = this.displayData.hideForGuests;
- const isGuest = isLoggedInAsGuest();
- return !(hideForGuest && isGuest);
- };
- return checkVisiblity() && checkHiddenability() && checkIfHideForGuest();
- },
},
};
diff --git a/src/utils/CheckSectionVisibility.js b/src/utils/CheckSectionVisibility.js
new file mode 100644
index 00000000..b5b65f4e
--- /dev/null
+++ b/src/utils/CheckSectionVisibility.js
@@ -0,0 +1,54 @@
+/**
+ * A helper function that filters all the sections based on current users permissions
+ * Checks each sections displayData for hideForUsers, showForUsers and hideForGuests
+ * Returns an array of sections that the current logged in user has permissions for
+ */
+
+// Import helper functions from auth, to get current user, and check if guest
+import { getCurrentUser, isLoggedInAsGuest } from '@/utils/Auth';
+
+/* Helper function, checks if a given username appears in a user array */
+const determineVisibility = (visibilityList, cUsername) => {
+ let isFound = false;
+ visibilityList.forEach((userInList) => {
+ if (userInList.toLowerCase() === cUsername) isFound = true;
+ });
+ return isFound;
+};
+
+/* Returns false if this section should not be rendered for the current user/ guest */
+const isSectionVisibleToUser = (displayData, currentUser, isGuest) => {
+ // Checks if user explicitly has access to a certain section
+ const checkVisiblity = () => {
+ if (!currentUser) return true;
+ const hideFor = displayData.hideForUsers || [];
+ const cUsername = currentUser.user.toLowerCase();
+ return !determineVisibility(hideFor, cUsername);
+ };
+ // Checks if user is explicitly prevented from viewing a certain section
+ const checkHiddenability = () => {
+ if (!currentUser) return true;
+ const cUsername = currentUser.user.toLowerCase();
+ const showForUsers = displayData.showForUsers || [];
+ if (showForUsers.length < 1) return true;
+ return determineVisibility(showForUsers, cUsername);
+ };
+ // Checks if the current user is a guest, and if section allows for guests
+ const checkIfHideForGuest = () => {
+ const hideForGuest = displayData.hideForGuests;
+ return !(hideForGuest && isGuest);
+ };
+ return checkVisiblity() && checkHiddenability() && checkIfHideForGuest();
+};
+
+/* Putting it all together, the function to export */
+const checkSectionVisibility = (sections) => {
+ const currentUser = getCurrentUser(); // Get current user object
+ const isGuest = isLoggedInAsGuest(); // Check if current user is a guest
+ return sections.filter((currentSection) => {
+ const displayData = currentSection.displayData || {};
+ return isSectionVisibleToUser(displayData, currentUser, isGuest);
+ });
+};
+
+export default checkSectionVisibility;
diff --git a/src/utils/ConfigHelpers.js b/src/utils/ConfigHelpers.js
index d282c297..d8ce987f 100644
--- a/src/utils/ConfigHelpers.js
+++ b/src/utils/ConfigHelpers.js
@@ -1,4 +1,5 @@
import ConfigAccumulator from '@/utils/ConfigAccumalator';
+import filterUserSections from '@/utils/CheckSectionVisibility';
import { languages } from '@/utils/languages';
import {
visibleComponents,
@@ -13,7 +14,11 @@ import {
*/
export const config = (() => {
const Accumulator = new ConfigAccumulator();
- return Accumulator.config();
+ return {
+ appConfig: Accumulator.appConfig(),
+ pageInfo: Accumulator.pageInfo(),
+ sections: filterUserSections(Accumulator.sections()),
+ };
})();
/**
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 42adf811..b13c818e 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -18,7 +18,7 @@
-
import SettingsContainer from '@/components/Settings/SettingsContainer.vue';
-import ItemGroup from '@/components/LinkItems/ItemGroup.vue';
+import Section from '@/components/LinkItems/Section.vue';
import Defaults, { localStorageKeys, iconCdns } from '@/utils/defaults';
export default {
@@ -54,7 +54,7 @@ export default {
},
components: {
SettingsContainer,
- ItemGroup,
+ Section,
},
data: () => ({
searchValue: '',
@@ -130,11 +130,11 @@ export default {
getDisplayData(section) {
return !section.displayData ? {} : section.displayData;
},
- /* Sets layout attribute, which is used by ItemGroup */
+ /* Sets layout attribute, which is used by Section */
setLayoutOrientation(layout) {
this.layoutOrientation = layout;
},
- /* Sets item size attribute, which is used by ItemGroup */
+ /* Sets item size attribute, which is used by Section */
setItemSize(itemSize) {
this.iconSize = itemSize;
},