diff options
Diffstat (limited to 'app/assets/javascripts/filtered_search')
10 files changed, 105 insertions, 29 deletions
diff --git a/app/assets/javascripts/filtered_search/add_extra_tokens_for_merge_requests.js b/app/assets/javascripts/filtered_search/add_extra_tokens_for_merge_requests.js index 9440015b32e..80f78c154ee 100644 --- a/app/assets/javascripts/filtered_search/add_extra_tokens_for_merge_requests.js +++ b/app/assets/javascripts/filtered_search/add_extra_tokens_for_merge_requests.js @@ -1,21 +1,55 @@ import { __ } from '~/locale'; export default IssuableTokenKeys => { - const wipToken = { - formattedKey: __('WIP'), - key: 'wip', - type: 'string', - param: '', - symbol: '', - icon: 'admin', - tag: __('Yes or No'), - lowercaseValueOnSubmit: true, - uppercaseTokenName: true, - capitalizeTokenValue: true, + const draftToken = { + token: { + formattedKey: __('Draft'), + key: 'draft', + type: 'string', + param: '', + symbol: '', + icon: 'admin', + tag: __('Yes or No'), + lowercaseValueOnSubmit: true, + capitalizeTokenValue: true, + }, + conditions: [ + { + url: 'wip=yes', + // eslint-disable-next-line @gitlab/require-i18n-strings + replacementUrl: 'draft=yes', + tokenKey: 'draft', + value: __('Yes'), + operator: '=', + }, + { + url: 'wip=no', + // eslint-disable-next-line @gitlab/require-i18n-strings + replacementUrl: 'draft=no', + tokenKey: 'draft', + value: __('No'), + operator: '=', + }, + { + url: 'not[wip]=yes', + replacementUrl: 'not[draft]=yes', + tokenKey: 'draft', + value: __('Yes'), + operator: '!=', + }, + { + url: 'not[wip]=no', + replacementUrl: 'not[draft]=no', + tokenKey: 'draft', + value: __('No'), + operator: '!=', + }, + ], }; - IssuableTokenKeys.tokenKeys.push(wipToken); - IssuableTokenKeys.tokenKeysWithAlternative.push(wipToken); + IssuableTokenKeys.tokenKeys.push(draftToken.token); + IssuableTokenKeys.tokenKeysWithAlternative.push(draftToken.token); + IssuableTokenKeys.conditions.push(...draftToken.conditions); const targetBranchToken = { formattedKey: __('Target-Branch'), diff --git a/app/assets/javascripts/filtered_search/available_dropdown_mappings.js b/app/assets/javascripts/filtered_search/available_dropdown_mappings.js index 692b41da965..49bd3cda127 100644 --- a/app/assets/javascripts/filtered_search/available_dropdown_mappings.js +++ b/app/assets/javascripts/filtered_search/available_dropdown_mappings.js @@ -106,7 +106,7 @@ export default class AvailableDropdownMappings { gl: DropdownEmoji, element: this.container.querySelector('#js-dropdown-my-reaction'), }, - wip: { + draft: { reference: null, gl: DropdownNonUser, element: this.container.querySelector('#js-dropdown-wip'), diff --git a/app/assets/javascripts/filtered_search/components/recent_searches_dropdown_content.vue b/app/assets/javascripts/filtered_search/components/recent_searches_dropdown_content.vue index e2909333d74..0c4abc14494 100644 --- a/app/assets/javascripts/filtered_search/components/recent_searches_dropdown_content.vue +++ b/app/assets/javascripts/filtered_search/components/recent_searches_dropdown_content.vue @@ -20,8 +20,18 @@ export default { }, }, computed: { + /** + * Both Epic and Roadmap pages share same recents store + * and with https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36421 + * Roadmap started using `GlFilteredSearch` which is not compatible + * with string tokens stored in recents, so this is a temporary + * fix by ignoring non-string recents while in Epic page. + */ + compatibleItems() { + return this.items.filter(item => typeof item === 'string'); + }, processedItems() { - return this.items.map(item => { + return this.compatibleItems.map(item => { const { tokens, searchToken } = FilteredSearchTokenizer.processTokens( item, this.allowedKeys, @@ -41,7 +51,7 @@ export default { }); }, hasItems() { - return this.items.length > 0; + return this.compatibleItems.length > 0; }, }, methods: { @@ -84,9 +94,7 @@ export default { <span class="value">{{ token.suffix }}</span> </span> </span> - <span class="filtered-search-history-dropdown-search-token"> - {{ item.searchToken }} - </span> + <span class="filtered-search-history-dropdown-search-token">{{ item.searchToken }}</span> </button> </li> <li class="divider"></li> diff --git a/app/assets/javascripts/filtered_search/dropdown_ajax_filter.js b/app/assets/javascripts/filtered_search/dropdown_ajax_filter.js index 92a64ab60db..4652dfe71c3 100644 --- a/app/assets/javascripts/filtered_search/dropdown_ajax_filter.js +++ b/app/assets/javascripts/filtered_search/dropdown_ajax_filter.js @@ -1,4 +1,4 @@ -import createFlash from '../flash'; +import { deprecatedCreateFlash as createFlash } from '../flash'; import AjaxFilter from '../droplab/plugins/ajax_filter'; import FilteredSearchDropdown from './filtered_search_dropdown'; import DropdownUtils from './dropdown_utils'; diff --git a/app/assets/javascripts/filtered_search/dropdown_emoji.js b/app/assets/javascripts/filtered_search/dropdown_emoji.js index adeea0ed5f6..1e3679b9e3c 100644 --- a/app/assets/javascripts/filtered_search/dropdown_emoji.js +++ b/app/assets/javascripts/filtered_search/dropdown_emoji.js @@ -1,4 +1,4 @@ -import Flash from '../flash'; +import { deprecatedCreateFlash as Flash } from '../flash'; import Ajax from '../droplab/plugins/ajax'; import Filter from '../droplab/plugins/filter'; import FilteredSearchDropdown from './filtered_search_dropdown'; diff --git a/app/assets/javascripts/filtered_search/dropdown_non_user.js b/app/assets/javascripts/filtered_search/dropdown_non_user.js index a2312de289d..bfa9f4a57ca 100644 --- a/app/assets/javascripts/filtered_search/dropdown_non_user.js +++ b/app/assets/javascripts/filtered_search/dropdown_non_user.js @@ -1,4 +1,4 @@ -import Flash from '../flash'; +import { deprecatedCreateFlash as Flash } from '../flash'; import Ajax from '../droplab/plugins/ajax'; import Filter from '../droplab/plugins/filter'; import FilteredSearchDropdown from './filtered_search_dropdown'; diff --git a/app/assets/javascripts/filtered_search/filtered_search_manager.js b/app/assets/javascripts/filtered_search/filtered_search_manager.js index 108cc8d3a78..3e4a9880134 100644 --- a/app/assets/javascripts/filtered_search/filtered_search_manager.js +++ b/app/assets/javascripts/filtered_search/filtered_search_manager.js @@ -3,7 +3,7 @@ import recentSearchesStorageKeys from 'ee_else_ce/filtered_search/recent_searche import { getParameterByName, getUrlParamsArray } from '~/lib/utils/common_utils'; import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys'; import { visitUrl } from '../lib/utils/url_utility'; -import Flash from '../flash'; +import { deprecatedCreateFlash as Flash } from '../flash'; import FilteredSearchContainer from './container'; import RecentSearchesRoot from './recent_searches_root'; import RecentSearchesStore from './stores/recent_searches_store'; @@ -29,6 +29,7 @@ export default class FilteredSearchManager { isGroup = false, isGroupAncestor = true, isGroupDecendent = false, + useDefaultState = false, filteredSearchTokenKeys = IssuableFilteredSearchTokenKeys, stateFiltersSelector = '.issues-state-filters', placeholder = __('Search or filter results...'), @@ -37,6 +38,7 @@ export default class FilteredSearchManager { this.isGroup = isGroup; this.isGroupAncestor = isGroupAncestor; this.isGroupDecendent = isGroupDecendent; + this.useDefaultState = useDefaultState; this.states = ['opened', 'closed', 'merged', 'all']; this.page = page; @@ -724,8 +726,13 @@ export default class FilteredSearchManager { search(state = null) { const paths = []; const { tokens, searchToken } = this.getSearchTokens(); - const currentState = state || getParameterByName('state') || 'opened'; - paths.push(`state=${currentState}`); + let currentState = state || getParameterByName('state'); + if (!currentState && this.useDefaultState) { + currentState = 'opened'; + } + if (this.states.includes(currentState)) { + paths.push(`state=${currentState}`); + } tokens.forEach(token => { const condition = this.filteredSearchTokenKeys.searchByConditionKeyValue( @@ -743,7 +750,7 @@ export default class FilteredSearchManager { let tokenPath = ''; if (condition) { - tokenPath = condition.url; + tokenPath = condition.replacementUrl || condition.url; } else { let tokenValue = token.value; diff --git a/app/assets/javascripts/filtered_search/filtered_search_visual_tokens.js b/app/assets/javascripts/filtered_search/filtered_search_visual_tokens.js index 5298e20557d..f0951f6b177 100644 --- a/app/assets/javascripts/filtered_search/filtered_search_visual_tokens.js +++ b/app/assets/javascripts/filtered_search/filtered_search_visual_tokens.js @@ -1,5 +1,5 @@ import VisualTokenValue from './visual_token_value'; -import { objectToQueryString } from '~/lib/utils/common_utils'; +import { objectToQueryString, spriteIcon } from '~/lib/utils/common_utils'; import FilteredSearchContainer from './container'; export default class FilteredSearchVisualTokens { @@ -84,7 +84,7 @@ export default class FilteredSearchVisualTokens { <div class="value-container"> <div class="${capitalizeTokenValue ? 'text-capitalize' : ''} value"></div> <div class="remove-token" role="button"> - <i class="fa fa-close"></i> + ${spriteIcon('close', 's16 close-icon')} </div> </div> </div> diff --git a/app/assets/javascripts/filtered_search/group_runners_filtered_search_token_keys.js b/app/assets/javascripts/filtered_search/group_runners_filtered_search_token_keys.js new file mode 100644 index 00000000000..ceeb71c4eec --- /dev/null +++ b/app/assets/javascripts/filtered_search/group_runners_filtered_search_token_keys.js @@ -0,0 +1,27 @@ +import { __ } from '~/locale'; +import FilteredSearchTokenKeys from './filtered_search_token_keys'; + +const tokenKeys = [ + { + formattedKey: __('Status'), + key: 'status', + type: 'string', + param: 'status', + symbol: '', + icon: 'messages', + tag: 'status', + }, + { + formattedKey: __('Type'), + key: 'type', + type: 'string', + param: 'type', + symbol: '', + icon: 'cube', + tag: 'type', + }, +]; + +const GroupRunnersFilteredSearchTokenKeys = new FilteredSearchTokenKeys(tokenKeys); + +export default GroupRunnersFilteredSearchTokenKeys; diff --git a/app/assets/javascripts/filtered_search/visual_token_value.js b/app/assets/javascripts/filtered_search/visual_token_value.js index b1e6c4142e9..f73646da6d1 100644 --- a/app/assets/javascripts/filtered_search/visual_token_value.js +++ b/app/assets/javascripts/filtered_search/visual_token_value.js @@ -4,7 +4,7 @@ import FilteredSearchContainer from '~/filtered_search/container'; import FilteredSearchVisualTokens from '~/filtered_search/filtered_search_visual_tokens'; import AjaxCache from '~/lib/utils/ajax_cache'; import DropdownUtils from '~/filtered_search/dropdown_utils'; -import Flash from '~/flash'; +import { deprecatedCreateFlash as Flash } from '~/flash'; import UsersCache from '~/lib/utils/users_cache'; import { __ } from '~/locale'; import * as Emoji from '~/emoji'; |