debian-mirror-gitlab/app/assets/javascripts/super_sidebar/components/search_results.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

96 lines
2.1 KiB
Vue
Raw Normal View History

2023-05-27 22:25:52 +05:30
<script>
2023-06-20 00:43:36 +05:30
import { GlCollapse, GlCollapseToggleDirective, GlIcon } from '@gitlab/ui';
import uniqueId from 'lodash/uniqueId';
2023-05-27 22:25:52 +05:30
import ItemsList from './items_list.vue';
export default {
components: {
2023-06-20 00:43:36 +05:30
GlCollapse,
GlIcon,
2023-05-27 22:25:52 +05:30
ItemsList,
},
2023-06-20 00:43:36 +05:30
directives: {
CollapseToggle: GlCollapseToggleDirective,
},
2023-05-27 22:25:52 +05:30
props: {
title: {
type: String,
required: true,
},
noResultsText: {
type: String,
required: true,
},
searchResults: {
type: Array,
required: false,
default: () => [],
},
},
2023-06-20 00:43:36 +05:30
data() {
return {
expanded: true,
};
},
2023-05-27 22:25:52 +05:30
computed: {
isEmpty() {
return !this.searchResults.length;
},
2023-06-20 00:43:36 +05:30
collapseIcon() {
return this.expanded ? 'chevron-up' : 'chevron-down';
},
},
created() {
this.collapseId = uniqueId('expandable-section-');
2023-05-27 22:25:52 +05:30
},
2023-06-20 00:43:36 +05:30
buttonClasses: [
// Reset user agent styles
'gl-appearance-none',
'gl-border-0',
'gl-bg-transparent',
// Text styles
'gl-text-left',
'gl-text-transform-uppercase',
'gl-text-secondary',
'gl-font-weight-bold',
'gl-font-xs',
'gl-line-height-12',
'gl-letter-spacing-06em',
// Border
'gl-border-t',
'gl-border-gray-50',
// Spacing
'gl-my-3',
'gl-pt-2',
'gl-w-full',
// Layout
'gl-display-flex',
'gl-justify-content-space-between',
'gl-align-items-center',
],
2023-05-27 22:25:52 +05:30
};
</script>
<template>
2023-06-20 00:43:36 +05:30
<li class="gl-border-t gl-border-gray-50 gl-mx-3">
<button
v-collapse-toggle="collapseId"
:class="$options.buttonClasses"
data-testid="search-results-toggle"
2023-05-27 22:25:52 +05:30
>
{{ title }}
2023-06-20 00:43:36 +05:30
<gl-icon :name="collapseIcon" :size="16" />
</button>
<gl-collapse :id="collapseId" v-model="expanded">
<div v-if="isEmpty" data-testid="empty-text" class="gl-text-gray-500 gl-font-sm gl-my-3">
{{ noResultsText }}
</div>
<items-list :aria-label="title" :items="searchResults">
<template #view-all-items>
<slot name="view-all-items"></slot>
</template>
</items-list>
</gl-collapse>
2023-05-27 22:25:52 +05:30
</li>
</template>