Commit 77038586 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/233486/removeDraftIsNotFilter' into 'master'

Remove not equal operator for draft filter

See merge request gitlab-org/gitlab!45649
parents edff5749 c52af3da
...@@ -12,6 +12,7 @@ export default (IssuableTokenKeys, disableTargetBranchFilter = false) => { ...@@ -12,6 +12,7 @@ export default (IssuableTokenKeys, disableTargetBranchFilter = false) => {
tag: __('Yes or No'), tag: __('Yes or No'),
lowercaseValueOnSubmit: true, lowercaseValueOnSubmit: true,
capitalizeTokenValue: true, capitalizeTokenValue: true,
hideNotEqual: true,
}, },
conditions: [ conditions: [
{ {
...@@ -30,20 +31,6 @@ export default (IssuableTokenKeys, disableTargetBranchFilter = false) => { ...@@ -30,20 +31,6 @@ export default (IssuableTokenKeys, disableTargetBranchFilter = false) => {
value: __('No'), value: __('No'),
operator: '=', 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: '!=',
},
], ],
}; };
......
...@@ -39,7 +39,7 @@ export default class DropdownOperator extends FilteredSearchDropdown { ...@@ -39,7 +39,7 @@ export default class DropdownOperator extends FilteredSearchDropdown {
this.dispatchInputEvent(); this.dispatchInputEvent();
} }
renderContent(forceShowList = false) { renderContent(forceShowList = false, dropdownName = '') {
const dropdownData = [ const dropdownData = [
{ {
tag: 'equal', tag: 'equal',
...@@ -48,8 +48,9 @@ export default class DropdownOperator extends FilteredSearchDropdown { ...@@ -48,8 +48,9 @@ export default class DropdownOperator extends FilteredSearchDropdown {
help: __('is'), help: __('is'),
}, },
]; ];
const dropdownToken = this.tokenKeys.searchByKey(dropdownName.toLowerCase());
if (gon.features?.notIssuableQueries) { if (gon.features?.notIssuableQueries && !dropdownToken?.hideNotEqual) {
dropdownData.push({ dropdownData.push({
tag: 'not-equal', tag: 'not-equal',
type: 'string', type: 'string',
......
...@@ -83,16 +83,16 @@ export default class FilteredSearchDropdown { ...@@ -83,16 +83,16 @@ export default class FilteredSearchDropdown {
} }
} }
render(forceRenderContent = false, forceShowList = false) { render(forceRenderContent = false, forceShowList = false, hideNotEqual = false) {
this.setAsDropdown(); this.setAsDropdown();
const currentHook = this.getCurrentHook(); const currentHook = this.getCurrentHook();
const firstTimeInitialized = currentHook === null; const firstTimeInitialized = currentHook === null;
if (firstTimeInitialized || forceRenderContent) { if (firstTimeInitialized || forceRenderContent) {
this.renderContent(forceShowList); this.renderContent(forceShowList, hideNotEqual);
} else if (currentHook.list.list.id !== this.dropdown.id) { } else if (currentHook.list.list.id !== this.dropdown.id) {
this.renderContent(forceShowList); this.renderContent(forceShowList, hideNotEqual);
} }
} }
......
...@@ -107,7 +107,7 @@ export default class FilteredSearchDropdownManager { ...@@ -107,7 +107,7 @@ export default class FilteredSearchDropdownManager {
this.mapping[key].reference.setOffset(offset); this.mapping[key].reference.setOffset(offset);
} }
load(key, firstLoad = false) { load(key, firstLoad = false, dropdownKey = '') {
const mappingKey = this.mapping[key]; const mappingKey = this.mapping[key];
const glClass = mappingKey.gl; const glClass = mappingKey.gl;
const { element } = mappingKey; const { element } = mappingKey;
...@@ -141,12 +141,12 @@ export default class FilteredSearchDropdownManager { ...@@ -141,12 +141,12 @@ export default class FilteredSearchDropdownManager {
} }
this.updateDropdownOffset(key); this.updateDropdownOffset(key);
mappingKey.reference.render(firstLoad, forceShowList); mappingKey.reference.render(firstLoad, forceShowList, dropdownKey);
this.currentDropdown = key; this.currentDropdown = key;
} }
loadDropdown(dropdownName = '') { loadDropdown(dropdownName = '', dropdownKey = '') {
let firstLoad = false; let firstLoad = false;
if (!this.droplab) { if (!this.droplab) {
...@@ -155,7 +155,7 @@ export default class FilteredSearchDropdownManager { ...@@ -155,7 +155,7 @@ export default class FilteredSearchDropdownManager {
} }
if (dropdownName === DROPDOWN_TYPE.operator) { if (dropdownName === DROPDOWN_TYPE.operator) {
this.load(dropdownName, firstLoad); this.load(dropdownName, firstLoad, dropdownKey);
return; return;
} }
...@@ -167,7 +167,7 @@ export default class FilteredSearchDropdownManager { ...@@ -167,7 +167,7 @@ export default class FilteredSearchDropdownManager {
if (shouldOpenFilterDropdown || shouldOpenHintDropdown) { if (shouldOpenFilterDropdown || shouldOpenHintDropdown) {
const key = match && match.key ? match.key : DROPDOWN_TYPE.hint; const key = match && match.key ? match.key : DROPDOWN_TYPE.hint;
this.load(key, firstLoad); this.load(key, firstLoad, dropdownKey);
} }
} }
...@@ -200,11 +200,11 @@ export default class FilteredSearchDropdownManager { ...@@ -200,11 +200,11 @@ export default class FilteredSearchDropdownManager {
dropdownToOpen = hasOperator && lastOperatorToken ? dropdownName : DROPDOWN_TYPE.operator; dropdownToOpen = hasOperator && lastOperatorToken ? dropdownName : DROPDOWN_TYPE.operator;
} }
this.loadDropdown(dropdownToOpen); this.loadDropdown(dropdownToOpen, dropdownName);
} else if (lastToken) { } else if (lastToken) {
const lastOperator = FilteredSearchVisualTokens.getLastTokenOperator(); const lastOperator = FilteredSearchVisualTokens.getLastTokenOperator();
// Token has been initialized into an object because it has a value // Token has been initialized into an object because it has a value
this.loadDropdown(lastOperator ? lastToken.key : DROPDOWN_TYPE.operator); this.loadDropdown(lastOperator ? lastToken.key : DROPDOWN_TYPE.operator, lastToken.key);
} else { } else {
this.loadDropdown(DROPDOWN_TYPE.hint); this.loadDropdown(DROPDOWN_TYPE.hint);
} }
......
---
title: Removed not equal filter option for drafts on merge requests
merge_request: 45649
author:
type: fixed
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Merge Requests > User filters by draft', :js do
include FilteredSearchHelpers
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
before do
create(:merge_request, title: 'Draft: Bugfix', source_project: project, target_project: project, source_branch: 'bugfix2')
sign_in(user)
visit project_merge_requests_path(project)
end
it 'filters results' do
input_filtered_search_keys('draft:=yes')
expect(page).to have_content('Draft: Bugfix')
end
it 'does not allow filtering by is not equal' do
find('#filtered-search-merge_requests').click
click_button 'Draft'
expect(page).not_to have_content('!=')
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