Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Permissions system

Smaug67397131748d6f5c
diff --git a/frontend/app/components/Sidebar/SidebarWorkspaces.vue b/frontend/app/components/Sidebar/SidebarWorkspaces.vue
index 001478bf..4b39fbbc 100644
--- a/frontend/app/components/Sidebar/SidebarWorkspaces.vue
+++ b/frontend/app/components/Sidebar/SidebarWorkspaces.vue
@@ -8,6 +8,9 @@
<li :class="{ selected: all_workspaces.value === workspaceId }" @click="selectOption(all_workspaces)">
<SidebarWorkspace :option="all_workspaces" />
</li>
+ <li :class="{ selected: shared_workspaces.value === workspaceId }" @click="selectOption(shared_workspaces)">
+ <SidebarWorkspace :option="shared_workspaces" />
+ </li>
<hr style="margin: 2px 0" />
<span style="margin: 4px 6px; font-size: small; font-weight: 600; color: var(--font-color-light)">Workspaces</span>
<li v-for="option in options" :key="option.meta?.id" :class="{ selected: option.value === workspaceId }" @click="selectOption(option)">
@@ -31,19 +34,19 @@ import type { Workspace } from './helpers';
const { workspaceId } = useSidebar();
const props = defineProps<{ options: Workspace[] }>();
const all_workspaces = ref({ text: 'All Workspaces', value: undefined, meta: { color: -1 } });
-
+const shared_workspaces = ref({ text: 'Shared with me', value: 'shared', meta: { color: -1, icon: 'users' } });
watch(
() => props.options,
opts => {
const storage_item = localStorage.getItem('filterWorkspace');
- if (storage_item && opts.find(option => option.value == storage_item)) {
+ if (storage_item && [...opts, shared_workspaces.value].find(option => option.value == storage_item)) {
workspaceId.value = storage_item;
}
},
{ immediate: true }, // check also during mounting
);
const isOpen = ref(false);
-const selectedOption = computed(() => props.options.find(option => option.value == workspaceId.value) || all_workspaces.value);
+const selectedOption = computed(() => [...props.options, shared_workspaces.value].find(option => option.value == workspaceId.value) || all_workspaces.value);
const toggleDropdown = () => (isOpen.value = !isOpen.value);
const closeDropdown = () => (isOpen.value = false);
diff --git a/frontend/app/composables/useSidebarTree.ts b/frontend/app/composables/useSidebarTree.ts
index c5881891..ebaaa8cb 100644
--- a/frontend/app/composables/useSidebarTree.ts
+++ b/frontend/app/composables/useSidebarTree.ts
@@ -6,7 +6,6 @@ const preferencesStore = usePreferences();
const { workspaceId } = useSidebar();
let nodes: ComputedRef<Item<Node>[]> | Ref<Item<Node>[]> = ref([]);
-
const allItems = computed(() => nodes.value.filter(n => n.data.role !== 1));
const structure = computed(() => new TreeStructure(allItems.value));
@@ -24,6 +23,7 @@ const resolveLink = (item: Node) => {
return '/dashboard';
};
+/* Do operations in the tree and return the final tree */
const tree = computed(() => {
if (!preferencesStore.get('normalizeFileIcons').value) {
for (const i of structure.value.childrenMap.keys()) {
@@ -34,7 +34,16 @@ const tree = computed(() => {
}
}
}
- return structure.value.generateTree();
+
+ const tree = structure.value.generateTree();
+
+ for (const item of tree) {
+ if ((item.data as Node).shared) {
+ item.parent_id = 'shared';
+ item.icon = 'users';
+ }
+ }
+ return tree;
});
const filtered = computed(() =>
diff --git a/frontend/app/stores/documents.store.ts b/frontend/app/stores/documents.store.ts
index 3772c4a3..b8ded9f4 100644
--- a/frontend/app/stores/documents.store.ts
+++ b/frontend/app/stores/documents.store.ts
@@ -152,7 +152,7 @@ export const useNodesStore = defineStore('nodes', {
if (this.nodes.length) return this.nodes;
const request = await makeRequest(`nodes/shared/@me`, 'GET', {});
if (request.status === 'success') {
- this.nodes.push(...(request.result as DB_Node[]).map((d: DB_Node) => ({ ...d, partial: false, shared: true })));
+ this.nodes.push(...(request.result as DB_Node[]).map((d: DB_Node) => ({ ...d, partial: true, shared: true })));
return this.nodes;
} else throw request;
},