@@ -27,10 +27,15 @@ export default {
27
27
apply: __ (' Apply' ),
28
28
showingMax: sprintf (s__ (' GlobalSearch|Showing top %{maxItems}' ), { maxItems: MAX_ITEM_LENGTH }),
29
29
loadError: s__ (' GlobalSearch|Aggregations load error.' ),
30
+ reset: s__ (' GlobalSearch|Reset filters' ),
30
31
},
31
32
computed: {
32
33
... mapState ([' aggregations' , ' sidebarDirty' ]),
33
- ... mapGetters ([' langugageAggregationBuckets' ]),
34
+ ... mapGetters ([
35
+ ' langugageAggregationBuckets' ,
36
+ ' currentUrlQueryHasLanguageFilters' ,
37
+ ' queryLangugageFilters' ,
38
+ ]),
34
39
hasBuckets () {
35
40
return this .langugageAggregationBuckets .length > 0 ;
36
41
},
@@ -55,18 +60,33 @@ export default {
55
60
dividerClasses () {
56
61
return [... HR_DEFAULT_CLASSES, ... ONLY_SHOW_MD];
57
62
},
63
+ hasQueryFilters () {
64
+ return this .queryLangugageFilters .length > 0 ;
65
+ },
58
66
},
59
67
async created () {
60
68
await this .fetchLanguageAggregation ();
61
69
},
62
70
methods: {
63
- ... mapActions ([' applyQuery' , ' fetchLanguageAggregation' ]),
71
+ ... mapActions ([
72
+ ' applyQuery' ,
73
+ ' resetLanguageQuery' ,
74
+ ' resetLanguageQueryWithRedirect' ,
75
+ ' fetchLanguageAggregation' ,
76
+ ]),
64
77
onShowMore () {
65
78
this .showAll = true ;
66
79
},
67
80
trimBuckets (length ) {
68
81
return this .langugageAggregationBuckets .slice (0 , length);
69
82
},
83
+ cleanResetFilters () {
84
+ if (this .currentUrlQueryHasLanguageFilters ) {
85
+ return this .resetLanguageQueryWithRedirect ();
86
+ }
87
+ this .showAll = false ;
88
+ return this .resetLanguageQuery ();
89
+ },
70
90
},
71
91
HR_DEFAULT_CLASSES ,
72
92
};
@@ -84,7 +104,7 @@ export default {
84
104
class =" gl-overflow-x-hidden gl-overflow-y-auto"
85
105
:class =" { 'language-filter-max-height': showAll }"
86
106
>
87
- <checkbox-filter class = " gl-px-5 " :filter -data =" filtersData" />
107
+ <checkbox-filter :filters -data =" filtersData" />
88
108
<span v-if =" showAll && hasOverMax" data-testid =" has-over-max-text" >{{
89
109
$options.i18n.showingMax
90
110
}}</span >
@@ -106,7 +126,9 @@ export default {
106
126
</div >
107
127
<div v-if =" !aggregations.error" >
108
128
<hr :class =" $options.HR_DEFAULT_CLASSES" />
109
- <div class =" gl-display-flex gl-align-items-center gl-mt-4 gl-mx-5 gl-px-5" >
129
+ <div
130
+ class =" gl-display-flex gl-align-items-center gl-justify-content-space-between gl-mt-4 gl-mx-5"
131
+ >
110
132
<gl-button
111
133
category =" primary"
112
134
variant =" confirm"
@@ -116,6 +138,16 @@ export default {
116
138
>
117
139
{{ $options.i18n.apply }}
118
140
</gl-button >
141
+ <gl-button
142
+ category =" tertiary"
143
+ variant =" link"
144
+ size =" small"
145
+ :disabled =" !hasQueryFilters && !sidebarDirty"
146
+ data-testid =" reset-button"
147
+ @click =" cleanResetFilters"
148
+ >
149
+ {{ $options.i18n.reset }}
150
+ </gl-button >
119
151
</div >
120
152
</div >
121
153
</gl-form >
0 commit comments