Commit 21e04bc6 authored by Phil Hughes's avatar Phil Hughes

Remove not equal operator for draft filter

Removes the not equal operator filter for draft filtering
on merge requests.

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/233486
parent 5cf068a4
......@@ -12,6 +12,7 @@ export default (IssuableTokenKeys, disableTargetBranchFilter = false) => {
tag: __('Yes or No'),
lowercaseValueOnSubmit: true,
capitalizeTokenValue: true,
hideNotEqual: true,
},
conditions: [
{
......@@ -22,28 +23,6 @@ export default (IssuableTokenKeys, disableTargetBranchFilter = false) => {
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: '!=',
},
],
};
......
......@@ -39,7 +39,7 @@ export default class DropdownOperator extends FilteredSearchDropdown {
this.dispatchInputEvent();
}
renderContent(forceShowList = false) {
renderContent(forceShowList = false, dropdownName = '') {
const dropdownData = [
{
tag: 'equal',
......@@ -48,8 +48,9 @@ export default class DropdownOperator extends FilteredSearchDropdown {
help: __('is'),
},
];
const dropdownToken = this.tokenKeys.searchByKey(dropdownName.toLowerCase());
if (gon.features?.notIssuableQueries) {
if (gon.features?.notIssuableQueries && !dropdownToken?.hideNotEqual) {
dropdownData.push({
tag: 'not-equal',
type: 'string',
......
......@@ -83,16 +83,16 @@ export default class FilteredSearchDropdown {
}
}
render(forceRenderContent = false, forceShowList = false) {
render(forceRenderContent = false, forceShowList = false, hideNotEqual = false) {
this.setAsDropdown();
const currentHook = this.getCurrentHook();
const firstTimeInitialized = currentHook === null;
if (firstTimeInitialized || forceRenderContent) {
this.renderContent(forceShowList);
this.renderContent(forceShowList, hideNotEqual);
} else if (currentHook.list.list.id !== this.dropdown.id) {
this.renderContent(forceShowList);
this.renderContent(forceShowList, hideNotEqual);
}
}
......
......@@ -107,7 +107,7 @@ export default class FilteredSearchDropdownManager {
this.mapping[key].reference.setOffset(offset);
}
load(key, firstLoad = false) {
load(key, firstLoad = false, dropdownKey = '') {
const mappingKey = this.mapping[key];
const glClass = mappingKey.gl;
const { element } = mappingKey;
......@@ -141,12 +141,12 @@ export default class FilteredSearchDropdownManager {
}
this.updateDropdownOffset(key);
mappingKey.reference.render(firstLoad, forceShowList);
mappingKey.reference.render(firstLoad, forceShowList, dropdownKey);
this.currentDropdown = key;
}
loadDropdown(dropdownName = '') {
loadDropdown(dropdownName = '', dropdownKey = '') {
let firstLoad = false;
if (!this.droplab) {
......@@ -155,7 +155,7 @@ export default class FilteredSearchDropdownManager {
}
if (dropdownName === DROPDOWN_TYPE.operator) {
this.load(dropdownName, firstLoad);
this.load(dropdownName, firstLoad, dropdownKey);
return;
}
......@@ -167,7 +167,7 @@ export default class FilteredSearchDropdownManager {
if (shouldOpenFilterDropdown || shouldOpenHintDropdown) {
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 {
dropdownToOpen = hasOperator && lastOperatorToken ? dropdownName : DROPDOWN_TYPE.operator;
}
this.loadDropdown(dropdownToOpen);
this.loadDropdown(dropdownToOpen, dropdownName);
} else if (lastToken) {
const lastOperator = FilteredSearchVisualTokens.getLastTokenOperator();
// 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 {
this.loadDropdown(DROPDOWN_TYPE.hint);
}
......
---
title: Removed not equal filter option for drafts on merge requests
merge_request:
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