feat: Hide empty folders from sidebar (#10786)

This PR updates the sidebar to hide empty folders. So, in case the user
has not created any folders, or teams, the section in the sidebar will
be hidden
This commit is contained in:
Shivam Mishra
2025-01-31 06:33:12 +05:30
committed by GitHub
parent 55f1690d9e
commit b811c27ab5

View File

@@ -2,7 +2,6 @@
import { computed, ref } from 'vue';
import SidebarGroupLeaf from './SidebarGroupLeaf.vue';
import SidebarGroupSeparator from './SidebarGroupSeparator.vue';
import SidebarGroupEmptyLeaf from './SidebarGroupEmptyLeaf.vue';
import { useSidebarContext } from './provider';
import { useEventListener } from '@vueuse/core';
@@ -26,11 +25,6 @@ const accessibleItems = computed(() =>
);
const hasAccessibleItems = computed(() => {
if (props.children.length === 0) {
// cases like segment, folder and labels where users can create new items
return true;
}
return accessibleItems.value.length > 0;
});
@@ -55,7 +49,7 @@ useEventListener(scrollableContainer, 'scroll', () => {
:icon
class="my-1"
/>
<ul class="m-0 list-none reset-base relative group">
<ul v-if="children.length" class="m-0 list-none reset-base relative group">
<!-- Each element has h-8, which is 32px, we will show 7 items with one hidden at the end,
which is 14rem. Then we add 16px so that we have some text visible from the next item -->
<div
@@ -64,16 +58,13 @@ useEventListener(scrollableContainer, 'scroll', () => {
'max-h-[calc(14rem+16px)] overflow-y-scroll no-scrollbar': isScrollable,
}"
>
<template v-if="children.length">
<SidebarGroupLeaf
v-for="child in children"
v-show="isExpanded || activeChild?.name === child.name"
v-bind="child"
:key="child.name"
:active="activeChild?.name === child.name"
/>
</template>
<SidebarGroupEmptyLeaf v-else v-show="isExpanded" class="ml-3 rtl:mr-3" />
<SidebarGroupLeaf
v-for="child in children"
v-show="isExpanded || activeChild?.name === child.name"
v-bind="child"
:key="child.name"
:active="activeChild?.name === child.name"
/>
</div>
<div
v-if="isScrollable && isExpanded"