Skip to content
Snippets Groups Projects
Commit bd9ae901 authored by Robert Schilling's avatar Robert Schilling
Browse files

Ability to filter confidential issues

Add a new search bar filter for confidential issues. Add filtering
support to the IssuesFinder.
parent 3de4c8d0
No related branches found
No related tags found
No related merge requests found
Showing
with 58 additions and 3 deletions
Loading
Loading
@@ -96,6 +96,11 @@ export default class FilteredSearchDropdownManager {
gl: DropdownNonUser,
element: this.container.querySelector('#js-dropdown-wip'),
},
confidential: {
reference: null,
gl: DropdownNonUser,
element: this.container.querySelector('#js-dropdown-confidential'),
},
status: {
reference: null,
gl: NullDropdown,
Loading
Loading
Loading
Loading
@@ -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() {
const wipToken = {
key: 'wip',
Loading
Loading
Loading
Loading
@@ -4,6 +4,8 @@ import { FILTERED_SEARCH } from '~/pages/constants';
import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys';
 
document.addEventListener('DOMContentLoaded', () => {
IssuableFilteredSearchTokenKeys.addExtraTokensForIssues();
initFilteredSearch({
page: FILTERED_SEARCH.ISSUES,
isGroupDecendent: true,
Loading
Loading
Loading
Loading
@@ -9,6 +9,8 @@ import { FILTERED_SEARCH } from '~/pages/constants';
import { ISSUABLE_INDEX } from '~/pages/projects/constants';
 
document.addEventListener('DOMContentLoaded', () => {
IssuableFilteredSearchTokenKeys.addExtraTokensForIssues();
initFilteredSearch({
page: FILTERED_SEARCH.ISSUES,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeys,
Loading
Loading
Loading
Loading
@@ -91,6 +91,7 @@ module IssuableCollections
options = {
scope: params[:scope],
state: params[:state],
confidential: params[:confidential],
sort: set_sort_order
}
 
Loading
Loading
Loading
Loading
@@ -69,9 +69,22 @@ class IssuesFinder < IssuableFinder
end
 
def filter_items(items)
by_due_date(super)
issues = by_due_date(super)
by_confidential(issues)
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)
if due_date?
if filter_by_no_due_date?
Loading
Loading
Loading
Loading
@@ -128,6 +128,14 @@
%li.filter-dropdown-item{ data: { value: 'no', capitalize: true } }
%button.btn.btn-link{ type: 'button' }
= _('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
 
Loading
Loading
---
title: Ability to filter confidential issues
merge_request: 24960
author: Robert Schilling
type: added
Loading
Loading
@@ -113,6 +113,7 @@ describe IssuableCollections do
author_id: '2',
author_username: 'user2',
authorized_only: 'true',
confidential: 'yes',
due_date: '2017-01-01',
group_id: '3',
iids: '4',
Loading
Loading
@@ -140,6 +141,7 @@ describe IssuableCollections do
'assignee_username' => 'user1',
'author_id' => '2',
'author_username' => 'user2',
'confidential' => 'yes',
'label_name' => 'foo',
'milestone_title' => 'bar',
'my_reaction_emoji' => 'thumbsup',
Loading
Loading
Loading
Loading
@@ -66,7 +66,7 @@ describe 'Dropdown hint', :js do
it 'filters with text' do
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
 
Loading
Loading
Loading
Loading
@@ -100,7 +100,7 @@ describe 'Search bar', :js do
find('.filtered-search-box .clear-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)
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment