提交 bd9ae901 编写于 作者: R Robert Schilling

Ability to filter confidential issues

Add a new search bar filter for confidential issues. Add filtering
support to the IssuesFinder.
上级 3de4c8d0
...@@ -96,6 +96,11 @@ export default class FilteredSearchDropdownManager { ...@@ -96,6 +96,11 @@ export default class FilteredSearchDropdownManager {
gl: DropdownNonUser, gl: DropdownNonUser,
element: this.container.querySelector('#js-dropdown-wip'), element: this.container.querySelector('#js-dropdown-wip'),
}, },
confidential: {
reference: null,
gl: DropdownNonUser,
element: this.container.querySelector('#js-dropdown-confidential'),
},
status: { status: {
reference: null, reference: null,
gl: NullDropdown, gl: NullDropdown,
......
...@@ -72,6 +72,23 @@ export default class FilteredSearchTokenKeys { ...@@ -72,6 +72,23 @@ export default class FilteredSearchTokenKeys {
); );
} }
addExtraTokensForIssues() {
const confidentialToken = {
key: 'confidential',
type: 'string',
param: '',
symbol: '',
icon: 'eye-slash',
tag: 'Yes or No',
lowercaseValueOnSubmit: true,
uppercaseTokenName: false,
capitalizeTokenValue: true,
};
this.tokenKeys.push(confidentialToken);
this.tokenKeysWithAlternative.push(confidentialToken);
}
addExtraTokensForMergeRequests() { addExtraTokensForMergeRequests() {
const wipToken = { const wipToken = {
key: 'wip', key: 'wip',
......
...@@ -4,6 +4,8 @@ import { FILTERED_SEARCH } from '~/pages/constants'; ...@@ -4,6 +4,8 @@ import { FILTERED_SEARCH } from '~/pages/constants';
import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys'; import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
IssuableFilteredSearchTokenKeys.addExtraTokensForIssues();
initFilteredSearch({ initFilteredSearch({
page: FILTERED_SEARCH.ISSUES, page: FILTERED_SEARCH.ISSUES,
isGroupDecendent: true, isGroupDecendent: true,
......
...@@ -9,6 +9,8 @@ import { FILTERED_SEARCH } from '~/pages/constants'; ...@@ -9,6 +9,8 @@ import { FILTERED_SEARCH } from '~/pages/constants';
import { ISSUABLE_INDEX } from '~/pages/projects/constants'; import { ISSUABLE_INDEX } from '~/pages/projects/constants';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
IssuableFilteredSearchTokenKeys.addExtraTokensForIssues();
initFilteredSearch({ initFilteredSearch({
page: FILTERED_SEARCH.ISSUES, page: FILTERED_SEARCH.ISSUES,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeys, filteredSearchTokenKeys: IssuableFilteredSearchTokenKeys,
......
...@@ -91,6 +91,7 @@ module IssuableCollections ...@@ -91,6 +91,7 @@ module IssuableCollections
options = { options = {
scope: params[:scope], scope: params[:scope],
state: params[:state], state: params[:state],
confidential: params[:confidential],
sort: set_sort_order sort: set_sort_order
} }
......
...@@ -69,9 +69,22 @@ class IssuesFinder < IssuableFinder ...@@ -69,9 +69,22 @@ class IssuesFinder < IssuableFinder
end end
def filter_items(items) def filter_items(items)
by_due_date(super) issues = by_due_date(super)
by_confidential(issues)
end end
# rubocop: disable CodeReuse/ActiveRecord
def by_confidential(items)
if params[:confidential] == 'yes'
items.where('issues.confidential = TRUE')
elsif params[:confidential] == 'no'
items.where.not('issues.confidential = TRUE')
else
items
end
end
# rubocop: enable CodeReuse/ActiveRecord
def by_due_date(items) def by_due_date(items)
if due_date? if due_date?
if filter_by_no_due_date? if filter_by_no_due_date?
......
...@@ -128,6 +128,14 @@ ...@@ -128,6 +128,14 @@
%li.filter-dropdown-item{ data: { value: 'no', capitalize: true } } %li.filter-dropdown-item{ data: { value: 'no', capitalize: true } }
%button.btn.btn-link{ type: 'button' } %button.btn.btn-link{ type: 'button' }
= _('No') = _('No')
#js-dropdown-confidential.filtered-search-input-dropdown-menu.dropdown-menu
%ul.filter-dropdown{ data: { dropdown: true } }
%li.filter-dropdown-item{ data: { value: 'yes', capitalize: true } }
%button.btn.btn-link{ type: 'button' }
= _('Yes')
%li.filter-dropdown-item{ data: { value: 'no', capitalize: true } }
%button.btn.btn-link{ type: 'button' }
= _('No')
= render_if_exists 'shared/issuable/filter_weight', type: type = render_if_exists 'shared/issuable/filter_weight', type: type
......
---
title: Ability to filter confidential issues
merge_request: 24960
author: Robert Schilling
type: added
...@@ -113,6 +113,7 @@ describe IssuableCollections do ...@@ -113,6 +113,7 @@ describe IssuableCollections do
author_id: '2', author_id: '2',
author_username: 'user2', author_username: 'user2',
authorized_only: 'true', authorized_only: 'true',
confidential: 'yes',
due_date: '2017-01-01', due_date: '2017-01-01',
group_id: '3', group_id: '3',
iids: '4', iids: '4',
...@@ -140,6 +141,7 @@ describe IssuableCollections do ...@@ -140,6 +141,7 @@ describe IssuableCollections do
'assignee_username' => 'user1', 'assignee_username' => 'user1',
'author_id' => '2', 'author_id' => '2',
'author_username' => 'user2', 'author_username' => 'user2',
'confidential' => 'yes',
'label_name' => 'foo', 'label_name' => 'foo',
'milestone_title' => 'bar', 'milestone_title' => 'bar',
'my_reaction_emoji' => 'thumbsup', 'my_reaction_emoji' => 'thumbsup',
......
...@@ -66,7 +66,7 @@ describe 'Dropdown hint', :js do ...@@ -66,7 +66,7 @@ describe 'Dropdown hint', :js do
it 'filters with text' do it 'filters with text' do
filtered_search.set('a') filtered_search.set('a')
expect(find(js_dropdown_hint)).to have_selector('.filter-dropdown .filter-dropdown-item', count: 4) expect(find(js_dropdown_hint)).to have_selector('.filter-dropdown .filter-dropdown-item', count: 5)
end end
end end
......
...@@ -100,7 +100,7 @@ describe 'Search bar', :js do ...@@ -100,7 +100,7 @@ describe 'Search bar', :js do
find('.filtered-search-box .clear-search').click find('.filtered-search-box .clear-search').click
filtered_search.click filtered_search.click
expect(find('#js-dropdown-hint')).to have_selector('.filter-dropdown .filter-dropdown-item', count: 5) expect(find('#js-dropdown-hint')).to have_selector('.filter-dropdown .filter-dropdown-item', count: 6)
expect(get_left_style(find('#js-dropdown-hint')['style'])).to eq(hint_offset) expect(get_left_style(find('#js-dropdown-hint')['style'])).to eq(hint_offset)
end end
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册