Skip to content
Snippets Groups Projects
Commit ae403302 authored by Tomas Bulva's avatar Tomas Bulva
Browse files

Cleaned label facet component

removed some unused code and unnecessary translations
parent 64255b12
1 merge request!142407Orphaned properties in label filter
......@@ -15,8 +15,6 @@ import { mapActions, mapState, mapGetters } from 'vuex';
import { uniq } from 'lodash';
import { rgbFromHex } from '@gitlab/ui/dist/utils/utils';
import { slugify } from '~/lib/utils/text_utility';
import { isLoggedIn } from '~/lib/utils/common_utils';
import { sprintf } from '~/locale';
import DropdownKeyboardNavigation from '~/vue_shared/components/dropdown_keyboard_navigation.vue';
......@@ -52,7 +50,6 @@ export default {
return {
currentFocusIndex: SEARCH_BOX_INDEX,
isFocused: false,
isLoggedIn: isLoggedIn(),
};
},
i18n: I18N,
......@@ -65,31 +62,7 @@ export default {
'appliedSelectedLabels',
'unselectedLabels',
'unappliedNewLabels',
'labelAggregationBuckets',
]),
searchInputDescribeBy() {
if (this.isLoggedIn) {
return this.$options.i18n.SEARCH_INPUT_DESCRIBE_BY_WITH_DROPDOWN;
}
return this.$options.i18n.SEARCH_INPUT_DESCRIBE_BY_NO_DROPDOWN;
},
dropdownResultsDescription() {
if (!('showSearchDropdown' in this)) {
return ''; // This allows aria-live to see register an update when the dropdown is shown
}
if ('showDefaultItems' in this) {
return sprintf(this.$options.i18n.SEARCH_DESCRIBED_BY_DEFAULT, {
count: this.filteredLabels.length,
});
}
return 'loading' in this
? this.$options.i18n.SEARCH_RESULTS_LOADING
: sprintf(this.$options.i18n.SEARCH_DESCRIBED_BY_UPDATED, {
count: this.filteredLabels.length,
});
},
currentFocusedOption() {
return this.filteredLabels[this.currentFocusIndex] || null;
},
......@@ -98,12 +71,6 @@ export default {
this.currentFocusedOption?.title || 'undefined-title',
)}`;
},
defaultIndex() {
if ('showDefaultItems' in this) {
return SEARCH_BOX_INDEX;
}
return FIRST_DROPDOWN_INDEX;
},
hasSelectedLabels() {
return this.filteredAppliedSelectedLabels?.length > 0;
},
......@@ -217,6 +184,9 @@ export default {
@close="onLabelClose"
/>
</div>
<span :id="$options.SEARCH_INPUT_DESCRIPTION" role="region" class="gl-sr-only">{{
$options.i18n.DESCRIBE_LABEL_FILTER_INPUT
}}</span>
<gl-search-box-by-type
ref="searchLabelInputBox"
v-model="searchLabels"
......@@ -228,9 +198,6 @@ export default {
@focusin="openDropdown"
@keydown.esc="closeDropdown"
/>
<span :id="$options.SEARCH_INPUT_DESCRIPTION" role="region" class="gl-sr-only">{{
searchInputDescribeBy
}}</span>
<span
role="region"
:data-testid="$options.SEARCH_RESULTS_DESCRIPTION"
......@@ -238,7 +205,7 @@ export default {
aria-live="polite"
aria-atomic="true"
>
{{ dropdownResultsDescription }}
{{ $options.i18n.DESCRIBE_LABEL_FILTER }}
</span>
<div
v-if="isFocused"
......@@ -251,7 +218,7 @@ export default {
v-model="currentFocusIndex"
:max="filteredLabels.length - 1"
:min="$options.FIRST_DROPDOWN_INDEX"
:default-index="defaultIndex"
:default-index="$options.FIRST_DROPDOWN_INDEX"
:enable-cycle="true"
/>
<div v-if="!aggregations.error && filteredLabels.length > 0">
......
......@@ -8,16 +8,14 @@ export const ALL_GITLAB = __('All GitLab');
export const PLACES = s__('GlobalSearch|Places');
export const COMMAND_PALETTE = s__('GlobalSearch|Command palette');
export const DESCRIBE_LABEL_FILTER = s__('GlobalSearch|List of filtered labels.');
export const DESCRIBE_LABEL_FILTER_INPUT = s__('GlobalSearch|Type to filter labels.');
export const SEARCH_DESCRIBED_BY_DEFAULT = s__(
'GlobalSearch|%{count} default results provided. Use the up and down arrow keys to navigate search results list.',
);
export const SEARCH_DESCRIBED_BY_WITH_RESULTS = s__(
'GlobalSearch|Type for new suggestions to appear below.',
);
export const SEARCH_INPUT_DESCRIBE_BY_NO_DROPDOWN = s__(
'GlobalSearch|Type and press the enter key to submit search.',
);
export const SEARCH_INPUT_DESCRIBE_BY_WITH_DROPDOWN = SEARCH_DESCRIBED_BY_WITH_RESULTS;
export const SEARCH_DESCRIBED_BY_UPDATED = s__(
'GlobalSearch|Results updated. %{count} results available. Use the up and down arrow keys to navigate search results list, or ENTER to submit.',
);
......@@ -79,10 +77,10 @@ export const I18N = {
SEARCH_DESCRIBED_BY_DEFAULT,
SEARCH_RESULTS_LOADING,
SEARCH_DESCRIBED_BY_UPDATED,
SEARCH_INPUT_DESCRIBE_BY_WITH_DROPDOWN,
SEARCH_INPUT_DESCRIBE_BY_NO_DROPDOWN,
SEARCH_LABELS,
DROPDOWN_HEADER,
AGGREGATIONS_ERROR_MESSAGE,
NO_LABELS_FOUND,
DESCRIBE_LABEL_FILTER,
DESCRIBE_LABEL_FILTER_INPUT,
};
......@@ -22888,6 +22888,9 @@ msgstr ""
msgid "GlobalSearch|Language"
msgstr ""
 
msgid "GlobalSearch|List of filtered labels."
msgstr ""
msgid "GlobalSearch|Merge requests I've created"
msgstr ""
 
......@@ -22963,10 +22966,10 @@ msgstr ""
msgid "GlobalSearch|Type %{kbdOpen}/%{kbdClose} to search"
msgstr ""
 
msgid "GlobalSearch|Type and press the enter key to submit search."
msgid "GlobalSearch|Type for new suggestions to appear below."
msgstr ""
 
msgid "GlobalSearch|Type for new suggestions to appear below."
msgid "GlobalSearch|Type to filter labels."
msgstr ""
 
msgid "GlobalSearch|Users"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment