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.

Improve sidebar workspaces and quick buttons

Smaug6739553a1f1de39e
diff --git a/frontend/app/components/Sidebar/Sidebar.vue b/frontend/app/components/Sidebar/Sidebar.vue
index ddb19c22..436d23c6 100644
--- a/frontend/app/components/Sidebar/Sidebar.vue
+++ b/frontend/app/components/Sidebar/Sidebar.vue
@@ -10,7 +10,7 @@
</span>
<IconClose class="btn" />
</section>
- <input type="text" placeholder="Search or ctrl + q" class="search" v-model="filter" />
+ <input type="text" placeholder="Search or ctrl + q" v-model="filter" />
<div class="user" v-if="userStore.user">
<img :src="useAvatar(userStore.user)" alt="Avatar" style="width: 25px; height: 25px; border-radius: 50%" />
@@ -52,7 +52,7 @@ const preferences = usePreferences();
const userStore = useUserStore();
const filter = ref<string>('');
const showSearchModal = ref<boolean>(false);
-const workspaces = computed(() => [{ text: 'All workspaces', value: null }, ...categoriesStore.categories.filter(c => c.role === 2).map(c => ({ text: c.name, value: c.id, meta: c }))]);
+const workspaces = computed(() => [...categoriesStore.categories.filter(c => c.role === 2).map(c => ({ text: c.name, value: c.id, meta: c }))]);
const handleSearchShortCut = (e: KeyboardEvent) => {
if (e.ctrlKey && e.key === 'q') showSearchModal.value = !showSearchModal.value;
@@ -151,14 +151,13 @@ onBeforeUnmount(() => {
}
}
}
-.search {
- height: 28px;
+input {
+ height: 30px;
margin: 2.5px 0;
border-radius: 6px;
border: 1px solid var(--border-color);
- width: 98%;
+ width: 100%;
outline: none;
- background-color: var(--bg-contrast);
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="%235b5967" height="24" viewBox="0 -960 960 960" width="22"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>');
background-repeat: no-repeat;
background-position: 5px;
diff --git a/frontend/app/components/Sidebar/SidebarItem.vue b/frontend/app/components/Sidebar/SidebarItem.vue
index 05ba1036..1f481f21 100644
--- a/frontend/app/components/Sidebar/SidebarItem.vue
+++ b/frontend/app/components/Sidebar/SidebarItem.vue
@@ -99,12 +99,9 @@ const drop = async (event: DragEvent) => {
padding: 1px 4px;
margin: 2.5px 0;
border-radius: 6px;
- color: var(--font-color);
- cursor: pointer;
width: 98%;
font-size: 15.2px;
font-weight: 500;
- letter-spacing: -0.5px;
&:hover,
&:has(.router-link-exact-active:not(.nav)) {
background: var(--bg-contrast-2);
diff --git a/frontend/app/components/Sidebar/SidebarWorkspace.vue b/frontend/app/components/Sidebar/SidebarWorkspace.vue
index 40d95250..2aabfa7a 100644
--- a/frontend/app/components/Sidebar/SidebarWorkspace.vue
+++ b/frontend/app/components/Sidebar/SidebarWorkspace.vue
@@ -1,27 +1,22 @@
<template>
<div>
- <svg xmlns="http://www.w3.org/2000/svg" height="22px" viewBox="0 -960 960 960" width="22px" fill="var(--font-color)" :class="option.meta?.color ? getAppColor(option.meta?.color) : ''">
- <path
- d="M200-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-640v560h560v-560h-80v245q0 12-10 17.5t-20-.5l-49-30q-10-6-21-6t-21 6l-49 30q-10 6-20 .5T480-515v-245H200Zm0 560v-560 560Z"
- />
- </svg>
+ <Icon :name="option.meta?.icon || 'workspace'" size="22" :class="option.meta?.color ? getAppColor(option.meta?.color) : '' + 'icon'" />
&nbsp; {{ option.text }}
</div>
</template>
<script setup lang="ts">
import type { Workspace } from './helpers';
-defineProps<{
- option: Workspace;
-}>();
+defineProps<{ option: Workspace }>();
</script>
<style scoped lang="scss">
div {
display: flex;
align-items: center;
+ font-weight: 500;
}
-svg {
+.icon {
padding: 1px;
border-radius: 5px;
}
diff --git a/frontend/app/components/Sidebar/SidebarWorkspaces.vue b/frontend/app/components/Sidebar/SidebarWorkspaces.vue
index d9b77398..729c26a8 100644
--- a/frontend/app/components/Sidebar/SidebarWorkspaces.vue
+++ b/frontend/app/components/Sidebar/SidebarWorkspaces.vue
@@ -1,28 +1,39 @@
<template>
<div class="dropdown-container" @click="toggleDropdown">
<div class="dropdown-selected" :class="{ open: isOpen }">
- <span v-if="selectedOption"><AppSelectOption :option="selectedOption" /></span>
- <span class="dropdown-arrow"></span>
+ <span v-if="selectedOption"><SidebarWorkspace :option="selectedOption" /></span>
+ <Icon name="expand" :small="true" />
</div>
<ul v-show="isOpen" class="dropdown-options">
- <li v-for="option in options" :class="{ selected: option.value === workspaceId }" @click="selectOption(option)">
- <AppSelectOption :option="option" />
+ <li :class="{ selected: all_workspaces.value === workspaceId }" @click="selectOption(all_workspaces)">
+ <SidebarWorkspace :option="all_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-if="options.length" v-for="option in options" :class="{ selected: option.value === workspaceId }" @click="selectOption(option)" :key="option.meta?.id">
+ <SidebarWorkspace :option="option" />
+ </li>
+ <div v-else class="placeholder" style="padding: 6px; font-size: 0.9rem; font-style: italic">No workspaces found</div>
+ <hr />
+ <div @click="create_workspace" class="new-workspace"><Icon name="plus" fill="var(--font-color-light)" /> New Workspace</div>
</ul>
</div>
</template>
<script setup lang="ts">
-import AppSelectOption from './SidebarWorkspace.vue';
+import SidebarWorkspace from './SidebarWorkspace.vue';
+import NewCategoryModal from '@/pages/dashboard/categories/_modals/CreateCategoryModal.vue';
+
import type { Workspace } from './helpers';
const { workspaceId } = useSidebar();
const storage_item = localStorage.getItem('filterWorkspace');
const props = defineProps<{ options: Workspace[] }>();
+const all_workspaces = ref({ text: 'All Workspaces', value: null });
if (storage_item && props.options.find(option => option.value == storage_item)) workspaceId.value = storage_item;
const isOpen = ref(false);
-const selectedOption = computed(() => props.options.find(option => option.value == workspaceId.value) || props.options.find(option => !option.value));
+const selectedOption = computed(() => props.options.find(option => option.value == workspaceId.value) || all_workspaces.value);
const toggleDropdown = () => (isOpen.value = !isOpen.value);
const closeDropdown = () => (isOpen.value = false);
@@ -36,6 +47,7 @@ const handleClickOutside = (event: MouseEvent) => {
};
onMounted(() => document.addEventListener('click', handleClickOutside));
onBeforeUnmount(() => document.removeEventListener('click', handleClickOutside));
+const create_workspace = (_: MouseEvent) => useModal().add(new Modal(shallowRef(NewCategoryModal), { role: 2 }));
</script>
<style scoped lang="scss">
@@ -63,25 +75,11 @@ onBeforeUnmount(() => document.removeEventListener('click', handleClickOutside))
box-shadow: 0 2px 10px var(--shadow);
}
-.dropdown-arrow {
- width: 8px;
- height: 8px;
- border: solid var(--font-color);
- border-width: 0 2px 2px 0;
- padding: 4px;
- transform: rotate(-45deg);
- transition: transform 0.3s ease;
-}
-
-.dropdown-selected.open .dropdown-arrow {
- transform: rotate(45deg);
-}
-
.dropdown-options {
position: absolute;
- width: 95%;
+ width: 98%;
margin: 0;
- padding: 0;
+ padding: 2px 0;
list-style: none;
background-color: var(--bg-color);
border: 1px solid var(--border-color);
@@ -93,12 +91,27 @@ onBeforeUnmount(() => document.removeEventListener('click', handleClickOutside))
li {
padding: 4px;
+ margin: 1px 4px;
+ border-radius: 4px;
cursor: pointer;
}
li.selected,
li:hover {
background-color: var(--selection-color);
- color: var(--font-color);
+}
+.new-workspace {
+ display: flex;
+ align-items: center;
+ padding: 4px;
+ margin: 4px;
+ gap: 4px;
+ border-radius: 6px;
+ font-size: 0.9rem;
+ font-weight: 500;
+ cursor: pointer;
+ &:hover {
+ background-color: var(--selection-color);
+ }
}
</style>
diff --git a/frontend/app/pages/dashboard/categories/[id]/index.vue b/frontend/app/pages/dashboard/categories/[id]/index.vue
index e6728ae9..11ab6ed5 100644
--- a/frontend/app/pages/dashboard/categories/[id]/index.vue
+++ b/frontend/app/pages/dashboard/categories/[id]/index.vue
@@ -36,3 +36,18 @@ const documents = computed(() => {
return documents;
});
</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/categories/_modals/CreateCategoryModal.vue b/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue
index 923c2cac..e6f79709 100644
--- a/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue
+++ b/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue
@@ -3,16 +3,21 @@
<h2>New {{ role == 1 ? 'category' : 'workspace' }}</h2>
<label for="name">Name</label>
<input class="entry" type="text" v-model="category.name" required id="name" placeholder="Display name" />
- <label for="icon">Icon <AppHint text="SVG supported" /></label>
- <input class="entry" type="text" v-model="category.icon" id="icon" />
- <label for="color">Color</label>
- <AppColorPicker class="entry" v-model:selectedColor="category.color" id="color" :nullable="true" />
+
<label>Parent</label>
<div>
<AppSelect class="entry" v-model="category.parent_id" :items="categoriesItem" placeholder="Select a category parent" />
</div>
- <label for="order">Order <AppHint text="Order of the category in the sidebar" /></label>
- <input class="entry" type="number" v-model.number="category.order" id="order" placeholder="0" />
+ <div style="display: flex">
+ <div style="flex: 1; margin-right: 10px">
+ <label for="order">Order <AppHint text="Order of the category in the sidebar" /></label>
+ <input class="entry" type="number" v-model.number="category.order" id="order" placeholder="0" />
+ </div>
+ <div style="flex: 1; margin-left: 10px">
+ <label for="color">Color</label>
+ <AppColorPicker class="entry" v-model:selectedColor="category.color" id="color" :nullable="true" />
+ </div>
+ </div>
<div class="footer">
<AppButton @click="emit('close')" type="secondary">Cancel</AppButton>
<AppButton type="primary" @click="createCategory">Create</AppButton>