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.

Export same pages into a component: NodeList

Smaug673987a208e12cf6
diff --git a/frontend/app/components/Node/NodeList.vue b/frontend/app/components/Node/NodeList.vue
new file mode 100644
index 00000000..d2d37613
--- /dev/null
+++ b/frontend/app/components/Node/NodeList.vue
@@ -0,0 +1,91 @@
+<template>
+ <div class="card-component">
+ <header>
+ <h1 v-if="parent">
+ <Icon :name="parent.icon || parent?.icon || 'files'" :class="`parent-icon ${getAppColor(parent.color || parent?.color as number, true)}`" />
+ {{ parent.name }}
+ </h1>
+ <h1 v-else-if="parentId === 'shared'">
+ <Icon name="users" :class="`parent-icon grey`" />
+ All workspaces
+ </h1>
+ <h1 v-else>
+ <Icon name="workspace" :class="`parent-icon primary`" />
+ All workspaces
+ </h1>
+ <div style="display: flex; align-items: center; gap: 8px">
+ <NuxtLink v-if="parent" @click="openPermissionsModal"><Icon name="manage_access" :big="true" fill="var(--font-color)" /></NuxtLink>
+ <NuxtLink v-if="parent" :to="`/dashboard/categories/${parent?.id}/edit`"><Icon name="settings" :big="true" fill="var(--font-color)" /></NuxtLink>
+ <span class="doc-count">{{ nodes.length }}</span>
+ <ViewSelection v-model="view" />
+ </div>
+ </header>
+ <div v-if="nodes.length">
+ <div v-if="view == 'table'" class="line-container">
+ <DocumentLine v-for="document of nodes" :key="document.id" :document="document" class="line-item" />
+ </div>
+ <div v-else class="document-list">
+ <DocumentsGrid :documents="nodes" />
+ </div>
+ </div>
+ <NoContent
+ v-else-if="!nodesStore.isFetching"
+ style="width: 100%; height: 100%"
+ title="No documents found"
+ description="There are no documents in this category"
+ ><NuxtLink to="/dashboard/docs/new"><AppButton type="link" style="font-weight: bold">+ Create new document </AppButton></NuxtLink>
+ </NoContent>
+ </div>
+</template>
+
+<script setup lang="ts">
+import NodePermissions from '@/components/Node/NodePermissions.modal.vue';
+import type { Node } from '~/stores';
+
+const props = defineProps<{ parent?: Node; nodes: Node[]; parentId?: string }>();
+const nodesStore = useNodesStore();
+
+const view: Ref<'table' | 'list'> = ref('list');
+
+const openPermissionsModal = () => {
+ if (props.parent) useModal().add(new Modal(shallowRef(NodePermissions), { props: { node: props.parent }, size: 'small' }));
+};
+</script>
+
+<style scoped lang="scss">
+h1 {
+ display: flex;
+ align-items: center;
+}
+
+.doc-count {
+ font-weight: bold;
+ font-size: 1rem;
+ border-radius: 4px;
+ padding: 4px 6px;
+ border: 1px solid var(--border-color);
+}
+
+.parent-icon {
+ width: 30px;
+ height: 30px;
+ padding: 6px;
+ border-radius: 6px;
+ margin-right: 10px;
+}
+
+.line-container {
+ display: flex;
+ flex-direction: column;
+}
+
+.line-item:first-child {
+ border-top-left-radius: 12px;
+ border-top-right-radius: 12px;
+}
+
+.line-item:last-child {
+ border-bottom-left-radius: 12px;
+ border-bottom-right-radius: 12px;
+}
+</style>
diff --git a/frontend/app/pages/dashboard/categories/[id]/index.vue b/frontend/app/pages/dashboard/categories/[id]/index.vue
index c088aae8..e2940f22 100644
--- a/frontend/app/pages/dashboard/categories/[id]/index.vue
+++ b/frontend/app/pages/dashboard/categories/[id]/index.vue
@@ -1,71 +1,24 @@
<template>
- <div class="card-component">
- <header>
- <h1 style="font-size: 20px">Documents of category <tag class="blue">New</tag></h1>
- <div style="display: flex; align-items: center; gap: 8px">
- <NuxtLink @click="openPermissionsModal"><Icon name="manage_access" :big="true" fill="var(--font-color)" /></NuxtLink>
- <NuxtLink :to="`/dashboard/categories/${node?.id}/edit`"><Icon name="settings" :big="true" fill="var(--font-color)" /></NuxtLink>
- <ViewSelection v-model="view" />
- </div>
- </header>
- <div v-if="documents.length">
- <div v-if="view == 'table'" class="line-container">
- <DocumentLine v-for="document of documents" :key="document.id" :document="document" class="line-item" />
- </div>
- <div v-else class="document-list">
- <DocumentsGrid :documents="documents" />
- </div>
- </div>
- <NoContent v-else style="width: 100%; height: 100%" title="No documents found" description="There are no documents in this category"
- ><NuxtLink to="/dashboard/docs/new"><AppButton type="link" style="font-weight: bold">+ Create new document </AppButton></NuxtLink>
- </NoContent>
- </div>
+ <NodeList :parent="parent" :nodes="nodes" />
</template>
<script setup lang="ts">
-import NodePermissions from '@/components/Node/NodePermissions.modal.vue';
+import NodeList from '@/components/Node/NodeList.vue';
import type { Node } from '~/stores';
+
const route = useRoute();
-const categoryId = route.params.id as string;
const nodesStore = useNodesStore();
-const view: Ref<'table' | 'list'> = ref('list');
-const node = ref<Node | undefined>();
-const error = ref<string>('');
-definePageMeta({
- breadcrumb: () => {
- const doc = useNodesStore().getById(useRoute().params.id as string);
- return doc?.name || '';
- },
-});
+const parentId = route.params.id as string;
+const parent = ref<Node | undefined>();
+
+definePageMeta({ breadcrumb: () => useNodesStore().getById(useRoute().params.id as string)?.name || '' });
watchEffect(async () => {
- node.value = nodesStore.getById(categoryId);
- if (!node.value) error.value = 'Document not found';
+ parent.value = nodesStore.getById(parentId);
});
-const openPermissionsModal = () => {
- if (node.value) useModal().add(new Modal(shallowRef(NodePermissions), { props: { node: node.value }, size: 'small' }));
-};
-
-const documents = computed(() => {
- return nodesStore.getAllChildrens(node.value?.id || '').filter(d => d.role == 3);
+const nodes = computed(() => {
+ return nodesStore.getAllChildrens(parent.value?.id || '').filter(d => d.role == 3);
});
</script>
-
-<style scoped lang="scss">
-.line-container {
- display: flex;
- flex-direction: column;
-}
-
-.line-item:first-child {
- border-top-left-radius: 12px;
- border-top-right-radius: 12px;
-}
-
-.line-item:last-child {
- border-bottom-left-radius: 12px;
- border-bottom-right-radius: 12px;
-}
-</style>
diff --git a/frontend/app/pages/dashboard/docs/index.vue b/frontend/app/pages/dashboard/docs/index.vue
index e8d145ec..835d4cf8 100644
--- a/frontend/app/pages/dashboard/docs/index.vue
+++ b/frontend/app/pages/dashboard/docs/index.vue
@@ -1,73 +1,28 @@
<template>
- <div class="card-component">
- <header>
- <h1 v-if="category">
- <Icon :name="category.icon || category?.icon || 'files'" :class="`category-icon ${getAppColor(category.color || category?.color as number, true)}`" />
- {{ category.name }}
- </h1>
- <h1 v-else>All documents</h1>
- <ViewSelection v-model="view" />
- </header>
- <template v-if="documents.length">
- <div v-if="view == 'table'" class="line-container">
- <DocumentLine v-for="document of documents" :key="document.id" :document="document" class="line-item" />
- </div>
- <DocumentsGrid v-else :documents="documents" />
- </template>
- <NoContent v-else title="No documents found" description="There are no documents here">
- <NuxtLink to="/dashboard/docs/new"><AppButton type="link" style="font-weight: bold">Create new one </AppButton></NuxtLink>
- </NoContent>
- </div>
+ <NodeList :parent="parent" :nodes="nodes" :parent-id="workspaceId" />
</template>
<script setup lang="ts">
+import NodeList from '@/components/Node/NodeList.vue';
import type { Node } from '~/stores';
-const { filtered, workspaceId } = useSidebar();
const nodesStore = useNodesStore();
-const view: Ref<'table' | 'list'> = ref('list');
-const category = computed(() => nodesStore.getById(workspaceId.value || ''));
-const documents = computed(() => {
+const { filtered, workspaceId } = useSidebar();
+
+const parent = computed(() => nodesStore.getById(workspaceId.value || ''));
+definePageMeta({
+ breadcrumb: () => 'All',
+});
+
+const nodes = computed(() => {
const result: Node[] = [];
- const getDocs = (items: Item[]) => {
+ const getNodes = (items: Item[]) => {
for (const item of items) {
if (item.data.role == 3) result.push(item.data);
- if (item.childrens) getDocs(item.childrens);
+ if (item.childrens) getNodes(item.childrens);
}
};
- getDocs(filtered.value);
+ getNodes(filtered.value);
return result;
});
</script>
-
-<style scoped lang="scss">
-h1 {
- display: flex;
- align-items: center;
-}
-
-.category-icon {
- width: 30px;
- height: 30px;
- padding: 6px;
- border-radius: 6px;
- margin-right: 10px;
-}
-
-.line-container {
- display: flex;
- flex-direction: column;
-}
-
-.line-item:first-child {
- border-top: 1px solid var(--border-color);
- border-top-left-radius: 12px;
- border-top-right-radius: 12px;
-}
-
-.line-item:last-child {
- border-bottom: 1px solid var(--border-color);
- border-bottom-left-radius: 12px;
- border-bottom-right-radius: 12px;
-}
-</style>