📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Fix migrations; services, add modal properties, fix stores
Smaug6739b6833a525e13
diff --git a/backend/app/migrations.go b/backend/app/migrations.goindex f1ab7858..52170a27 100644--- a/backend/app/migrations.go+++ b/backend/app/migrations.go@@ -32,7 +32,7 @@ func Migrate(config *Config) {m, err := migrate.NewWithDatabaseInstance(fmt.Sprintf("file://%s", absPath),- "mysql",+ "alexandrie",driver,)if err != nil {diff --git a/backend/services/node.service.go b/backend/services/node.service.goindex b292db1d..ad82b6a7 100644--- a/backend/services/node.service.go+++ b/backend/services/node.service.go@@ -77,7 +77,7 @@ SELECT * FROM user_nodes ORDER BY role, 'order' DESC, name;`, userId)func (s *Service) GetSharedNodes(userId types.Snowflake) ([]*models.Node, error) {var nodes = make([]*models.Node, 0)- // 1. Récupération des nodes accessibles+ // 1. Get all accessible nodes (owned or shared, including children of owned/shared nodes)rows, err := s.db.Query(`WITH RECURSIVE accessible_nodes AS (SELECT n.id, n.user_id, n.parent_id, n.name, n.description, n.tags, n.role, n.color, n.icon, n.theme,@@ -124,12 +124,12 @@ func (s *Service) GetSharedNodes(userId types.Snowflake) ([]*models.Node, error)); err != nil {return nil, err}- node.Permissions = []*models.Permission{} // initialiser le slice+ node.Permissions = []*models.Permission{}nodes = append(nodes, &node)nodeMap[node.Id] = &node}- // 2. Récupération des permissions pour tous les nodes récupérés+ // 2. Get permissions for the retrieved nodesif len(nodes) > 0 {nodeIDs := make([]interface{}, 0, len(nodes))for _, n := range nodes {diff --git a/frontend/app/components/Sidebar/SidebarItem.vue b/frontend/app/components/Sidebar/SidebarItem.vueindex 597585e6..f4daacc0 100644--- a/frontend/app/components/Sidebar/SidebarItem.vue+++ b/frontend/app/components/Sidebar/SidebarItem.vue@@ -13,6 +13,8 @@<NuxtLink :to="item.route" style="flex: 1" class="close">{{ item.label }}</NuxtLink>+ <Icon v-if="item.data.shared && !item.parent_id" name="users" fill="var(--font-color)" />+<NuxtLink v-if="item.data.role === 2" :to="`/dashboard/categories/${item.id}/edit`" class="nav close"><Icon name="settings" fill="var(--font-color)" /></NuxtLink>@@ -33,7 +35,7 @@ const props = defineProps<{ item: Item | DefaultItem }>();const customClass = computed(() => {if ('color' in props.item.data && props.item.data.color != null && props.item.data.color != -1)return `item-icon ${getAppColor(props.item.data.color as number)}`;- return '';+ return 'default-icon';});const icon = computed(() => {if ('icon' in props.item.data && props.item.data.icon) return props.item.data.icon;@@ -103,7 +105,7 @@ const drop = async (event: DragEvent) => {background: var(--bg-contrast-2);}- .icon {+ .default-icon {width: 20px;height: 20px;diff --git a/frontend/app/components/Sidebar/helpers.ts b/frontend/app/components/Sidebar/helpers.tsindex f0d2d165..672ab4e6 100644--- a/frontend/app/components/Sidebar/helpers.ts+++ b/frontend/app/components/Sidebar/helpers.ts@@ -1,6 +1,6 @@import type { Node } from '~/stores';-export type DefaultItem = Item<Omit<Node, 'user_id' | 'data' | 'show' | 'shared' | 'created_timestamp' | 'updated_timestamp'>>;+export type DefaultItem = Item<Omit<Node, 'user_id' | 'data' | 'show' | 'created_timestamp' | 'updated_timestamp'>>;export interface Workspace {text: string;value?: string;@@ -19,6 +19,8 @@ export const navigationItems: DefaultItem[] = [role: -1,name: 'Home',icon: 'dashboard',+ permissions: [],+ shared: false,},show: computed(() => sidebarItemsPrefs.value.home!),},@@ -33,6 +35,8 @@ export const navigationItems: DefaultItem[] = [role: -1,name: 'Manage categories',icon: 'categories',+ permissions: [],+ shared: false,},show: computed(() => sidebarItemsPrefs.value.manageCategories!),},@@ -47,6 +51,8 @@ export const navigationItems: DefaultItem[] = [role: -1,name: 'CDN',icon: 'cdn',+ permissions: [],+ shared: false,},show: computed(() => sidebarItemsPrefs.value.cdn!),},@@ -61,6 +67,8 @@ export const navigationItems: DefaultItem[] = [role: -1,name: 'Settings',icon: 'user_settings',+ permissions: [],+ shared: false,},show: computed(() => sidebarItemsPrefs.value.settings!),},@@ -75,6 +83,8 @@ export const navigationItems: DefaultItem[] = [role: -1,name: 'Documents',icon: 'files',+ permissions: [],+ shared: false,},show: computed(() => sidebarItemsPrefs.value.documents!),},@@ -89,6 +99,8 @@ export const navigationItems: DefaultItem[] = [role: -1,name: 'Import',icon: 'import',+ permissions: [],+ shared: false,},show: computed(() => sidebarItemsPrefs.value.importation!),},@@ -103,6 +115,8 @@ export const navigationItems: DefaultItem[] = [role: -1,name: 'New Page',icon: 'add_file',+ permissions: [],+ shared: false,},show: computed(() => sidebarItemsPrefs.value.newPage!),},diff --git a/frontend/app/composables/useNodesTree.ts b/frontend/app/composables/useNodesTree.tsindex a92426e5..045a9270 100644--- a/frontend/app/composables/useNodesTree.ts+++ b/frontend/app/composables/useNodesTree.ts@@ -7,7 +7,8 @@ let nodes: ComputedRef<Item<Node>[]> | Ref<Item<Node>[]> = ref([]);const structure = computed(() => new TreeStructure(nodes.value));const resolveIcon = (item: Node) => {- if (item.role === 1 || item.role === 2) return item.icon || 'folder';+ if (item.role === 1) return item.icon || 'workspace';+ if (item.role === 2) return item.icon || (item.shared ? 'shared_folder' : 'folder');if (item.role === 3) return item.accessibility == 1 ? 'file' : item.accessibility == 2 ? 'draft' : 'shared_doc';if (item.role === 4) return item.metadata?.filetype == 'application/pdf' ? 'pdf' : 'image';return 'file';diff --git a/frontend/app/helpers/icons.ts b/frontend/app/helpers/icons.tsindex 010d49c9..8b8c1c7c 100644--- a/frontend/app/helpers/icons.ts+++ b/frontend/app/helpers/icons.ts@@ -46,6 +46,7 @@ const icons = {security: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m438-338 226-226-57-57-169 169-84-84-57 57 141 141Zm42 258q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z"/></svg>`,settings: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"/></svg>`,shared_doc: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M160-120q-33 0-56.5-23.5T80-200v-480h80v480h600v80H160Zm160-160q-33 0-56.5-23.5T240-360v-480h680v480q0 33-23.5 56.5T840-280H320Zm0-80h520v-400H320v400Zm80-120h160v-200H400v200Zm200 0h160v-80H600v80Zm0-120h160v-80H600v80ZM320-360v-400 400Z"/></svg>`,+ shared_folder: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M440-280h320v-22q0-45-44-71.5T600-400q-72 0-116 26.5T440-302v22Zm160-160q33 0 56.5-23.5T680-520q0-33-23.5-56.5T600-600q-33 0-56.5 23.5T520-520q0 33 23.5 56.5T600-440ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z"/></svg>`,shortcuts: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M260-120q-58 0-99-41t-41-99q0-58 41-99t99-41h60v-160h-60q-58 0-99-41t-41-99q0-58 41-99t99-41q58 0 99 41t41 99v60h160v-60q0-58 41-99t99-41q58 0 99 41t41 99q0 58-41 99t-99 41h-60v160h60q58 0 99 41t41 99q0 58-41 99t-99 41q-58 0-99-41t-41-99v-60H400v60q0 58-41 99t-99 41Zm0-80q25 0 42.5-17.5T320-260v-60h-60q-25 0-42.5 17.5T200-260q0 25 17.5 42.5T260-200Zm440 0q25 0 42.5-17.5T760-260q0-25-17.5-42.5T700-320h-60v60q0 25 17.5 42.5T700-200ZM400-400h160v-160H400v160ZM260-640h60v-60q0-25-17.5-42.5T260-760q-25 0-42.5 17.5T200-700q0 25 17.5 42.5T260-640Zm380 0h60q25 0 42.5-17.5T760-700q0-25-17.5-42.5T700-760q-25 0-42.5 17.5T640-700v60Z"/></svg>`,snippets: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M600-360q50 0 85-35t35-85q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 50 35 85t85 35Zm0 80q-72 0-127-45t-69-115H240v-80h164q5-22 13.5-42.5T440-600H160v-80h440q83 0 141.5 58.5T800-480q0 83-58.5 141.5T600-280Z"/></svg>`,table: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200q-33 0-56.5-23.5T120-200Zm400-240v240h240v-240H520Zm0-80h240v-240H520v240Zm-80 0v-240H200v240h240Zm0 80H200v240h240v-240Z"/></svg>`,diff --git a/frontend/app/pages/dashboard/categories/[id]/index.vue b/frontend/app/pages/dashboard/categories/[id]/index.vueindex ff8e8608..1aa427de 100644--- a/frontend/app/pages/dashboard/categories/[id]/index.vue+++ b/frontend/app/pages/dashboard/categories/[id]/index.vue@@ -38,13 +38,7 @@ const view: Ref<'table' | 'list'> = ref('list');const openPermissionsModal = () => useModal().add(new Modal(shallowRef(NodePermissions), { props: { nodeId: categoryId }, size: 'small' }));const documents = computed(() => {- const documents = nodesStore.getByCategories(categoryId);- const childCategories = nodesStore.getChilds(categoryId);- for (const childCategory of childCategories) {- const childDocuments = nodesStore.getByCategories(childCategory.id);- documents.push(...childDocuments);- }- return documents;+ return nodesStore.getAllChildrens(categoryId).filter(d => d.role == 3);});</script>diff --git a/frontend/app/pages/dashboard/docs/[id].vue b/frontend/app/pages/dashboard/docs/[id].vueindex ca114471..0e929663 100644--- a/frontend/app/pages/dashboard/docs/[id].vue+++ b/frontend/app/pages/dashboard/docs/[id].vue@@ -56,6 +56,7 @@ watchEffect(async () => {}article.value = undefined;if (docFromStore.partial) {+ console.log(0);try {error.value = false;article.value = await documentsStore.fetch({ id: document_id });diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vueindex 56e312ee..a7df0f51 100644--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue@@ -23,7 +23,7 @@<NuxtLink @click="openEditModal" v-if="nodeStore.hasPermissions(doc, 2)"><Icon name="settings" :big="true" fill="var(--font-color)" /></NuxtLink>- <NuxtLink @click="openPermissionsModal" v-if="nodeStore.hasPermissions(doc, 3)">+ <NuxtLink @click="openPermissionsModal" v-if="nodeStore.hasPermissions(doc, 0)"><Icon name="users" :big="true" fill="var(--font-color)" /></NuxtLink><NuxtLink @click="openDeleteModal" v-if="nodeStore.hasPermissions(doc, 3)">diff --git a/frontend/app/pages/dashboard/docs/_modals/NodePermissions.vue b/frontend/app/pages/dashboard/docs/_modals/NodePermissions.vueindex 9ffd7536..531ac814 100644--- a/frontend/app/pages/dashboard/docs/_modals/NodePermissions.vue+++ b/frontend/app/pages/dashboard/docs/_modals/NodePermissions.vue@@ -1,6 +1,6 @@<template><div class="modal-content">- <h2 class="title">Manage permissions <tag yellow>Beta</tag></h2>+ <h2 class="title">Manage permissions <tag red>Alpha</tag></h2><!-- Search + add --><form @submit.prevent="addPermission">@@ -44,7 +44,6 @@</template><script setup lang="ts">-import AppSelect from '~/components/AppSelect.vue';import type { Node, Permission, PublicUser } from '~/stores';const props = defineProps<{@@ -79,12 +78,11 @@ watch(query, async newQuery => {const addPermission = async () => {if (!user.value) return;- const perm = await nodesStore.addPermission({+ await nodesStore.addPermission({node_id: props.nodeId,user_id: user.value.id,permission: selectedPermission.value,});- if (perm && localNode.value) localNode.value.permissions.push(perm);user.value = null;query.value = '';selectedPermission.value = 1;diff --git a/frontend/app/stores/nodes.store.ts b/frontend/app/stores/nodes.store.tsindex 0d23106a..f075cc03 100644--- a/frontend/app/stores/nodes.store.ts+++ b/frontend/app/stores/nodes.store.ts@@ -53,6 +53,22 @@ export const useNodesStore = defineStore('nodes', {if (index == -1) return;return cnodes[index - 1];},++ getAllChildrens: state => (id: string) => {+ const parent = state.nodes.find(d => d.id == id);+ if (!parent) return [];+ const childrens: Node[] = [parent];+ const getChildrens = (parent: Node) => {+ state.nodes.forEach(node => {+ if (node.parent_id == parent.id) {+ childrens.push(node);+ getChildrens(node);+ }+ });+ };+ getChildrens(parent);+ return childrens;+ },getAllChildrensIds: state => (id: string) => {const childrens: string[] = [id];const getChildrens = (parent: Node) => {@@ -111,6 +127,7 @@ export const useNodesStore = defineStore('nodes', {// Case 3: A parent node has a permission entry for this node (inherited permissions)const userStore = useUserStore();if (node.user_id === userStore.user?.id) return true;+ if (level === 0) return false; // level 0 = only ownerconst perm = node.permissions.find(p => p.user_id === userStore.user?.id);if (perm) return perm.permission >= level;let permission = -1;@@ -144,7 +161,9 @@ export const useNodesStore = defineStore('nodes', {if (opts?.id) {const result = request.result as { node: DB_Node; permissions: Permission[] };const index = this.nodes.findIndex(d => d.id == opts?.id);- const updatedNode: Node = { ...(result.node as DB_Node), partial: false, shared: false, permissions: result.permissions };+ let shared = false;+ if (index != -1) shared = this.nodes[index]!.shared;+ const updatedNode: Node = { ...(result.node as DB_Node), partial: false, shared: shared, permissions: result.permissions };if (index == -1) this.nodes.push(updatedNode);else this.nodes[index] = updatedNode;return updatedNode as 'id' extends keyof T ? Node : Node[];@@ -178,7 +197,10 @@ export const useNodesStore = defineStore('nodes', {for (const node of request.result as DB_Node[]) {const index = this.nodes.findIndex(d => d.id == node.id);if (index == -1) this.nodes.push({ ...node, partial: true, shared: true, permissions: node.permissions || [] });- else this.nodes[index] = { ...node, partial: true, shared: true, permissions: node.permissions || [] };+ else {+ const state = this.nodes[index];+ this.nodes[index] = { ...node, partial: true, shared: state?.shared ?? true, permissions: node.permissions || [] };+ }}return this.nodes;} else throw request;