Commit 91e97c80 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '54213-standardize-token-value-capitalization-in-filter-bar' into 'master'

Standardize token value capitalization in filter bar

Closes #54213

See merge request gitlab-org/gitlab-ce!23846
parents c2b3f64c 6e50b42e
......@@ -593,7 +593,7 @@ export default class FilteredSearchManager {
tokens.forEach(token => {
const condition = this.filteredSearchTokenKeys.searchByConditionKeyValue(
token.key,
token.value.toLowerCase(),
token.value,
);
const tokenConfig = this.filteredSearchTokenKeys.searchByKey(token.key) || {};
const { param } = tokenConfig;
......
......@@ -65,8 +65,10 @@ export default class FilteredSearchTokenKeys {
searchByConditionKeyValue(key, value) {
return (
this.conditions.find(condition => condition.tokenKey === key && condition.value === value) ||
null
this.conditions.find(
condition =>
condition.tokenKey === key && condition.value.toLowerCase() === value.toLowerCase(),
) || null
);
}
......
......@@ -60,52 +60,52 @@ export const conditions = [
{
url: 'assignee_id=None',
tokenKey: 'assignee',
value: 'none',
value: 'None',
},
{
url: 'assignee_id=Any',
tokenKey: 'assignee',
value: 'any',
value: 'Any',
},
{
url: 'milestone_title=None',
tokenKey: 'milestone',
value: 'none',
value: 'None',
},
{
url: 'milestone_title=Any',
tokenKey: 'milestone',
value: 'any',
value: 'Any',
},
{
url: 'milestone_title=%23upcoming',
tokenKey: 'milestone',
value: 'upcoming',
value: 'Upcoming',
},
{
url: 'milestone_title=%23started',
tokenKey: 'milestone',
value: 'started',
value: 'Started',
},
{
url: 'label_name[]=None',
tokenKey: 'label',
value: 'none',
value: 'None',
},
{
url: 'label_name[]=Any',
tokenKey: 'any',
value: 'any',
tokenKey: 'label',
value: 'Any',
},
{
url: 'my_reaction_emoji=None',
tokenKey: 'my-reaction',
value: 'none',
value: 'None',
},
{
url: 'my_reaction_emoji=Any',
tokenKey: 'my-reaction',
value: 'any',
value: 'Any',
},
];
......
......@@ -57,10 +57,10 @@
avatar: { lazy: true, url: '{{avatar_url}}' }
#js-dropdown-assignee.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'none' } }
%li.filter-dropdown-item{ data: { value: 'None' } }
%button.btn.btn-link{ type: 'button' }
= _('None')
%li.filter-dropdown-item{ data: { value: 'any' } }
%li.filter-dropdown-item{ data: { value: 'Any' } }
%button.btn.btn-link{ type: 'button' }
= _('Any')
%li.divider.droplab-item-ignore
......@@ -73,16 +73,16 @@
avatar: { lazy: true, url: '{{avatar_url}}' }
#js-dropdown-milestone.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'none' } }
%li.filter-dropdown-item{ data: { value: 'None' } }
%button.btn.btn-link{ type: 'button' }
= _('None')
%li.filter-dropdown-item{ data: { value: 'any' } }
%li.filter-dropdown-item{ data: { value: 'Any' } }
%button.btn.btn-link{ type: 'button' }
= _('Any')
%li.filter-dropdown-item{ data: { value: 'upcoming' } }
%li.filter-dropdown-item{ data: { value: 'Upcoming' } }
%button.btn.btn-link{ type: 'button' }
= _('Upcoming')
%li.filter-dropdown-item{ data: { value: 'started' } }
%li.filter-dropdown-item{ data: { value: 'Started' } }
%button.btn.btn-link{ type: 'button' }
= _('Started')
%li.divider.droplab-item-ignore
......@@ -92,10 +92,10 @@
{{title}}
#js-dropdown-label.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'none' } }
%li.filter-dropdown-item{ data: { value: 'None' } }
%button.btn.btn-link{ type: 'button' }
= _('None')
%li.filter-dropdown-item{ data: { value: 'any' } }
%li.filter-dropdown-item{ data: { value: 'Any' } }
%button.btn.btn-link{ type: 'button' }
= _('Any')
%li.divider.droplab-item-ignore
......@@ -107,10 +107,10 @@
{{title}}
#js-dropdown-my-reaction.filtered-search-input-dropdown-menu.dropdown-menu
%ul{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'none' } }
%li.filter-dropdown-item{ data: { value: 'None' } }
%button.btn.btn-link{ type: 'button' }
= _('None')
%li.filter-dropdown-item{ data: { value: 'any' } }
%li.filter-dropdown-item{ data: { value: 'Any' } }
%button.btn.btn-link{ type: 'button' }
= _('Any')
%li.divider.droplab-item-ignore
......
---
title: Standardize filter value capitlization in filter bar in both issues and boards pages
merge_request: 23846
author: obahareth
type: changed
......@@ -112,7 +112,7 @@ describe 'Issue Boards add issue modal filtering', :js do
page.within('.add-issues-modal') do
wait_for_requests
expect(page).to have_selector('.js-visual-token', text: 'none')
expect(page).to have_selector('.js-visual-token', text: 'None')
expect(page).to have_selector('.board-card', count: 1)
end
end
......@@ -147,7 +147,7 @@ describe 'Issue Boards add issue modal filtering', :js do
page.within('.add-issues-modal') do
wait_for_requests
expect(page).to have_selector('.js-visual-token', text: 'upcoming')
expect(page).to have_selector('.js-visual-token', text: 'Upcoming')
expect(page).to have_selector('.board-card', count: 0)
end
end
......@@ -182,7 +182,7 @@ describe 'Issue Boards add issue modal filtering', :js do
page.within('.add-issues-modal') do
wait_for_requests
expect(page).to have_selector('.js-visual-token', text: 'none')
expect(page).to have_selector('.js-visual-token', text: 'None')
expect(page).to have_selector('.board-card', count: 1)
end
end
......
......@@ -160,7 +160,7 @@ describe 'Dropdown assignee', :js do
find('#js-dropdown-assignee .filter-dropdown-item', text: 'None').click
expect(page).to have_css(js_dropdown_assignee, visible: false)
expect_tokens([assignee_token('none')])
expect_tokens([assignee_token('None')])
expect_filtered_search_input_empty
end
......@@ -168,7 +168,7 @@ describe 'Dropdown assignee', :js do
find('#js-dropdown-assignee .filter-dropdown-item', text: 'Any').click
expect(page).to have_css(js_dropdown_assignee, visible: false)
expect_tokens([assignee_token('any')])
expect_tokens([assignee_token('Any')])
expect_filtered_search_input_empty
end
end
......
......@@ -125,7 +125,7 @@ describe 'Dropdown emoji', :js do
find('#js-dropdown-my-reaction .filter-dropdown-item', text: 'None').click
expect(page).to have_css(js_dropdown_emoji, visible: false)
expect_tokens([reaction_token('none', false)])
expect_tokens([reaction_token('None', false)])
expect_filtered_search_input_empty
end
......@@ -133,7 +133,7 @@ describe 'Dropdown emoji', :js do
find('#js-dropdown-my-reaction .filter-dropdown-item', text: 'Any').click
expect(page).to have_css(js_dropdown_emoji, visible: false)
expect_tokens([reaction_token('any', false)])
expect_tokens([reaction_token('Any', false)])
expect_filtered_search_input_empty
end
......
......@@ -238,7 +238,7 @@ describe 'Dropdown label', :js do
find("#{js_dropdown_label} .filter-dropdown-item", text: 'None').click
expect(page).not_to have_css(js_dropdown_label)
expect_tokens([label_token('none', false)])
expect_tokens([label_token('None', false)])
expect_filtered_search_input_empty
end
......@@ -246,7 +246,7 @@ describe 'Dropdown label', :js do
find("#{js_dropdown_label} .filter-dropdown-item", text: 'Any').click
expect(page).not_to have_css(js_dropdown_label)
expect_tokens([label_token('any', false)])
expect_tokens([label_token('Any', false)])
expect_filtered_search_input_empty
end
end
......
......@@ -192,7 +192,7 @@ describe 'Dropdown milestone', :js do
click_static_milestone('None')
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect_tokens([milestone_token('none', false)])
expect_tokens([milestone_token('None', false)])
expect_filtered_search_input_empty
end
......@@ -200,7 +200,7 @@ describe 'Dropdown milestone', :js do
click_static_milestone('Any')
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect_tokens([milestone_token('any', false)])
expect_tokens([milestone_token('Any', false)])
expect_filtered_search_input_empty
end
......@@ -208,7 +208,7 @@ describe 'Dropdown milestone', :js do
click_static_milestone('Upcoming')
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect_tokens([milestone_token('upcoming', false)])
expect_tokens([milestone_token('Upcoming', false)])
expect_filtered_search_input_empty
end
......@@ -216,7 +216,7 @@ describe 'Dropdown milestone', :js do
click_static_milestone('Started')
expect(page).to have_css(js_dropdown_milestone, visible: false)
expect_tokens([milestone_token('started', false)])
expect_tokens([milestone_token('Started', false)])
expect_filtered_search_input_empty
end
end
......
......@@ -108,7 +108,7 @@ describe 'Filter issues', :js do
it 'filters issues by no assignee' do
input_filtered_search('assignee:none')
expect_tokens([assignee_token('none')])
expect_tokens([assignee_token('None')])
expect_issues_list_count(3)
expect_filtered_search_input_empty
end
......@@ -146,7 +146,7 @@ describe 'Filter issues', :js do
it 'filters issues by no label' do
input_filtered_search('label:none')
expect_tokens([label_token('none', false)])
expect_tokens([label_token('None', false)])
expect_issues_list_count(4)
expect_filtered_search_input_empty
end
......@@ -287,7 +287,7 @@ describe 'Filter issues', :js do
it 'filters issues by no milestone' do
input_filtered_search("milestone:none")
expect_tokens([milestone_token('none', false)])
expect_tokens([milestone_token('None', false)])
expect_issues_list_count(3)
expect_filtered_search_input_empty
end
......@@ -299,7 +299,7 @@ describe 'Filter issues', :js do
input_filtered_search("milestone:upcoming")
expect_tokens([milestone_token('upcoming', false)])
expect_tokens([milestone_token('Upcoming', false)])
expect_issues_list_count(1)
expect_filtered_search_input_empty
end
......@@ -307,7 +307,7 @@ describe 'Filter issues', :js do
it 'filters issues by started milestones' do
input_filtered_search("milestone:started")
expect_tokens([milestone_token('started', false)])
expect_tokens([milestone_token('Started', false)])
expect_issues_list_count(5)
expect_filtered_search_input_empty
end
......
......@@ -122,7 +122,7 @@ describe 'Visual tokens', :js do
end
it 'changes value in visual token' do
expect(first('.tokens-container .filtered-search-token .value').text).to eq('none')
expect(first('.tokens-container .filtered-search-token .value').text).to eq('None')
end
it 'moves input to the right' do
......@@ -147,7 +147,7 @@ describe 'Visual tokens', :js do
it 'selects static option from dropdown' do
find("#js-dropdown-milestone").find('.filter-dropdown-item', text: 'Upcoming').click
expect(first('.tokens-container .filtered-search-token .value').text).to eq('upcoming')
expect(first('.tokens-container .filtered-search-token .value').text).to eq('Upcoming')
expect(is_input_focused).to eq(true)
end
......@@ -348,7 +348,7 @@ describe 'Visual tokens', :js do
it 'tokenizes the search term to complete visual token' do
expect_tokens([
author_token(user.name),
assignee_token('none')
assignee_token('None')
])
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment