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.

feat: add expand all button on sidebar

Smaug6739902afdaf8275
diff --git a/frontend/app/components/Sidebar/Sidebar.vue b/frontend/app/components/Sidebar/Sidebar.vue
index eaca366e..1c85fd63 100644
--- a/frontend/app/components/Sidebar/Sidebar.vue
+++ b/frontend/app/components/Sidebar/Sidebar.vue
@@ -28,10 +28,14 @@
><Icon name="add_folder" />
<p class="hint-tooltip">New category</p></NuxtLink
>
- <NuxtLink class="nav-item" @click="sidebarTree.collapseAll"
+ <NuxtLink v-if="!sidebarTree.isCollapsed()" class="nav-item" @click="sidebarTree.collapseAll"
><Icon name="collapse" />
<p class="hint-tooltip">Close all</p></NuxtLink
>
+ <NuxtLink v-else class="nav-item" @click="sidebarTree.expandAll"
+ ><Icon name="arrow-expand" />
+ <p class="hint-tooltip">Open all</p></NuxtLink
+ >
<NuxtLink class="nav-item" @click="toggleDock"
><Icon name="dock" />
<p class="hint-tooltip">Toggle dock</p></NuxtLink
diff --git a/frontend/app/composables/useCollapseStates.ts b/frontend/app/composables/useCollapseStates.ts
index 40522cf0..7134268f 100644
--- a/frontend/app/composables/useCollapseStates.ts
+++ b/frontend/app/composables/useCollapseStates.ts
@@ -45,6 +45,17 @@ function collapseAllStates() {
saveStates();
}
+/** Expand all items */
+function expandAllStates() {
+ Object.keys(states).forEach(key => (states[key] = true));
+ saveStates();
+}
+
+/* Is all collapsed */
+function isAllCollapsed() {
+ return Object.values(states).every(state => state === false);
+}
+
/** Access the raw reactive states object */
export function useCollapseStates() {
return {
@@ -52,5 +63,7 @@ export function useCollapseStates() {
setCollapseState,
toggleCollapseState,
collapseAllStates,
+ expandAllStates,
+ isAllCollapsed,
};
}
diff --git a/frontend/app/composables/useNodesTree.ts b/frontend/app/composables/useNodesTree.ts
index 70c6eb10..54991886 100644
--- a/frontend/app/composables/useNodesTree.ts
+++ b/frontend/app/composables/useNodesTree.ts
@@ -11,7 +11,15 @@ const tree = computed(() => {
return structure.value.generateTree();
});
+/* Collapse operations */
const collapseAll = collapse.collapseAllStates;
+
+const expandAll = collapse.expandAllStates;
+
+const isCollapsed = collapse.isAllCollapsed;
+
+/* Get subtree by id as a flat array */
+
const getSubTreeById = (id: string) => {
return structure.value.treeToArray(structure.value.getSubTreeById(id)?.childrens || []);
};
@@ -86,6 +94,8 @@ function useSidebarTree() {
structure,
nodes,
collapseAll,
+ expandAll,
+ isCollapsed,
getSubTreeById,
groupedByWorkspace,
getCategoryFromNode,
diff --git a/frontend/public/app-icons/arrow-expand.svg b/frontend/public/app-icons/arrow-expand.svg
new file mode 100644
index 00000000..4726997a
--- /dev/null
+++ b/frontend/public/app-icons/arrow-expand.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M320-500h320L480-660 320-500ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-200v120h560v-120H200Zm0-80h560v-360H200v360Zm0 80v120-120Z"/></svg>
\ No newline at end of file