2023-03-17 16:20:25 +05:30
|
|
|
<script>
|
2023-05-27 22:25:52 +05:30
|
|
|
import { GlButton, GlCollapse } from '@gitlab/ui';
|
|
|
|
import { __ } from '~/locale';
|
2023-06-20 00:43:36 +05:30
|
|
|
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
|
|
|
import {
|
|
|
|
sidebarState,
|
|
|
|
SUPER_SIDEBAR_PEEK_OPEN_DELAY,
|
|
|
|
SUPER_SIDEBAR_PEEK_CLOSE_DELAY,
|
|
|
|
} from '../constants';
|
|
|
|
import { toggleSuperSidebarCollapsed } from '../super_sidebar_collapsed_state_manager';
|
2023-03-17 16:20:25 +05:30
|
|
|
import UserBar from './user_bar.vue';
|
2023-05-27 22:25:52 +05:30
|
|
|
import SidebarPortalTarget from './sidebar_portal_target.vue';
|
2023-03-17 16:20:25 +05:30
|
|
|
import ContextSwitcherToggle from './context_switcher_toggle.vue';
|
|
|
|
import ContextSwitcher from './context_switcher.vue';
|
2023-04-23 21:23:45 +05:30
|
|
|
import HelpCenter from './help_center.vue';
|
2023-05-27 22:25:52 +05:30
|
|
|
import SidebarMenu from './sidebar_menu.vue';
|
2023-03-17 16:20:25 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2023-05-27 22:25:52 +05:30
|
|
|
GlButton,
|
2023-03-17 16:20:25 +05:30
|
|
|
GlCollapse,
|
|
|
|
UserBar,
|
|
|
|
ContextSwitcherToggle,
|
|
|
|
ContextSwitcher,
|
2023-04-23 21:23:45 +05:30
|
|
|
HelpCenter,
|
2023-05-27 22:25:52 +05:30
|
|
|
SidebarMenu,
|
|
|
|
SidebarPortalTarget,
|
|
|
|
},
|
2023-06-20 00:43:36 +05:30
|
|
|
mixins: [glFeatureFlagsMixin()],
|
2023-05-27 22:25:52 +05:30
|
|
|
i18n: {
|
|
|
|
skipToMainContent: __('Skip to main content'),
|
2023-03-17 16:20:25 +05:30
|
|
|
},
|
|
|
|
props: {
|
|
|
|
sidebarData: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
2023-06-20 00:43:36 +05:30
|
|
|
return sidebarState;
|
2023-03-17 16:20:25 +05:30
|
|
|
},
|
2023-05-27 22:25:52 +05:30
|
|
|
computed: {
|
|
|
|
menuItems() {
|
|
|
|
return this.sidebarData.current_menu_items || [];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
collapseSidebar() {
|
|
|
|
toggleSuperSidebarCollapsed(true, false);
|
|
|
|
},
|
2023-06-20 00:43:36 +05:30
|
|
|
onContextSwitcherShown() {
|
|
|
|
this.$refs['context-switcher'].focusInput();
|
|
|
|
},
|
|
|
|
onHoverAreaMouseEnter() {
|
|
|
|
this.openPeekTimer = setTimeout(this.openPeek, SUPER_SIDEBAR_PEEK_OPEN_DELAY);
|
|
|
|
},
|
|
|
|
onHoverAreaMouseLeave() {
|
|
|
|
clearTimeout(this.openPeekTimer);
|
|
|
|
},
|
|
|
|
onSidebarMouseEnter() {
|
|
|
|
clearTimeout(this.closePeekTimer);
|
|
|
|
},
|
|
|
|
onSidebarMouseLeave() {
|
|
|
|
this.closePeekTimer = setTimeout(this.closePeek, SUPER_SIDEBAR_PEEK_CLOSE_DELAY);
|
|
|
|
},
|
|
|
|
closePeek() {
|
|
|
|
if (this.isPeek) {
|
|
|
|
this.isPeek = false;
|
|
|
|
this.isCollapsed = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
openPeek() {
|
|
|
|
this.isPeek = true;
|
|
|
|
this.isCollapsed = false;
|
|
|
|
|
|
|
|
// Cancel and start the timer to close sidebar, in case the user moves
|
|
|
|
// the cursor fast enough away to not trigger a mouseenter event.
|
|
|
|
// This is cancelled if the user moves the cursor into the sidebar.
|
|
|
|
this.onSidebarMouseEnter();
|
|
|
|
this.onSidebarMouseLeave();
|
|
|
|
},
|
2023-05-27 22:25:52 +05:30
|
|
|
},
|
2023-03-17 16:20:25 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-05-27 22:25:52 +05:30
|
|
|
<div>
|
|
|
|
<div class="super-sidebar-overlay" @click="collapseSidebar"></div>
|
2023-06-20 00:43:36 +05:30
|
|
|
<div
|
|
|
|
v-if="!isPeek && glFeatures.superSidebarPeek"
|
|
|
|
class="super-sidebar-hover-area gl-fixed gl-left-0 gl-top-0 gl-bottom-0 gl-w-3"
|
|
|
|
data-testid="super-sidebar-hover-area"
|
|
|
|
@mouseenter="onHoverAreaMouseEnter"
|
|
|
|
@mouseleave="onHoverAreaMouseLeave"
|
|
|
|
></div>
|
2023-05-27 22:25:52 +05:30
|
|
|
<aside
|
|
|
|
id="super-sidebar"
|
|
|
|
class="super-sidebar"
|
2023-06-20 00:43:36 +05:30
|
|
|
:class="{ 'super-sidebar-peek': isPeek }"
|
2023-05-27 22:25:52 +05:30
|
|
|
data-testid="super-sidebar"
|
|
|
|
data-qa-selector="navbar"
|
2023-06-20 00:43:36 +05:30
|
|
|
:inert="isCollapsed"
|
|
|
|
@mouseenter="onSidebarMouseEnter"
|
|
|
|
@mouseleave="onSidebarMouseLeave"
|
2023-05-27 22:25:52 +05:30
|
|
|
>
|
|
|
|
<gl-button
|
|
|
|
class="super-sidebar-skip-to gl-sr-only-focusable gl-absolute gl-left-3 gl-right-3 gl-top-3"
|
|
|
|
href="#content-body"
|
|
|
|
variant="confirm"
|
|
|
|
>
|
|
|
|
{{ $options.i18n.skipToMainContent }}
|
|
|
|
</gl-button>
|
2023-06-20 00:43:36 +05:30
|
|
|
<user-bar :has-collapse-button="!isPeek" :sidebar-data="sidebarData" />
|
2023-05-27 22:25:52 +05:30
|
|
|
<div class="gl-display-flex gl-flex-direction-column gl-flex-grow-1 gl-overflow-hidden">
|
|
|
|
<div class="gl-flex-grow-1 gl-overflow-auto">
|
|
|
|
<context-switcher-toggle
|
|
|
|
:context="sidebarData.current_context_header"
|
2023-06-20 00:43:36 +05:30
|
|
|
:expanded="contextSwitcherOpen"
|
|
|
|
data-qa-selector="context_switcher"
|
2023-05-27 22:25:52 +05:30
|
|
|
/>
|
2023-06-20 00:43:36 +05:30
|
|
|
<gl-collapse
|
|
|
|
id="context-switcher"
|
|
|
|
v-model="contextSwitcherOpen"
|
|
|
|
data-qa-selector="context_section"
|
|
|
|
@shown="onContextSwitcherShown"
|
|
|
|
>
|
2023-05-27 22:25:52 +05:30
|
|
|
<context-switcher
|
2023-06-20 00:43:36 +05:30
|
|
|
ref="context-switcher"
|
|
|
|
:persistent-links="sidebarData.context_switcher_links"
|
2023-05-27 22:25:52 +05:30
|
|
|
:username="sidebarData.username"
|
|
|
|
:projects-path="sidebarData.projects_path"
|
|
|
|
:groups-path="sidebarData.groups_path"
|
|
|
|
:current-context="sidebarData.current_context"
|
|
|
|
/>
|
|
|
|
</gl-collapse>
|
2023-06-20 00:43:36 +05:30
|
|
|
<gl-collapse :visible="!contextSwitcherOpen">
|
|
|
|
<sidebar-menu
|
|
|
|
:items="menuItems"
|
|
|
|
:panel-type="sidebarData.panel_type"
|
|
|
|
:pinned-item-ids="sidebarData.pinned_items"
|
|
|
|
:update-pins-url="sidebarData.update_pins_url"
|
|
|
|
/>
|
2023-05-27 22:25:52 +05:30
|
|
|
<sidebar-portal-target />
|
|
|
|
</gl-collapse>
|
|
|
|
</div>
|
|
|
|
<div class="gl-p-3">
|
|
|
|
<help-center :sidebar-data="sidebarData" />
|
|
|
|
</div>
|
2023-03-17 16:20:25 +05:30
|
|
|
</div>
|
2023-05-27 22:25:52 +05:30
|
|
|
</aside>
|
2023-06-20 00:43:36 +05:30
|
|
|
<a
|
|
|
|
v-for="shortcutLink in sidebarData.shortcut_links"
|
|
|
|
:key="shortcutLink.href"
|
|
|
|
:href="shortcutLink.href"
|
|
|
|
:class="shortcutLink.css_class"
|
|
|
|
class="gl-display-none"
|
|
|
|
>
|
|
|
|
{{ shortcutLink.title }}
|
|
|
|
</a>
|
2023-05-27 22:25:52 +05:30
|
|
|
</div>
|
2023-03-17 16:20:25 +05:30
|
|
|
</template>
|