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.

reorganize code structure with node hierarchy

Smaug67391389ef9da6ad
diff --git a/frontend/app/pages/(public)/doc/_components/HierarchyNode.vue b/frontend/app/components/Node/Hierarchy/Item.vue
similarity index 87%
rename from frontend/app/pages/(public)/doc/_components/HierarchyNode.vue
rename to frontend/app/components/Node/Hierarchy/Item.vue
index bda8f292..b477a329 100644
--- a/frontend/app/pages/(public)/doc/_components/HierarchyNode.vue
+++ b/frontend/app/components/Node/Hierarchy/Item.vue
@@ -9,7 +9,7 @@
<!-- Node icon -->
<span class="node-icon" :class="getAccentClass">
- <Icon :name="node.icon || getDefaultIcon" display="md" />
+ <Icon :name="node.icon || resolveIcon(props.node)" display="md" />
</span>
<!-- Node content -->
@@ -20,7 +20,7 @@
<!-- Node metadata -->
<div class="node-meta">
- <span class="node-type">{{ getRoleLabel }}</span>
+ <span class="node-type">{{ getRoleName(props.node.role) }}</span>
<span v-if="hasChildren" class="children-count">{{ childrenCount }}</span>
</div>
</div>
@@ -28,13 +28,14 @@
<!-- Children (collapsible) -->
<Transition name="expand">
<div v-if="isExpanded && hasChildren" class="node-children">
- <HierarchyNode v-for="child in children" :key="child.id" :node="child" :all-nodes="allNodes" :depth="depth + 1" />
+ <NodeHierarchyItem v-for="child in children" :key="child.id" :node="child" :all-nodes="allNodes" :depth="depth + 1" />
</div>
</Transition>
</div>
</template>
<script setup lang="ts">
+import { resolveIcon, getRoleName } from '~/helpers/node';
import type { Node } from '~/stores';
const props = defineProps<{
@@ -66,32 +67,6 @@ const children = computed(() => {
const hasChildren = computed(() => children.value.length > 0);
const childrenCount = computed(() => children.value.length);
-const getDefaultIcon = computed(() => {
- switch (props.node.role) {
- case 1:
- return 'workspace';
- case 2:
- return 'files';
- case 3:
- return 'file';
- default:
- return 'file';
- }
-});
-
-const getRoleLabel = computed(() => {
- switch (props.node.role) {
- case 1:
- return 'Workspace';
- case 2:
- return 'Category';
- case 3:
- return 'Document';
- default:
- return '';
- }
-});
-
const getAccentClass = computed(() => {
return getAppAccent(props.node.color as number, true);
});
diff --git a/frontend/app/pages/(public)/doc/_components/HierarchyTree.vue b/frontend/app/components/Node/Hierarchy/Tree.vue
similarity index 93%
rename from frontend/app/pages/(public)/doc/_components/HierarchyTree.vue
rename to frontend/app/components/Node/Hierarchy/Tree.vue
index c5fc7ec7..0bbc4cbd 100644
--- a/frontend/app/pages/(public)/doc/_components/HierarchyTree.vue
+++ b/frontend/app/components/Node/Hierarchy/Tree.vue
@@ -9,7 +9,7 @@
</div>
<div class="tree-content">
- <HierarchyNode v-for="node in rootNodes" :key="node.id" :node="node" :all-nodes="allNodes" :depth="0" />
+ <NodeHierarchyItem v-for="node in rootNodes" :key="node.id" :node="node" :all-nodes="allNodes" :depth="0" />
</div>
<div v-if="!rootNodes.length" class="empty-state">
@@ -20,7 +20,6 @@
</template>
<script setup lang="ts">
-import HierarchyNode from './HierarchyNode.vue';
import type { Node } from '~/stores';
const props = defineProps<{
diff --git a/frontend/app/pages/(public)/doc/[id]/index.vue b/frontend/app/pages/(public)/doc/[id]/index.vue
index 636e4358..da236b4e 100644
--- a/frontend/app/pages/(public)/doc/[id]/index.vue
+++ b/frontend/app/pages/(public)/doc/[id]/index.vue
@@ -23,7 +23,7 @@
/>
<!-- Hierarchical children tree -->
- <HierarchyTree v-if="children.length > 0" :nodes="children" :parent-id="article.id" />
+ <NodeHierarchyTree v-if="children.length > 0" :nodes="children" :parent-id="article.id" />
</div>
<!-- Table of contents only for documents with content -->
@@ -46,7 +46,6 @@
import TableOfContent from '~/pages/dashboard/docs/_components/table-of-content/TableOfContents.vue';
import DocumentSkeleton from '~/pages/dashboard/docs/_components/DocumentSkeleton.vue';
import DocumentCardHeader from '~/pages/dashboard/docs/_components/DocumentCardHeader.vue';
-import HierarchyTree from '~/pages/(public)/doc/_components/HierarchyTree.vue';
import type { Node } from '~/stores';
const documentsStore = useNodesStore();
diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue
index 76831fe7..c258f871 100644
--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue
+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue
@@ -10,7 +10,7 @@
><img v-if="user" :src="api.avatarURL(user)" class="avatar" />
<span style="font-size: 16px; color: var(--font-color-light)">{{ user?.username }}</span>
</span>
- <DocumentCardHeaderActionRow :doc="doc" class="no-print" />
+ <DocumentCardHeaderActionRow :doc="doc" :is-public="public" class="no-print" />
</p>
<NuxtLink class="category" :to="`/dashboard/categories/${category?.id}`">{{ category?.name || 'Uncategorized' }}</NuxtLink>
<h1 class="title" :class="{ public: public }">{{ doc?.name }}</h1>
diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
index 82848ae4..04cd2252 100644
--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
@@ -1,9 +1,10 @@
<template>
<span class="row">
- <NuxtLink v-if="doc.accessibility == 3" :to="`/doc/${doc.id}`" :prefetch="false" target="_blank">
+ <NuxtLink v-if="doc.accessibility == 3 && !isPublic" :to="`/doc/${doc.id}`" :prefetch="false" target="_blank">
<Icon name="link" display="lg" />
+ <p class="hint-tooltip">Public link</p>
</NuxtLink>
- <NuxtLink v-if="nodeStore.hasPermissions(doc, 2)" :to="`/dashboard/docs/edit/${doc.id}`" :prefetch="false">
+ <NuxtLink v-if="nodeStore.hasPermissions(doc, 2)" :to="isPublic ? `/doc/${doc.id}/edit` : `/dashboard/docs/edit/${doc.id}`" :prefetch="false">
<Icon name="edit" display="lg" />
<p class="hint-tooltip">Edit</p>
</NuxtLink>
@@ -42,7 +43,7 @@ import RemoveSharedNode from '~/components/Node/RemoveSharedNode.modal.vue';
import { generateMarkdownWithMetadata } from '~/helpers/node';
import type { Node } from '~/stores';
-const props = defineProps<{ doc: Node }>();
+const props = defineProps<{ doc: Node; isPublic?: boolean }>();
const nodeStore = useNodesStore();
const router = useRouter();
diff --git a/frontend/public/app-icons/chevron_right.svg b/frontend/public/app-icons/chevron_right.svg
new file mode 100644
index 00000000..6ef05e11
--- /dev/null
+++ b/frontend/public/app-icons/chevron_right.svg
@@ -0,0 +1 @@
+<svg viewBox="0 -960 960 960"><path d="M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"/></svg>
\ No newline at end of file