Commit 48ca1083 authored by Nathan Friend's avatar Nathan Friend Committed by Andrew Fontaine

Update ref_selector component to use #header slot

This commit refactors the ref_selector component to take advantage of
the newly-added #header slot in the GlDropdown component.
parent 28cb67da
...@@ -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,15 +181,11 @@ export default { ...@@ -184,15 +181,11 @@ 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"
class="gl-text-center gl-mx-3 gl-py-3"
data-testid="no-results"
>
<gl-sprintf v-if="lastQuery" :message="i18n.noResultsWithQuery"> <gl-sprintf v-if="lastQuery" :message="i18n.noResultsWithQuery">
<template #query> <template #query>
<b class="gl-word-break-all">{{ lastQuery }}</b> <b class="gl-word-break-all">{{ lastQuery }}</b>
...@@ -249,7 +242,5 @@ export default { ...@@ -249,7 +242,5 @@ export default {
/> />
</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