Commit 590af934 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'nfriend-ref-selector-dropdown-cleanup' into 'master'

Update ref selector to use header slot

See merge request gitlab-org/gitlab!55121
parents 05c9b146 48ca1083
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { import {
GlDropdown, GlDropdown,
GlDropdownDivider, GlDropdownDivider,
GlDropdownSectionHeader,
GlSearchBoxByType, GlSearchBoxByType,
GlSprintf, GlSprintf,
GlIcon, GlIcon,
...@@ -27,7 +26,6 @@ export default { ...@@ -27,7 +26,6 @@ export default {
components: { components: {
GlDropdown, GlDropdown,
GlDropdownDivider, GlDropdownDivider,
GlDropdownSectionHeader,
GlSearchBoxByType, GlSearchBoxByType,
GlSprintf, GlSprintf,
GlIcon, GlIcon,
...@@ -161,8 +159,13 @@ export default { ...@@ -161,8 +159,13 @@ export default {
</script> </script>
<template> <template>
<gl-dropdown v-bind="$attrs" class="ref-selector" @shown="focusSearchBox"> <gl-dropdown
<template slot="button-content"> v-bind="$attrs"
:header-text="i18n.dropdownHeader"
class="ref-selector"
@shown="focusSearchBox"
>
<template #button-content>
<span class="gl-flex-grow-1 gl-ml-2 gl-text-gray-400" data-testid="button-content"> <span class="gl-flex-grow-1 gl-ml-2 gl-text-gray-400" data-testid="button-content">
<span v-if="selectedRef" class="gl-font-monospace">{{ selectedRef }}</span> <span v-if="selectedRef" class="gl-font-monospace">{{ selectedRef }}</span>
<span v-else>{{ i18n.noRefSelected }}</span> <span v-else>{{ i18n.noRefSelected }}</span>
...@@ -170,13 +173,7 @@ export default { ...@@ -170,13 +173,7 @@ export default {
<gl-icon name="chevron-down" /> <gl-icon name="chevron-down" />
</template> </template>
<div class="gl-display-flex gl-flex-direction-column ref-selector-dropdown-content"> <template #header>
<gl-dropdown-section-header>
<span class="gl-text-center gl-display-block">{{ i18n.dropdownHeader }}</span>
</gl-dropdown-section-header>
<gl-dropdown-divider />
<gl-search-box-by-type <gl-search-box-by-type
ref="searchBox" ref="searchBox"
v-model.trim="query" v-model.trim="query"
...@@ -184,72 +181,66 @@ export default { ...@@ -184,72 +181,66 @@ export default {
@input="onSearchBoxInput" @input="onSearchBoxInput"
@keydown.enter.prevent="onSearchBoxEnter" @keydown.enter.prevent="onSearchBoxEnter"
/> />
</template>
<div class="gl-flex-grow-1 gl-overflow-y-auto"> <gl-loading-icon v-if="isLoading" size="lg" class="gl-my-3" />
<gl-loading-icon v-if="isLoading" size="lg" class="gl-my-3" />
<div <div v-else-if="showNoResults" class="gl-text-center gl-mx-3 gl-py-3" data-testid="no-results">
v-else-if="showNoResults" <gl-sprintf v-if="lastQuery" :message="i18n.noResultsWithQuery">
class="gl-text-center gl-mx-3 gl-py-3" <template #query>
data-testid="no-results" <b class="gl-word-break-all">{{ lastQuery }}</b>
> </template>
<gl-sprintf v-if="lastQuery" :message="i18n.noResultsWithQuery"> </gl-sprintf>
<template #query>
<b class="gl-word-break-all">{{ lastQuery }}</b>
</template>
</gl-sprintf>
<span v-else>{{ i18n.noResults }}</span> <span v-else>{{ i18n.noResults }}</span>
</div> </div>
<template v-else> <template v-else>
<template v-if="showBranchesSection"> <template v-if="showBranchesSection">
<ref-results-section <ref-results-section
:section-title="i18n.branches" :section-title="i18n.branches"
:total-count="matches.branches.totalCount" :total-count="matches.branches.totalCount"
:items="matches.branches.list" :items="matches.branches.list"
:selected-ref="selectedRef" :selected-ref="selectedRef"
:error="matches.branches.error" :error="matches.branches.error"
:error-message="i18n.branchesErrorMessage" :error-message="i18n.branchesErrorMessage"
:show-header="showSectionHeaders" :show-header="showSectionHeaders"
data-testid="branches-section" data-testid="branches-section"
@selected="selectRef($event)" @selected="selectRef($event)"
/> />
<gl-dropdown-divider v-if="showTagsSection || showCommitsSection" /> <gl-dropdown-divider v-if="showTagsSection || showCommitsSection" />
</template> </template>
<template v-if="showTagsSection"> <template v-if="showTagsSection">
<ref-results-section <ref-results-section
:section-title="i18n.tags" :section-title="i18n.tags"
:total-count="matches.tags.totalCount" :total-count="matches.tags.totalCount"
:items="matches.tags.list" :items="matches.tags.list"
:selected-ref="selectedRef" :selected-ref="selectedRef"
:error="matches.tags.error" :error="matches.tags.error"
:error-message="i18n.tagsErrorMessage" :error-message="i18n.tagsErrorMessage"
:show-header="showSectionHeaders" :show-header="showSectionHeaders"
data-testid="tags-section" data-testid="tags-section"
@selected="selectRef($event)" @selected="selectRef($event)"
/> />
<gl-dropdown-divider v-if="showCommitsSection" /> <gl-dropdown-divider v-if="showCommitsSection" />
</template> </template>
<template v-if="showCommitsSection"> <template v-if="showCommitsSection">
<ref-results-section <ref-results-section
:section-title="i18n.commits" :section-title="i18n.commits"
:total-count="matches.commits.totalCount" :total-count="matches.commits.totalCount"
:items="matches.commits.list" :items="matches.commits.list"
:selected-ref="selectedRef" :selected-ref="selectedRef"
:error="matches.commits.error" :error="matches.commits.error"
:error-message="i18n.commitsErrorMessage" :error-message="i18n.commitsErrorMessage"
:show-header="showSectionHeaders" :show-header="showSectionHeaders"
data-testid="commits-section" data-testid="commits-section"
@selected="selectRef($event)" @selected="selectRef($event)"
/> />
</template> </template>
</template> </template>
</div>
</div>
</gl-dropdown> </gl-dropdown>
</template> </template>
.ref-selector { .ref-selector {
& &-dropdown-content {
// Setting a max height is necessary to allow the dropdown's content
// to control where and how scrollbars appear.
// This content is limited to the max-height of the dropdown
// ($dropdown-max-height-lg) minus the additional padding
// on the top and bottom (2 * $gl-padding-8)
max-height: $dropdown-max-height-lg - 2 * $gl-padding-8;
}
.dropdown-menu.show { .dropdown-menu.show {
// Make the dropdown a little wider and longer than usual // Make the dropdown a little wider and longer than usual
// since it contains quite a bit of content. // since it contains quite a bit of content.
......
---
title: Small visual updates to Git ref selector dropdown on New/Edit Release page
merge_request: 55121
author:
type: changed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment