2023-03-17 16:20:25 +05:30
|
|
|
<script>
|
2023-06-20 00:43:36 +05:30
|
|
|
import { GlBadge, GlButton, GlModalDirective, GlTooltipDirective } from '@gitlab/ui';
|
|
|
|
import { __, s__, sprintf } from '~/locale';
|
2023-03-17 16:20:25 +05:30
|
|
|
import SafeHtml from '~/vue_shared/directives/safe_html';
|
2023-06-20 00:43:36 +05:30
|
|
|
import { highCountTrim } from '~/lib/utils/text_utility';
|
2023-03-17 16:20:25 +05:30
|
|
|
import logo from '../../../../views/shared/_logo.svg';
|
2023-06-20 00:43:36 +05:30
|
|
|
import { JS_TOGGLE_COLLAPSE_CLASS } from '../constants';
|
2023-04-23 21:23:45 +05:30
|
|
|
import CreateMenu from './create_menu.vue';
|
2023-03-17 16:20:25 +05:30
|
|
|
import Counter from './counter.vue';
|
2023-04-23 21:23:45 +05:30
|
|
|
import MergeRequestMenu from './merge_request_menu.vue';
|
2023-05-27 22:25:52 +05:30
|
|
|
import UserMenu from './user_menu.vue';
|
2023-06-20 00:43:36 +05:30
|
|
|
import SuperSidebarToggle from './super_sidebar_toggle.vue';
|
|
|
|
import { SEARCH_MODAL_ID } from './global_search/constants';
|
2023-03-17 16:20:25 +05:30
|
|
|
|
|
|
|
export default {
|
2023-05-27 22:25:52 +05:30
|
|
|
// "GitLab Next" is a proper noun, so don't translate "Next"
|
|
|
|
/* eslint-disable-next-line @gitlab/require-i18n-strings */
|
|
|
|
NEXT_LABEL: 'Next',
|
2023-03-17 16:20:25 +05:30
|
|
|
logo,
|
2023-06-20 00:43:36 +05:30
|
|
|
JS_TOGGLE_COLLAPSE_CLASS,
|
|
|
|
SEARCH_MODAL_ID,
|
2023-03-17 16:20:25 +05:30
|
|
|
components: {
|
|
|
|
Counter,
|
2023-05-27 22:25:52 +05:30
|
|
|
CreateMenu,
|
|
|
|
GlBadge,
|
|
|
|
GlButton,
|
2023-04-23 21:23:45 +05:30
|
|
|
MergeRequestMenu,
|
2023-05-27 22:25:52 +05:30
|
|
|
UserMenu,
|
2023-06-20 00:43:36 +05:30
|
|
|
SearchModal: () =>
|
|
|
|
import(
|
|
|
|
/* webpackChunkName: 'global_search_modal' */ './global_search/components/global_search.vue'
|
|
|
|
),
|
|
|
|
SuperSidebarToggle,
|
2023-03-17 16:20:25 +05:30
|
|
|
},
|
|
|
|
i18n: {
|
2023-04-23 21:23:45 +05:30
|
|
|
createNew: __('Create new...'),
|
2023-06-20 00:43:36 +05:30
|
|
|
homepage: __('Homepage'),
|
2023-03-17 16:20:25 +05:30
|
|
|
issues: __('Issues'),
|
|
|
|
mergeRequests: __('Merge requests'),
|
2023-05-27 22:25:52 +05:30
|
|
|
search: __('Search'),
|
2023-06-20 00:43:36 +05:30
|
|
|
searchKbdHelp: sprintf(
|
|
|
|
s__('GlobalSearch|Search GitLab %{kbdOpen}/%{kbdClose}'),
|
|
|
|
{ kbdOpen: '<kbd>', kbdClose: '</kbd>' },
|
|
|
|
false,
|
|
|
|
),
|
2023-03-17 16:20:25 +05:30
|
|
|
todoList: __('To-Do list'),
|
2023-06-20 00:43:36 +05:30
|
|
|
stopImpersonating: __('Stop impersonating'),
|
2023-03-17 16:20:25 +05:30
|
|
|
},
|
|
|
|
directives: {
|
2023-04-23 21:23:45 +05:30
|
|
|
GlTooltip: GlTooltipDirective,
|
2023-06-20 00:43:36 +05:30
|
|
|
GlModal: GlModalDirective,
|
2023-03-17 16:20:25 +05:30
|
|
|
SafeHtml,
|
|
|
|
},
|
2023-06-20 00:43:36 +05:30
|
|
|
inject: ['rootPath', 'isImpersonating'],
|
2023-03-17 16:20:25 +05:30
|
|
|
props: {
|
2023-06-20 00:43:36 +05:30
|
|
|
hasCollapseButton: {
|
|
|
|
default: true,
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
},
|
2023-03-17 16:20:25 +05:30
|
|
|
sidebarData: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2023-06-20 00:43:36 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
mrMenuShown: false,
|
|
|
|
todoCount: this.sidebarData.todos_pending_count,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
formattedTodoCount() {
|
|
|
|
return highCountTrim(this.todoCount);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
document.addEventListener('todo:toggle', this.updateTodos);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
document.removeEventListener('todo:toggle', this.updateTodos);
|
|
|
|
},
|
2023-05-27 22:25:52 +05:30
|
|
|
methods: {
|
2023-06-20 00:43:36 +05:30
|
|
|
updateTodos(e) {
|
|
|
|
this.todoCount = e.detail.count || 0;
|
2023-05-27 22:25:52 +05:30
|
|
|
},
|
|
|
|
},
|
2023-03-17 16:20:25 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="user-bar">
|
2023-06-20 00:43:36 +05:30
|
|
|
<div class="gl-display-flex gl-align-items-center gl-px-3 gl-py-2">
|
|
|
|
<a
|
|
|
|
v-gl-tooltip:super-sidebar.hover.bottom="$options.i18n.homepage"
|
|
|
|
:href="rootPath"
|
|
|
|
:title="$options.i18n.homepage"
|
|
|
|
data-track-action="click_link"
|
|
|
|
data-track-label="gitlab_logo_link"
|
|
|
|
data-track-property="nav_core_menu"
|
|
|
|
>
|
2023-05-27 22:25:52 +05:30
|
|
|
<img
|
|
|
|
v-if="sidebarData.logo_url"
|
|
|
|
data-testid="brand-header-custom-logo"
|
|
|
|
:src="sidebarData.logo_url"
|
|
|
|
class="gl-h-6"
|
|
|
|
/>
|
|
|
|
<span v-else v-safe-html="$options.logo"></span>
|
|
|
|
</a>
|
|
|
|
<gl-badge
|
|
|
|
v-if="sidebarData.gitlab_com_and_canary"
|
|
|
|
variant="success"
|
|
|
|
:href="sidebarData.canary_toggle_com_url"
|
|
|
|
size="sm"
|
2023-06-20 00:43:36 +05:30
|
|
|
class="gl-ml-2"
|
2023-05-27 22:25:52 +05:30
|
|
|
>
|
2023-06-20 00:43:36 +05:30
|
|
|
{{ $options.NEXT_LABEL }}
|
|
|
|
</gl-badge>
|
2023-05-27 22:25:52 +05:30
|
|
|
<div class="gl-flex-grow-1"></div>
|
2023-06-20 00:43:36 +05:30
|
|
|
<super-sidebar-toggle
|
|
|
|
v-if="hasCollapseButton"
|
|
|
|
:class="$options.JS_TOGGLE_COLLAPSE_CLASS"
|
|
|
|
tooltip-placement="bottom"
|
|
|
|
tooltip-container="super-sidebar"
|
|
|
|
data-testid="super-sidebar-collapse-button"
|
2023-05-27 22:25:52 +05:30
|
|
|
/>
|
2023-04-23 21:23:45 +05:30
|
|
|
<create-menu :groups="sidebarData.create_new_menu_groups" />
|
2023-06-20 00:43:36 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
<gl-button
|
2023-06-20 00:43:36 +05:30
|
|
|
id="super-sidebar-search"
|
|
|
|
v-gl-tooltip.bottom.hover.html="$options.i18n.searchKbdHelp"
|
|
|
|
v-gl-modal="$options.SEARCH_MODAL_ID"
|
|
|
|
data-testid="super-sidebar-search-button"
|
2023-05-27 22:25:52 +05:30
|
|
|
icon="search"
|
|
|
|
:aria-label="$options.i18n.search"
|
|
|
|
category="tertiary"
|
|
|
|
/>
|
2023-06-20 00:43:36 +05:30
|
|
|
<search-modal />
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
<user-menu :data="sidebarData" />
|
2023-06-20 00:43:36 +05:30
|
|
|
|
|
|
|
<gl-button
|
|
|
|
v-if="isImpersonating"
|
|
|
|
v-gl-tooltip
|
|
|
|
:href="sidebarData.stop_impersonation_path"
|
|
|
|
:title="$options.i18n.stopImpersonating"
|
|
|
|
:aria-label="$options.i18n.stopImpersonating"
|
|
|
|
icon="incognito"
|
|
|
|
variant="confirm"
|
|
|
|
category="tertiary"
|
|
|
|
data-method="delete"
|
|
|
|
data-testid="stop-impersonation-btn"
|
|
|
|
/>
|
2023-03-17 16:20:25 +05:30
|
|
|
</div>
|
|
|
|
<div class="gl-display-flex gl-justify-content-space-between gl-px-3 gl-py-2 gl-gap-2">
|
|
|
|
<counter
|
2023-04-23 21:23:45 +05:30
|
|
|
v-gl-tooltip:super-sidebar.hover.bottom="$options.i18n.issues"
|
2023-06-20 00:43:36 +05:30
|
|
|
class="gl-flex-basis-third dashboard-shortcuts-issues"
|
2023-03-17 16:20:25 +05:30
|
|
|
icon="issues"
|
|
|
|
:count="sidebarData.assigned_open_issues_count"
|
|
|
|
:href="sidebarData.issues_dashboard_path"
|
|
|
|
:label="$options.i18n.issues"
|
2023-06-20 00:43:36 +05:30
|
|
|
data-track-action="click_link"
|
|
|
|
data-track-label="issues_link"
|
|
|
|
data-track-property="nav_core_menu"
|
2023-03-17 16:20:25 +05:30
|
|
|
/>
|
2023-04-23 21:23:45 +05:30
|
|
|
<merge-request-menu
|
|
|
|
class="gl-flex-basis-third gl-display-block!"
|
|
|
|
:items="sidebarData.merge_request_menu"
|
2023-06-20 00:43:36 +05:30
|
|
|
@shown="mrMenuShown = true"
|
|
|
|
@hidden="mrMenuShown = false"
|
2023-04-23 21:23:45 +05:30
|
|
|
>
|
|
|
|
<counter
|
2023-06-20 00:43:36 +05:30
|
|
|
v-gl-tooltip:super-sidebar.hover.bottom="mrMenuShown ? '' : $options.i18n.mergeRequests"
|
2023-04-23 21:23:45 +05:30
|
|
|
class="gl-w-full"
|
|
|
|
icon="merge-request-open"
|
|
|
|
:count="sidebarData.total_merge_requests_count"
|
|
|
|
:label="$options.i18n.mergeRequests"
|
2023-06-20 00:43:36 +05:30
|
|
|
data-track-action="click_dropdown"
|
|
|
|
data-track-label="merge_requests_menu"
|
|
|
|
data-track-property="nav_core_menu"
|
2023-04-23 21:23:45 +05:30
|
|
|
/>
|
|
|
|
</merge-request-menu>
|
2023-03-17 16:20:25 +05:30
|
|
|
<counter
|
2023-04-23 21:23:45 +05:30
|
|
|
v-gl-tooltip:super-sidebar.hover.bottom="$options.i18n.todoList"
|
2023-06-20 00:43:36 +05:30
|
|
|
class="gl-flex-basis-third shortcuts-todos js-todos-count"
|
2023-03-17 16:20:25 +05:30
|
|
|
icon="todo-done"
|
2023-06-20 00:43:36 +05:30
|
|
|
:count="formattedTodoCount"
|
2023-03-17 16:20:25 +05:30
|
|
|
href="/dashboard/todos"
|
|
|
|
:label="$options.i18n.todoList"
|
2023-05-27 22:25:52 +05:30
|
|
|
data-qa-selector="todos_shortcut_button"
|
2023-06-20 00:43:36 +05:30
|
|
|
data-track-action="click_link"
|
|
|
|
data-track-label="todos_link"
|
|
|
|
data-track-property="nav_core_menu"
|
2023-03-17 16:20:25 +05:30
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|