diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-08 15:07:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-08 15:07:09 +0300 |
commit | e44c3e4832e43c77e9c29fad6e49f8d6066d7f5c (patch) | |
tree | 892f4505093dd5ffd60e238a8b74b35f021654ae /app/assets/javascripts/super_sidebar/components | |
parent | aa1c2a29b8ddc82141f826eacd169d3d7ff66611 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/super_sidebar/components')
5 files changed, 45 insertions, 27 deletions
diff --git a/app/assets/javascripts/super_sidebar/components/context_switcher.vue b/app/assets/javascripts/super_sidebar/components/context_switcher.vue index c5f3410a68f..439280eebd4 100644 --- a/app/assets/javascripts/super_sidebar/components/context_switcher.vue +++ b/app/assets/javascripts/super_sidebar/components/context_switcher.vue @@ -64,11 +64,8 @@ export default { ProjectsList, GroupsList, }, + inject: ['contextSwitcherLinks'], props: { - persistentLinks: { - type: Array, - required: true, - }, username: { type: String, required: true, @@ -185,7 +182,7 @@ export default { class="gl-border-b gl-border-gray-50 gl-px-0 gl-py-2" > <nav-item - v-for="item in persistentLinks" + v-for="item in contextSwitcherLinks" :key="item.link" :item="item" :link-classes="{ [item.link_classes]: item.link_classes }" diff --git a/app/assets/javascripts/super_sidebar/components/global_search/components/global_search.vue b/app/assets/javascripts/super_sidebar/components/global_search/components/global_search.vue index d3bc8f44725..0f2ac5ab03f 100644 --- a/app/assets/javascripts/super_sidebar/components/global_search/components/global_search.vue +++ b/app/assets/javascripts/super_sidebar/components/global_search/components/global_search.vue @@ -361,12 +361,11 @@ export default { @updated="highlightFirstCommand" /> + <global-search-default-items v-else-if="showDefaultItems" /> + <template v-else> - <global-search-default-items v-if="showDefaultItems" /> - <template v-else> - <global-search-scoped-items v-if="showScopedSearchItems" /> - <global-search-autocomplete-items /> - </template> + <global-search-scoped-items v-if="showScopedSearchItems" /> + <global-search-autocomplete-items /> </template> </div> <template v-if="searchContext"> diff --git a/app/assets/javascripts/super_sidebar/components/global_search/components/global_search_default_items.vue b/app/assets/javascripts/super_sidebar/components/global_search/components/global_search_default_items.vue index 239c61fd750..eb76277d12b 100644 --- a/app/assets/javascripts/super_sidebar/components/global_search/components/global_search_default_items.vue +++ b/app/assets/javascripts/super_sidebar/components/global_search/components/global_search_default_items.vue @@ -1,31 +1,41 @@ <script> import { GlDisclosureDropdownGroup } from '@gitlab/ui'; import { mapState, mapGetters } from 'vuex'; -import { ALL_GITLAB } from '~/vue_shared/global_search/constants'; +import { ALL_GITLAB, PLACES } from '~/vue_shared/global_search/constants'; export default { name: 'GlobalSearchDefaultItems', i18n: { ALL_GITLAB, + PLACES, }, components: { GlDisclosureDropdownGroup, }, + inject: ['contextSwitcherLinks'], computed: { ...mapState(['searchContext']), ...mapGetters(['defaultSearchOptions']), - sectionHeader() { + currentContextName() { return ( this.searchContext?.project?.name || this.searchContext?.group?.name || this.$options.i18n.ALL_GITLAB ); }, - defaultItemsGroup() { - return { - name: this.sectionHeader, - items: this.defaultSearchOptions, - }; + groups() { + const groups = [ + { + name: this.$options.i18n.PLACES, + items: this.contextSwitcherLinks.map(({ title, link }) => ({ text: title, href: link })), + }, + { + name: this.currentContextName, + items: this.defaultSearchOptions, + }, + ]; + + return groups.filter(({ items }) => items.length > 0); }, }, }; @@ -33,6 +43,12 @@ export default { <template> <ul class="gl-p-0 gl-m-0 gl-list-style-none"> - <gl-disclosure-dropdown-group :group="defaultItemsGroup" bordered class="gl-mt-0!" /> + <gl-disclosure-dropdown-group + v-for="(group, index) of groups" + :key="group.name" + :group="group" + bordered + :class="{ 'gl-mt-0!': index === 0 }" + /> </ul> </template> diff --git a/app/assets/javascripts/super_sidebar/components/global_search/store/getters.js b/app/assets/javascripts/super_sidebar/components/global_search/store/getters.js index 89bd41ea6c4..6871dabc9a1 100644 --- a/app/assets/javascripts/super_sidebar/components/global_search/store/getters.js +++ b/app/assets/javascripts/super_sidebar/components/global_search/store/getters.js @@ -48,7 +48,7 @@ export const scopedIssuesPath = (state) => { return ( state.searchContext?.project_metadata?.issues_path || state.searchContext?.group_metadata?.issues_path || - state.issuesPath + (gon.current_username ? state.issuesPath : false) ); }; @@ -56,7 +56,7 @@ export const scopedMRPath = (state) => { return ( state.searchContext?.project_metadata?.mr_path || state.searchContext?.group_metadata?.mr_path || - state.mrPath + (gon.current_username ? state.mrPath : false) ); }; @@ -64,16 +64,23 @@ export const defaultSearchOptions = (state, getters) => { const userName = gon.current_username; if (!userName) { - return [ - { + const options = []; + + if (getters.scopedIssuesPath) { + options.push({ text: ISSUES_CATEGORY, href: getters.scopedIssuesPath, - }, - { + }); + } + + if (getters.scopedMRPath) { + options.push({ text: MERGE_REQUEST_CATEGORY, href: getters.scopedMRPath, - }, - ]; + }); + } + + return options; } const issues = [ diff --git a/app/assets/javascripts/super_sidebar/components/super_sidebar.vue b/app/assets/javascripts/super_sidebar/components/super_sidebar.vue index dd07d2f21e0..4fc5ea62e95 100644 --- a/app/assets/javascripts/super_sidebar/components/super_sidebar.vue +++ b/app/assets/javascripts/super_sidebar/components/super_sidebar.vue @@ -140,7 +140,6 @@ export default { <context-switcher v-if="sidebarData.is_logged_in" ref="context-switcher" - :persistent-links="sidebarData.context_switcher_links" :username="sidebarData.username" :projects-path="sidebarData.projects_path" :groups-path="sidebarData.groups_path" |