diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-12 00:08:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-12 00:08:44 +0300 |
commit | a66475b6beb46d77b9ff3fe30453be2d52779048 (patch) | |
tree | 39fd943e67dd66b1d734028f5449d8a41c4fe58f /app/assets/javascripts/search | |
parent | 48e26d30fd251f87a2e136d8997ef2ec35859e71 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/search')
-rw-r--r-- | app/assets/javascripts/search/state_filter/components/state_filter.vue | 35 | ||||
-rw-r--r-- | app/assets/javascripts/search/state_filter/constants.js | 19 |
2 files changed, 38 insertions, 16 deletions
diff --git a/app/assets/javascripts/search/state_filter/components/state_filter.vue b/app/assets/javascripts/search/state_filter/components/state_filter.vue index 5245c23843e..f08adaf8c83 100644 --- a/app/assets/javascripts/search/state_filter/components/state_filter.vue +++ b/app/assets/javascripts/search/state_filter/components/state_filter.vue @@ -1,6 +1,12 @@ <script> import { GlDropdown, GlDropdownItem, GlDropdownDivider } from '@gitlab/ui'; -import { FILTER_STATES, FILTER_HEADER, FILTER_TEXT } from '../constants'; +import { + FILTER_STATES, + SCOPES, + FILTER_STATES_BY_SCOPE, + FILTER_HEADER, + FILTER_TEXT, +} from '../constants'; import { setUrlParams, visitUrl } from '~/lib/utils/url_utility'; const FILTERS_ARRAY = Object.values(FILTER_STATES); @@ -26,13 +32,15 @@ export default { }, computed: { selectedFilterText() { - let filterText = FILTER_TEXT; - if (this.selectedFilter === FILTER_STATES.CLOSED.value) { - filterText = FILTER_STATES.CLOSED.label; - } else if (this.selectedFilter === FILTER_STATES.OPEN.value) { - filterText = FILTER_STATES.OPEN.label; + const filter = FILTERS_ARRAY.find(({ value }) => value === this.selectedFilter); + if (!filter || filter === FILTER_STATES.ANY) { + return FILTER_TEXT; } - return filterText; + + return filter.label; + }, + showDropdown() { + return Object.values(SCOPES).includes(this.scope); }, selectedFilter: { get() { @@ -63,29 +71,24 @@ export default { }, filterStates: FILTER_STATES, filterHeader: FILTER_HEADER, - filtersArray: FILTERS_ARRAY, + filtersByScope: FILTER_STATES_BY_SCOPE, }; </script> <template> - <gl-dropdown - v-if="scope === 'issues'" - :text="selectedFilterText" - class="col-sm-3 gl-pt-4 gl-pl-0" - > + <gl-dropdown v-if="showDropdown" :text="selectedFilterText" class="col-sm-3 gl-pt-4 gl-pl-0"> <header class="gl-text-center gl-font-weight-bold gl-font-lg"> {{ $options.filterHeader }} </header> <gl-dropdown-divider /> <gl-dropdown-item - v-for="filter in $options.filtersArray" + v-for="filter in $options.filtersByScope[scope]" :key="filter.value" :is-check-item="true" :is-checked="isFilterSelected(filter.value)" :class="dropDownItemClass(filter)" @click="handleFilterChange(filter.value)" + >{{ filter.label }}</gl-dropdown-item > - {{ filter.label }} - </gl-dropdown-item> </gl-dropdown> </template> diff --git a/app/assets/javascripts/search/state_filter/constants.js b/app/assets/javascripts/search/state_filter/constants.js index 25728486360..2f11cab9044 100644 --- a/app/assets/javascripts/search/state_filter/constants.js +++ b/app/assets/javascripts/search/state_filter/constants.js @@ -17,4 +17,23 @@ export const FILTER_STATES = { label: __('Closed'), value: 'closed', }, + MERGED: { + label: __('Merged'), + value: 'merged', + }, +}; + +export const SCOPES = { + ISSUES: 'issues', + MERGE_REQUESTS: 'merge_requests', +}; + +export const FILTER_STATES_BY_SCOPE = { + [SCOPES.ISSUES]: [FILTER_STATES.ANY, FILTER_STATES.OPEN, FILTER_STATES.CLOSED], + [SCOPES.MERGE_REQUESTS]: [ + FILTER_STATES.ANY, + FILTER_STATES.OPEN, + FILTER_STATES.MERGED, + FILTER_STATES.CLOSED, + ], }; |