π 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
refactor: streamline component imports and improve code readability
Smaug67398a77d0950675
diff --git a/frontend/app/components/ContextMenuManager.vue b/frontend/app/components/ContextMenuManager.vueindex 31304b9d..812b315b 100644--- a/frontend/app/components/ContextMenuManager.vue+++ b/frontend/app/components/ContextMenuManager.vue@@ -28,18 +28,11 @@</template><script setup lang="ts">+const { isMobile } = useDevice();const contextMenu = useContextMenu();const menu = contextMenu.menu;-// Mobile detection-const mobileBreakpoint = 768;const windowWidth = ref(typeof window !== 'undefined' ? window.innerWidth : 1024);-const isMobile = computed(() => windowWidth.value < mobileBreakpoint);--function updateWindowWidth() {- windowWidth.value = window.innerWidth;-}-// Drag/Swipe handling for mobile sheetconst isDragging = ref(false);const dragStartY = ref(0);@@ -56,12 +49,12 @@ const sheetStyle = computed(() => {return {};});-function getClientY(e: TouchEvent | MouseEvent): number {- if ('touches' in e) {- return e.touches[0]?.clientY ?? 0;- }+const updateWindowWidth = () => (windowWidth.value = window.innerWidth);++const getClientY = (e: TouchEvent | MouseEvent): number => {+ if ('touches' in e) return e.touches[0]?.clientY ?? 0;return e.clientY;-}+};function onDragStart(e: TouchEvent | MouseEvent) {isDragging.value = true;@@ -69,7 +62,6 @@ function onDragStart(e: TouchEvent | MouseEvent) {dragCurrentY.value = dragStartY.value;if (!('touches' in e)) {- // Mouse events need global listenerswindow.addEventListener('mousemove', onDragMove);window.addEventListener('mouseup', onDragEnd);}@@ -80,8 +72,6 @@ function onDragMove(e: TouchEvent | MouseEvent) {dragCurrentY.value = getClientY(e);const deltaY = dragCurrentY.value - dragStartY.value;-- // Only allow dragging down (positive delta)sheetTranslateY.value = Math.max(0, deltaY);}@@ -97,15 +87,11 @@ function onDragEnd() {const threshold = 100; // pixels to trigger closeif (sheetTranslateY.value > threshold) {- // Close the menucontextMenu.close();}-- // Reset translatesheetTranslateY.value = 0;}-// Reset drag state when menu closeswatch(() => menu.value,newMenu => {diff --git a/frontend/app/components/Error.vue b/frontend/app/components/Error.vueindex 249c7d08..a066a7e0 100644--- a/frontend/app/components/Error.vue+++ b/frontend/app/components/Error.vue@@ -79,7 +79,7 @@ const handleError = computed(() => {margin-top: 20px;}-.error-illustration svg {+svg {width: 100%;max-width: 300px;height: auto;diff --git a/frontend/app/components/Icon.vue b/frontend/app/components/Icon.vueindex 414345ca..e08fa4f1 100644--- a/frontend/app/components/Icon.vue+++ b/frontend/app/components/Icon.vue@@ -14,12 +14,11 @@ const props = withDefaults(defineProps<{ name: string; fill?: string; display?:size: undefined,});+const isUnicode = (str: string) => Array.from(str).some(char => char.charCodeAt(0) > 255);+const isSpriteIcon = computed(() => {return typeof props.name === 'string' && props.name.length < 50 && !isUnicode(props.name);});-const isUnicode = (str: string) => {- return Array.from(str).some(char => char.charCodeAt(0) > 255);-};</script><style scoped lang="scss">diff --git a/frontend/app/components/Navbar.vue b/frontend/app/components/Navbar.vueindex a1ae6205..79827643 100644--- a/frontend/app/components/Navbar.vue+++ b/frontend/app/components/Navbar.vue@@ -28,9 +28,10 @@const { t } = useI18nT();const { isOpened, toggleSidebar } = useSidebar();const preferences = usePreferencesStore();+const commandCenter = useCommandCenter();const navbarItems = preferences.get('navbarItems');-const openCommandCenter = () => useCommandCenter().open();+const openCommandCenter = () => commandCenter.open();</script><style lang="scss" scoped>diff --git a/frontend/app/components/Node/ContainerView.vue b/frontend/app/components/Node/ContainerView.vueindex 01653e51..f9d1b361 100644--- a/frontend/app/components/Node/ContainerView.vue+++ b/frontend/app/components/Node/ContainerView.vue@@ -63,12 +63,7 @@/></div>- <NoContent- v-else-if="!nodesStore.isFetching"- style="width: 100%; height: 100%"- :title="t('nodes.container.noDocuments')"- :description="t('nodes.container.noDocumentsDescription')"- >+ <NoContent v-else-if="!nodesStore.isFetching" :title="t('nodes.container.noDocuments')" :description="t('nodes.container.noDocumentsDescription')"><NuxtLink to="/dashboard/docs/new"><AppButton type="link">{{ t('nodes.container.createNewDocument') }}</AppButton></NuxtLink>diff --git a/frontend/app/components/Node/Filter.vue b/frontend/app/components/Node/Filter.vueindex 008123cb..38e5b511 100644--- a/frontend/app/components/Node/Filter.vue+++ b/frontend/app/components/Node/Filter.vue@@ -56,7 +56,7 @@ import type { Node, SearchOptions } from '~/stores';const props = defineProps<{ nodes: Node[] }>();const emit = defineEmits<{ (e: 'update:nodes', v: Node[]): void }>();-const defaultOptions: SearchOptions = {+const DEFAULT_OPTIONS: SearchOptions = {query: '',sortType: 'descending',sortBy: 'created',@@ -65,7 +65,8 @@ const defaultOptions: SearchOptions = {const { t } = useI18nT();const store = useNodesStore();-const options = ref({ ...defaultOptions });++const options = ref({ ...DEFAULT_OPTIONS });const opened = ref<boolean>(false);const inputRef = ref<HTMLInputElement | null>(null);const root = ref<HTMLDivElement | null>(null);@@ -90,8 +91,11 @@ const toggle = () => {opened.value = !opened.value;if (opened.value) focusInput();};+const close = () => (opened.value = false);-const reset = () => (options.value = { ...defaultOptions });++const reset = () => (options.value = { ...DEFAULT_OPTIONS });+const focusInput = () => nextTick(() => inputRef.value?.focus());watchEffect(() => {diff --git a/frontend/app/components/Sidebar/Dock.vue b/frontend/app/components/Sidebar/Dock.vueindex 8b260994..5cb9981a 100644--- a/frontend/app/components/Sidebar/Dock.vue+++ b/frontend/app/components/Sidebar/Dock.vue@@ -31,12 +31,12 @@</template><script setup lang="ts">-import SettingsModal from '~/pages/dashboard/settings/modal.vue';+import SettingsModal from '~/pages/dashboard/settings/index.vue';const userStore = useUserStore();const openSettings = () => {- useModal().add(new Modal(shallowRef(SettingsModal), { props: {}, size: 'large', noPadding: true }));+ useModal().add(new Modal(shallowRef(SettingsModal), { props: { isModal: true }, size: 'large', noPadding: true }));};function closeDock() {usePreferencesStore().set('view_dock', false);diff --git a/frontend/app/components/Sidebar/Resizable.vue b/frontend/app/components/Sidebar/Resizable.vueindex 9a48f83b..7e792178 100644--- a/frontend/app/components/Sidebar/Resizable.vue+++ b/frontend/app/components/Sidebar/Resizable.vue@@ -38,6 +38,7 @@ function resize(event: MouseEvent) {else if (newWidth > maxWidth) newWidth = maxWidth;paneWidth.value = newWidth;}+function stopResize() {isResizing.value = false;document.removeEventListener('mousemove', resize);diff --git a/frontend/app/components/Sidebar/Sidebar.vue b/frontend/app/components/Sidebar/Sidebar.vueindex ce8b6283..90fa80b8 100644--- a/frontend/app/components/Sidebar/Sidebar.vue+++ b/frontend/app/components/Sidebar/Sidebar.vue@@ -58,15 +58,15 @@</template><script setup lang="ts">+import { navigationItems } from './helpers';+import { filterTreeByLabel } from '~/helpers/TreeBuilder';+import NewCategoryModal from '~/components/Node/Modals/CreateCategory.vue';+import SidebarSkeleton from './SidebarSkeleton.vue';+import Dock from './Dock.vue';import CollapseItem from './CollapseItem.vue';import SidebarWorkspaces from './SidebarWorkspaces.vue';import Resizable from './Resizable.vue';import IconClose from './IconClose.vue';-import SidebarSkeleton from './SidebarSkeleton.vue';-import { navigationItems } from './helpers';-import NewCategoryModal from '~/components/Node/Modals/CreateCategory.vue';-import Dock from './Dock.vue';-import { filterTreeByLabel } from '~/helpers/TreeBuilder';const nodesStore = useNodesStore();const preferences = usePreferencesStore();@@ -83,22 +83,21 @@ const compactMode = preferences.get('compactMode');const sidebarItemsPrefs = preferences.get('sidebarItems');const filter = ref<string>('');+const workspaces = computed(() => [...nodesStore.getAll.filter(c => c.role === 1).map(c => ({ text: c.name, value: c.id, meta: c }))]);const isLoading = computed(() => nodesStore.isFetching);--const toggleDock = () => preferences.set('view_dock', !preferences.get('view_dock').value);-const tree = computed(() => {if (!filter.value.trim()) return filtered.value;return filterTreeByLabel(filtered.value, filter.value);});+const toggleDock = () => preferences.set('view_dock', !preferences.get('view_dock').value);+const handleClickOutside = (e: MouseEvent) => {if (isOpened.value && e.target && !(e.target as Element).closest('.sidebar') && !(e.target as Element).closest('.open-sidebar')) isOpened.value = false;};-const newCategory = () => {- useModal().add(new Modal(shallowRef(NewCategoryModal), { props: { role: 2 } }));-};+const newCategory = () => useModal().add(new Modal(shallowRef(NewCategoryModal), { props: { role: 2 } }));+const onClick = () => {if (isMobile.value) isOpened.value = false;};diff --git a/frontend/app/components/Sidebar/SidebarItem.vue b/frontend/app/components/Sidebar/SidebarItem.vueindex 6d167a53..3b87d63e 100644--- a/frontend/app/components/Sidebar/SidebarItem.vue+++ b/frontend/app/components/Sidebar/SidebarItem.vue@@ -10,13 +10,15 @@@dragleave="dragLeave"@contextmenu.prevent="showContextMenu">+ <!-- Left icon --><Icon :fill="item.data.role == 3 ? 'var(--pink) !important' : undefined" :name="icon" :class="customClass" /> + <!-- Label --><NuxtLink v-if="item.onClick" class="close content" @click="item.onClick">{{ item.data.role == -1 ? t(item.label) : item.label }}</NuxtLink><NuxtLink v-else :to="item.route" class="close content">{{ item.data.role == -1 ? t(item.label) : item.label }}</NuxtLink>+ <!-- Right icons / actions --><Icon v-if="item.data.shared && level === 0" name="shared" fill="var(--text-secondary)" />-<NuxtLink v-if="item.data.role === 2 && canEdit" :to="`/dashboard/categories/${item.id}/edit`" class="nav close"><Icon name="settings" /></NuxtLink>@@ -24,6 +26,8 @@<Icon name="plus" /></NuxtLink><Icon v-if="item.data.order === -1" name="pin" fill="var(--text-secondary)" />++ <!-- Show collapse icon for parents --><slot /></span></template>diff --git a/frontend/app/components/Sidebar/SidebarSkeleton.vue b/frontend/app/components/Sidebar/SidebarSkeleton.vueindex ca440ec8..9d74c4cf 100644--- a/frontend/app/components/Sidebar/SidebarSkeleton.vue+++ b/frontend/app/components/Sidebar/SidebarSkeleton.vue@@ -6,9 +6,9 @@<div v-else class="empty-sidebar"><div class="icon"><svg fill="var(--text-secondary)" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">- <g id="SVGRepo_bgCarrier" stroke-width="0"></g>- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>- <g id="SVGRepo_iconCarrier">+ <g stroke-width="0"></g>+ <g stroke-linecap="round" stroke-linejoin="round"></g>+ <g><pathstroke-width="0"d="M3 20h18a1 1 0 0 0 .864-1.504l-7-12c-.359-.615-1.369-.613-1.729 0L9.866 12.1l-1.02-1.632A.998.998 0 0 0 8 10h-.001a1 1 0 0 0-.847.47l-5 8A1 1 0 0 0 3 20zM14 8.985 19.259 18h-5.704l-2.486-3.987L14 8.985zm-5.999 3.9L11.197 18H4.805l3.196-5.115zM6 8c1.654 0 3-1.346 3-3S7.654 2 6 2 3 3.346 3 5s1.346 3 3 3zm0-4a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"diff --git a/frontend/app/components/Sidebar/SidebarWorkspace.vue b/frontend/app/components/Sidebar/SidebarWorkspace.vueindex afdd2bbe..83a9e174 100644--- a/frontend/app/components/Sidebar/SidebarWorkspace.vue+++ b/frontend/app/components/Sidebar/SidebarWorkspace.vue@@ -1,5 +1,5 @@<template>- <div class="workspace-item">+ <div><span class="workspace-name"><Icon :name="option.meta?.icon || 'workspace'" size="22" :class="[getAppAccent(option.meta?.color), 'icon']" />{{ option.text }}@@ -19,7 +19,7 @@ const { getAppAccent } = useAppColors();</script><style scoped lang="scss">-.workspace-item {+div {display: flex;font-weight: 500;align-items: center;diff --git a/frontend/app/components/Sidebar/SidebarWorkspaces.vue b/frontend/app/components/Sidebar/SidebarWorkspaces.vueindex 5c706335..d8040139 100644--- a/frontend/app/components/Sidebar/SidebarWorkspaces.vue+++ b/frontend/app/components/Sidebar/SidebarWorkspaces.vue@@ -6,11 +6,11 @@<Icon name="expand" display="sm" /></div><ul v-if="isOpen" class="dropdown-options">- <li :class="{ selected: all_workspaces.value === workspaceId }" @click="selectOption(all_workspaces)">- <SidebarWorkspace :option="all_workspaces" />+ <li :class="{ selected: allWorkspaces.value === workspaceId }" @click="selectOption(allWorkspaces)">+ <SidebarWorkspace :option="allWorkspaces" /></li>- <li :class="{ selected: shared_workspaces.value === workspaceId }" @click="selectOption(shared_workspaces)">- <SidebarWorkspace :option="shared_workspaces" />+ <li :class="{ selected: sharedWorkspaces.value === workspaceId }" @click="selectOption(sharedWorkspaces)">+ <SidebarWorkspace :option="sharedWorkspaces" /></li><hr /><span class="workspaces-label">{{ t('components.sidebar.workspaces') }}</span>@@ -19,37 +19,44 @@</li><div v-if="!options.length" class="placeholder">{{ t('components.sidebar.noWorkspaces') }}</div><hr />- <div class="new-workspace" @click="create_workspace"><Icon name="plus" fill="var(--text-secondary)" /> {{ t('components.sidebar.newWorkspace') }}</div>- <NuxtLink :to="`/dashboard/categories/${selectedOption.value}/edit`" class="new-workspace"- ><Icon name="settings" fill="var(--text-secondary)" /> {{ t('components.sidebar.editWorkspace') }}</NuxtLink- >+ <div class="new-workspace" @click="createWorkspace"><Icon name="plus" fill="var(--text-secondary)" /> {{ t('components.sidebar.newWorkspace') }}</div>+ <NuxtLink :to="`/dashboard/categories/${selectedOption.value}/edit`" class="new-workspace">+ <Icon name="settings" fill="var(--text-secondary)" /> {{ t('components.sidebar.editWorkspace') }}+ </NuxtLink></ul></div></template><script setup lang="ts">import SidebarWorkspace from './SidebarWorkspace.vue';import NewCategoryModal from '~/components/Node/Modals/CreateCategory.vue';-import type { Workspace } from './helpers';+const props = defineProps<{ options: Workspace[] }>();+const { t } = useI18nT();const { workspaceId } = useSidebar();-const props = defineProps<{ options: Workspace[] }>();-const all_workspaces = computed(() => ({ text: t('components.sidebar.allWorkspaces'), value: undefined, meta: { color: -1 } }));-const shared_workspaces = computed(() => ({ text: t('components.sidebar.sharedWithMe'), value: 'shared', meta: { color: -1, icon: 'users' } }));++const isOpen = ref(false);++const allWorkspaces = computed(() => ({ text: t('components.sidebar.allWorkspaces'), value: undefined, meta: { color: -1 } }));+const sharedWorkspaces = computed(() => ({ text: t('components.sidebar.sharedWithMe'), value: 'shared', meta: { color: -1, icon: 'users' } }));+const selectedOption = computed(() => [...props.options, sharedWorkspaces.value].find(option => option.value == workspaceId.value) || allWorkspaces.value);+watch(() => props.options,opts => {const storage_item = localStorage.getItem('filterWorkspace');- if (storage_item && [...opts, shared_workspaces.value].find(option => option.value == storage_item)) {+ if (storage_item && [...opts, sharedWorkspaces.value].find(option => option.value == storage_item)) {workspaceId.value = storage_item;}},- { immediate: true }, // check also during mounting+ { immediate: true },);-const isOpen = ref(false);-const selectedOption = computed(() => [...props.options, shared_workspaces.value].find(option => option.value == workspaceId.value) || all_workspaces.value);++const createWorkspace = () => useModal().add(new Modal(shallowRef(NewCategoryModal), { props: { role: 1 } }));+const toggleDropdown = () => (isOpen.value = !isOpen.value);+const closeDropdown = () => (isOpen.value = false);const selectOption = (option: Workspace) => {@@ -60,9 +67,9 @@ const selectOption = (option: Workspace) => {const handleClickOutside = (event: MouseEvent) => {if (!(event.target as HTMLElement)!.closest('.dropdown-container')) closeDropdown();};+onMounted(() => document.addEventListener('click', handleClickOutside));onBeforeUnmount(() => document.removeEventListener('click', handleClickOutside));-const create_workspace = (_: MouseEvent) => useModal().add(new Modal(shallowRef(NewCategoryModal), { props: { role: 1 } }));</script><style scoped lang="scss">diff --git a/frontend/app/components/Sidebar/helpers.ts b/frontend/app/components/Sidebar/helpers.tsindex 9c134cd2..85dd2b9d 100644--- a/frontend/app/components/Sidebar/helpers.ts+++ b/frontend/app/components/Sidebar/helpers.ts@@ -1,7 +1,7 @@import type { TreeItem } from '~/helpers/TreeBuilder';import type { Node } from '~/stores';-import SettingsModal from '~/pages/dashboard/settings/modal.vue';+import SettingsModal from '~/pages/dashboard/settings/index.vue';export interface NavigationItem {data: {@@ -108,7 +108,7 @@ export const navigationItems = (sidebarItemsPrefs?: Preferences['sidebarItems'])label: 'components.sidebar.nav.settings',onClick: () => {if (isMobile.value) useRouter().push('/dashboard/settings');- else useModal().add(new Modal(shallowRef(SettingsModal), { noPadding: true, props: {}, size: 'large' }));+ else useModal().add(new Modal(shallowRef(SettingsModal), { noPadding: true, props: { isModal: true }, size: 'large' }));},parent_id: '',route: '',diff --git a/frontend/app/pages/dashboard/categories.vue b/frontend/app/pages/dashboard/categories.vueindex 1b64a0ac..d1d2268c 100644--- a/frontend/app/pages/dashboard/categories.vue+++ b/frontend/app/pages/dashboard/categories.vue@@ -1,7 +1,7 @@<template>- <NuxtPage />+ <NuxtPage /></template><script setup lang="ts">-definePageMeta({ breadcrumb: {c: 2, i18n: 'nodes.category.name'} });+definePageMeta({ breadcrumb: { i18n: 'nodes.category.name' } });</script>diff --git a/frontend/app/pages/dashboard/docs.vue b/frontend/app/pages/dashboard/docs.vueindex 14e8fb4f..b4701238 100644--- a/frontend/app/pages/dashboard/docs.vue+++ b/frontend/app/pages/dashboard/docs.vue@@ -1,7 +1,7 @@<template>- <NuxtPage />+ <NuxtPage /></template><script setup lang="ts">-definePageMeta({ breadcrumb: {c:2, i18n: 'nodes.types.document'} });+definePageMeta({ breadcrumb: { i18n: 'nodes.types.document' } });</script>diff --git a/frontend/app/pages/dashboard/import/index.vue b/frontend/app/pages/dashboard/import/index.vueindex d6cece32..270ec15a 100644--- a/frontend/app/pages/dashboard/import/index.vue+++ b/frontend/app/pages/dashboard/import/index.vue@@ -3,7 +3,7 @@<!-- Step 1: File Selection --><div v-if="step === 'select'"><header>- <h1 style="font-size: 20px">{{ t('import.meta.title') }} <tag class="yellow">Beta</tag></h1>+ <h1 style="font-size: 20px">{{ t('import.meta.title') }} <tag class="orange">Beta</tag></h1></header><p>{{ t('import.meta.description') }}diff --git a/frontend/app/pages/dashboard/settings/_views/security.vue b/frontend/app/pages/dashboard/settings/_views/security.vueindex bd09d561..b18ab0f1 100644--- a/frontend/app/pages/dashboard/settings/_views/security.vue+++ b/frontend/app/pages/dashboard/settings/_views/security.vue@@ -237,14 +237,6 @@ p {gap: 1rem;margin-bottom: 1.5rem;- svg {- width: 24px;- height: 24px;- color: var(--orange);- flex-shrink: 0;- margin-top: 0.15rem;- }-strong {display: block;color: var(--orange-dark);@@ -308,11 +300,6 @@ p {height: 24px;align-items: center;justify-content: center;-- :deep(svg) {- width: 100%;- height: 100%;- }}.oidc-name {diff --git a/frontend/app/pages/dashboard/settings/modal.vue b/frontend/app/pages/dashboard/settings/modal.vuedeleted file mode 100644index ea0bee3c..00000000--- a/frontend/app/pages/dashboard/settings/modal.vue+++ /dev/null@@ -1,72 +0,0 @@-<template>- <IndexSettings class="component" :is-modal="true" />-</template>--<script setup lang="ts">-import IndexSettings from './index.vue';-</script>--<style scoped lang="scss">-.component {- display: flex;- width: 100%;- max-width: 1150px;- height: 715px;- max-height: 90vh;- border-radius: var(--radius-md);-- nav {- padding: 1rem;- background-color: var(--surface-raised) !important;- border-bottom-left-radius: 8px;- border-top-left-radius: 8px;- gap: 1rem;- overflow-y: auto;-- span {- font-size: 0.9rem;- font-weight: 500;- color: var(--text-secondary);- }-- a {- display: flex;- margin: 0.2rem;- padding: 0.2rem 0.4rem;- border-radius: var(--radius-sm);- color: inherit;- align-items: center;- gap: 0.5rem;- text-decoration: none;-- &:hover {- background-color: var(--surface-overlay);- }- }-- .title {- display: block !important;- }-- .user {- display: flex !important;- align-items: center;-- div {- font-size: 0.8rem;- margin-left: 5px;-- .email {- font-size: 0.7rem;- color: var(--text-secondary);- }- }- }- }-- .content {- margin: 0.5rem;- padding: 1rem 2rem;- }-}-</style>