From 705a08ae208448e503397eb704a2217869e716a1 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Mon, 11 Dec 2023 22:35:51 +0100 Subject: [PATCH] feat: move sidebar toggle button into the topbar --- .../src/components/AppBar/SidebarToggle.vue | 1 + packages/web-pkg/src/components/AppTopBar.vue | 22 ++----------------- .../__snapshots__/AppTopBar.spec.ts.snap | 5 ----- .../src/components/Topbar/TopBar.vue | 17 +++++++++++--- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/packages/web-pkg/src/components/AppBar/SidebarToggle.vue b/packages/web-pkg/src/components/AppBar/SidebarToggle.vue index d39a702b9b5..191745d42f9 100644 --- a/packages/web-pkg/src/components/AppBar/SidebarToggle.vue +++ b/packages/web-pkg/src/components/AppBar/SidebarToggle.vue @@ -17,6 +17,7 @@ import { eventBus } from '../../services/eventBus' import { SideBarEventTopics } from '../../composables/sideBar' export default defineComponent({ + name: 'SidebarToggle', props: { isSideBarOpen: { type: Boolean, diff --git a/packages/web-pkg/src/components/AppTopBar.vue b/packages/web-pkg/src/components/AppTopBar.vue index 8105f168143..4da6f8e5872 100644 --- a/packages/web-pkg/src/components/AppTopBar.vue +++ b/packages/web-pkg/src/components/AppTopBar.vue @@ -73,10 +73,6 @@ - - {{ isSideBarOpen }} - - @@ -85,14 +81,7 @@ import { computed, defineComponent, PropType, unref } from 'vue' import ContextActionMenu from './ContextActions/ContextActionMenu.vue' import { useGettext } from 'vue3-gettext' -import { - Action, - SideBarEventTopics, - useEventBus, - useFolderLink, - useGetMatchingSpace, - useSideBar -} from '../composables' +import { Action, useEventBus, useFolderLink, useGetMatchingSpace } from '../composables' import { Resource, isPublicSpaceResource, @@ -149,20 +138,13 @@ export default defineComponent({ return props.resource ? getParentFolderLinkIconAdditionalAttributes(props.resource) : null }) - const toggleSideBar = () => { - eventBus.publish(SideBarEventTopics.toggle) - } - const { isSideBarOpen } = useSideBar() - return { pathPrefix, isPathDisplayed, contextMenuLabel, closeButtonLabel, parentFolderName, - parentFolderLinkIconAdditionalAttributes, - isSideBarOpen, - toggleSideBar + parentFolderLinkIconAdditionalAttributes } } }) diff --git a/packages/web-pkg/tests/unit/components/__snapshots__/AppTopBar.spec.ts.snap b/packages/web-pkg/tests/unit/components/__snapshots__/AppTopBar.spec.ts.snap index e6df7fb5b6c..e1f85b08fd4 100644 --- a/packages/web-pkg/tests/unit/components/__snapshots__/AppTopBar.spec.ts.snap +++ b/packages/web-pkg/tests/unit/components/__snapshots__/AppTopBar.spec.ts.snap @@ -14,7 +14,6 @@ exports[`AppTopBar if a resource is present renders a resource and dropdownActio - `; @@ -33,7 +32,6 @@ exports[`AppTopBar if a resource is present renders a resource and dropdownActio - `; @@ -51,7 +49,6 @@ exports[`AppTopBar if a resource is present renders a resource and mainActions ( - `; @@ -69,7 +66,6 @@ exports[`AppTopBar if a resource is present renders a resource and no actions (i - `; @@ -87,7 +83,6 @@ exports[`AppTopBar if no resource is present renders only a close button 1`] = ` - `; diff --git a/packages/web-runtime/src/components/Topbar/TopBar.vue b/packages/web-runtime/src/components/Topbar/TopBar.vue index 0bb8cf41adc..75d8c5be15d 100644 --- a/packages/web-runtime/src/components/Topbar/TopBar.vue +++ b/packages/web-runtime/src/components/Topbar/TopBar.vue @@ -31,6 +31,12 @@ + @@ -54,9 +60,11 @@ import { useCapabilityNotifications, useEmbedMode, useRouter, + useSideBar, useStore, useThemeStore, - useUserContext + useUserContext, + SidebarToggle } from '@ownclouders/web-pkg' export default { @@ -65,7 +73,8 @@ export default { FeedbackLink, Notifications, ThemeSwitcher, - UserMenu + UserMenu, + SidebarToggle }, props: { applicationsList: { @@ -85,6 +94,7 @@ export default { const router = useRouter() const ability = useAbility() const { isEnabled: isEmbedModeEnabled } = useEmbedMode() + const { isSideBarOpen } = useSideBar() const logoWidth = ref('150px') const isNotificationBellEnabled = computed(() => { @@ -191,7 +201,8 @@ export default { userMenuItems, appMenuItems, logoWidth, - isEmbedModeEnabled + isEmbedModeEnabled, + isSideBarOpen } }, computed: {