1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
<script>
import { GlBadge, GlButton, GlModalDirective, GlTooltipDirective, GlIcon } from '@gitlab/ui';
import { __, s__, sprintf } from '~/locale';
import {
destroyUserCountsManager,
createUserCountsManager,
userCounts,
} from '~/super_sidebar/user_counts_manager';
import BrandLogo from 'jh_else_ce/super_sidebar/components/brand_logo.vue';
import { JS_TOGGLE_COLLAPSE_CLASS } from '../constants';
import CreateMenu from './create_menu.vue';
import Counter from './counter.vue';
import MergeRequestMenu from './merge_request_menu.vue';
import UserMenu from './user_menu.vue';
import SuperSidebarToggle from './super_sidebar_toggle.vue';
import { SEARCH_MODAL_ID } from './global_search/constants';
export default {
// "GitLab Next" is a proper noun, so don't translate "Next"
/* eslint-disable-next-line @gitlab/require-i18n-strings */
NEXT_LABEL: 'Next',
JS_TOGGLE_COLLAPSE_CLASS,
SEARCH_MODAL_ID,
components: {
Counter,
CreateMenu,
GlBadge,
GlButton,
MergeRequestMenu,
UserMenu,
SearchModal: () =>
import(
/* webpackChunkName: 'global_search_modal' */ './global_search/components/global_search.vue'
),
SuperSidebarToggle,
BrandLogo,
GlIcon,
},
i18n: {
issues: __('Issues'),
mergeRequests: __('Merge requests'),
searchKbdHelp: sprintf(
s__('GlobalSearch|Type %{kbdOpen}/%{kbdClose} to search'),
{ kbdOpen: '<kbd>', kbdClose: '</kbd>' },
false,
),
todoList: __('To-Do list'),
stopImpersonating: __('Stop impersonating'),
searchBtnText: __('Search or go to…'),
},
directives: {
GlTooltip: GlTooltipDirective,
GlModal: GlModalDirective,
},
inject: ['isImpersonating'],
props: {
hasCollapseButton: {
default: true,
type: Boolean,
required: false,
},
sidebarData: {
type: Object,
required: true,
},
},
data() {
return {
mrMenuShown: false,
searchTooltip: this.$options.i18n.searchKbdHelp,
userCounts,
};
},
computed: {
mergeRequestTotalCount() {
return userCounts.assigned_merge_requests + userCounts.review_requested_merge_requests;
},
},
created() {
Object.assign(userCounts, this.sidebarData.user_counts);
createUserCountsManager();
},
mounted() {
document.addEventListener('todo:toggle', this.updateTodos);
},
beforeDestroy() {
document.removeEventListener('todo:toggle', this.updateTodos);
destroyUserCountsManager();
},
methods: {
updateTodos(e) {
userCounts.todos = e.detail.count || 0;
},
hideSearchTooltip() {
this.searchTooltip = '';
},
showSearchTooltip() {
this.searchTooltip = this.$options.i18n.searchKbdHelp;
},
},
};
</script>
<template>
<div
class="user-bar gl-display-flex gl-p-3 gl-gap-1"
:class="{ 'gl-flex-direction-column gl-gap-3': sidebarData.is_logged_in }"
>
<div
v-if="hasCollapseButton || sidebarData.is_logged_in"
class="gl-display-flex gl-align-items-center gl-gap-1"
>
<template v-if="sidebarData.is_logged_in">
<brand-logo :logo-url="sidebarData.logo_url" />
<gl-badge
v-if="sidebarData.gitlab_com_and_canary"
variant="success"
data-testid="canary-badge-link"
:href="sidebarData.canary_toggle_com_url"
size="sm"
>
{{ $options.NEXT_LABEL }}
</gl-badge>
<div class="gl-flex-grow-1"></div>
</template>
<super-sidebar-toggle
v-if="hasCollapseButton"
:class="$options.JS_TOGGLE_COLLAPSE_CLASS"
data-testid="super-sidebar-collapse-button"
type="collapse"
/>
<create-menu
v-if="sidebarData.is_logged_in && sidebarData.create_new_menu_groups.length > 0"
:groups="sidebarData.create_new_menu_groups"
/>
<user-menu v-if="sidebarData.is_logged_in" :data="sidebarData" />
<gl-button
v-if="isImpersonating"
v-gl-tooltip.bottom
:href="sidebarData.stop_impersonation_path"
:title="$options.i18n.stopImpersonating"
:aria-label="$options.i18n.stopImpersonating"
icon="incognito"
category="tertiary"
data-method="delete"
data-testid="stop-impersonation-btn"
/>
</div>
<div
v-if="sidebarData.is_logged_in"
class="gl-display-flex gl-justify-content-space-between gl-gap-2"
>
<counter
v-gl-tooltip:super-sidebar.bottom="$options.i18n.issues"
class="gl-flex-basis-third dashboard-shortcuts-issues"
icon="issues"
:count="userCounts.assigned_issues"
:href="sidebarData.issues_dashboard_path"
:label="$options.i18n.issues"
data-testid="issues-shortcut-button"
data-track-action="click_link"
data-track-label="issues_link"
data-track-property="nav_core_menu"
/>
<merge-request-menu
class="gl-flex-basis-third gl-display-block!"
:items="sidebarData.merge_request_menu"
@shown="mrMenuShown = true"
@hidden="mrMenuShown = false"
>
<counter
v-gl-tooltip:super-sidebar.bottom="mrMenuShown ? '' : $options.i18n.mergeRequests"
class="gl-w-full"
icon="merge-request-open"
:count="mergeRequestTotalCount"
:label="$options.i18n.mergeRequests"
data-testid="merge-requests-shortcut-button"
data-track-action="click_dropdown"
data-track-label="merge_requests_menu"
data-track-property="nav_core_menu"
/>
</merge-request-menu>
<counter
v-gl-tooltip:super-sidebar.bottom="$options.i18n.todoList"
class="gl-flex-basis-third shortcuts-todos js-todos-count"
icon="todo-done"
:count="userCounts.todos"
:href="sidebarData.todos_dashboard_path"
:label="$options.i18n.todoList"
data-testid="todos-shortcut-button"
data-track-action="click_link"
data-track-label="todos_link"
data-track-property="nav_core_menu"
/>
</div>
<button
id="super-sidebar-search"
v-gl-tooltip.bottom.html="searchTooltip"
v-gl-modal="$options.SEARCH_MODAL_ID"
class="counter gl-display-block gl-py-3 gl-bg-gray-10 gl-rounded-base gl-text-gray-900 gl-border-none gl-inset-border-1-gray-a-08 gl-line-height-1 gl-focus--focus gl-w-full"
data-testid="super-sidebar-search-button"
>
<gl-icon name="search" />
{{ $options.i18n.searchBtnText }}
</button>
<search-modal @shown="hideSearchTooltip" @hidden="showSearchTooltip" />
</div>
</template>
|