From f49bb98b926975a3bb0e97fa819bc8e89d400957 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Fri, 12 Dec 2025 16:25:45 +0530 Subject: [PATCH] fix: sidebar improvements --- .../CommandPalette/CommandPalette.vue | 14 ++++-- .../src/components/Sidebar/AppSidebar.vue | 43 ++++++------------- frontend/src/utils/index.js | 1 - 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/frontend/src/components/CommandPalette/CommandPalette.vue b/frontend/src/components/CommandPalette/CommandPalette.vue index 6fd6a02d..a32cbb00 100644 --- a/frontend/src/components/CommandPalette/CommandPalette.vue +++ b/frontend/src/components/CommandPalette/CommandPalette.vue @@ -10,7 +10,6 @@ placeholder="Search" class="w-full border-none bg-transparent py-3 !pl-2 pr-4.5 text-base text-ink-gray-7 placeholder-ink-gray-4 focus:ring-0" @input="onInput" - @keydown="onKeyDown" v-model="query" autocomplete="off" /> @@ -108,7 +107,7 @@ const onInput = () => { const generateSearchResults = () => { search.data?.forEach((type: any) => { - let result = {} + let result: { title: string; items: any[] } = { title: '', items: [] } result.title = type.title type.items.forEach((item: any) => { let paramName = item.doctype === 'LMS Course' ? 'courseName' : 'batchName' @@ -126,7 +125,10 @@ const generateSearchResults = () => { } const appendSearchPage = () => { - let searchPage = {} + let searchPage: { title: string; items: Array } = { + title: '', + items: [], + } searchPage.title = __('Jump to') searchPage.items = [ { @@ -212,7 +214,11 @@ const shortcutForEnter = () => { } } -const navigateTo = (route: string) => { +const navigateTo = (route: { + name: string + params?: Record + query?: Record +}) => { show.value = false query.value = '' router.replace({ name: route.name, params: route.params, query: route.query }) diff --git a/frontend/src/components/Sidebar/AppSidebar.vue b/frontend/src/components/Sidebar/AppSidebar.vue index cdc8c94e..fbb95344 100644 --- a/frontend/src/components/Sidebar/AppSidebar.vue +++ b/frontend/src/components/Sidebar/AppSidebar.vue @@ -250,8 +250,7 @@ const showPageModal = ref(false) const isModerator = ref(false) const isInstructor = ref(false) const pageToEdit = ref(null) -const { settings, sidebarSettings, activeTab, isSettingsOpen, programs } = - useSettings() +const { sidebarSettings, activeTab, isSettingsOpen, programs } = useSettings() const settingsStore = useSettings() const showOnboarding = ref(false) const showIntermediateModal = ref(false) @@ -286,9 +285,6 @@ const setSidebarLinks = () => { (item) => item.label.toLowerCase().split(' ').join('_') !== key ) }) - /* sidebarLinks.value = sidebarLinks.value?.items.filter( - (link) => link.label.toLowerCase().split(' ').join('_') !== key - ) */ } }) }, @@ -327,32 +323,18 @@ const unreadNotifications = createResource({ }, onSuccess(data) { unreadCount.value = data - /* sidebarLinks.value = sidebarLinks.value.map((link) => { - if (link.label === 'Notifications') { - link.count = data - } - return link - }) */ + updateUnreadCount() }, auto: user ? true : false, }) -const addPrograms = async () => { - const programsLinkExists = sidebarLinks.value.some( - (link) => link.label === 'Programs' - ) - if (programsLinkExists) return - - let canAddProgram = await checkIfCanAddProgram() - if (!canAddProgram) return - let activeFor = ['Programs', 'ProgramDetail'] - let index = 2 - - sidebarLinks.value.splice(index, 0, { - label: 'Programs', - icon: 'Route', - to: 'Programs', - activeFor: activeFor, +const updateUnreadCount = () => { + sidebarLinks.value?.forEach((link) => { + link.items.forEach((item) => { + if (item.label === 'Notifications') { + item.count = unreadCount.value || 0 + } + }) }) } @@ -602,15 +584,14 @@ const setUpOnboarding = () => { watch(userResource, async () => { await userResource.promise - sidebarLinks.value = getSidebarLinks() - setSidebarLinks() if (userResource.data) { isModerator.value = userResource.data.is_moderator isInstructor.value = userResource.data.is_instructor - await programs.promise - sidebarLinks.value = getSidebarLinks() + await programs.reload() setUpOnboarding() } + sidebarLinks.value = getSidebarLinks() + setSidebarLinks() }) const redirectToWebsite = () => { diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index d18bc98a..b7b1d817 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -567,7 +567,6 @@ const checkIfCanAddProgram = () => { if (userResource?.data?.is_moderator || userResource?.data?.is_instructor) { return true } - console.log('programs.data', programs.data) return ( programs.data?.enrolled.length > 0 || programs.data?.published.length > 0