diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2019-02-06 15:31:56 +0300 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2019-02-21 16:02:38 +0300 |
commit | bd9ae901ec0bc0f9d1060e9128ecd5f8d8127671 (patch) | |
tree | 2b0db5ffbc5c37d8e78ff30387c1b48394a687fd | |
parent | 3de4c8d0462aba1e254a255c438c80092109edf7 (diff) |
Ability to filter confidential issues
Add a new search bar filter for confidential issues. Add filtering
support to the IssuesFinder.
11 files changed, 58 insertions, 3 deletions
diff --git a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js index 57ec6603d80..4d05f46ed17 100644 --- a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js +++ b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js @@ -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, diff --git a/app/assets/javascripts/filtered_search/filtered_search_token_keys.js b/app/assets/javascripts/filtered_search/filtered_search_token_keys.js index b70da240833..48534bdf815 100644 --- a/app/assets/javascripts/filtered_search/filtered_search_token_keys.js +++ b/app/assets/javascripts/filtered_search/filtered_search_token_keys.js @@ -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', diff --git a/app/assets/javascripts/pages/groups/issues/index.js b/app/assets/javascripts/pages/groups/issues/index.js index 736c6a62610..21ec3f9f9ba 100644 --- a/app/assets/javascripts/pages/groups/issues/index.js +++ b/app/assets/javascripts/pages/groups/issues/index.js @@ -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, diff --git a/app/assets/javascripts/pages/projects/issues/index/index.js b/app/assets/javascripts/pages/projects/issues/index/index.js index a56c0bb6be8..bb91e38cb64 100644 --- a/app/assets/javascripts/pages/projects/issues/index/index.js +++ b/app/assets/javascripts/pages/projects/issues/index/index.js @@ -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, diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index 07d0bf16d93..fdf0ee030d4 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -91,6 +91,7 @@ module IssuableCollections options = { scope: params[:scope], state: params[:state], + confidential: params[:confidential], sort: set_sort_order } diff --git a/app/finders/issues_finder.rb b/app/finders/issues_finder.rb index a0504ca0879..d0a094ea4a6 100644 --- a/app/finders/issues_finder.rb +++ b/app/finders/issues_finder.rb @@ -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? diff --git a/app/views/shared/issuable/_search_bar.html.haml b/app/views/shared/issuable/_search_bar.html.haml index 588659c7e9c..bdba47ed14d 100644 --- a/app/views/shared/issuable/_search_bar.html.haml +++ b/app/views/shared/issuable/_search_bar.html.haml @@ -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 diff --git a/changelogs/unreleased/filter-confidential-issues.yml b/changelogs/unreleased/filter-confidential-issues.yml new file mode 100644 index 00000000000..83f19a57aab --- /dev/null +++ b/changelogs/unreleased/filter-confidential-issues.yml @@ -0,0 +1,5 @@ +--- +title: Ability to filter confidential issues +merge_request: 24960 +author: Robert Schilling +type: added diff --git a/spec/controllers/concerns/issuable_collections_spec.rb b/spec/controllers/concerns/issuable_collections_spec.rb index 307c5d60c57..5fdb9fe2ed6 100644 --- a/spec/controllers/concerns/issuable_collections_spec.rb +++ b/spec/controllers/concerns/issuable_collections_spec.rb @@ -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', @@ -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', diff --git a/spec/features/issues/filtered_search/dropdown_hint_spec.rb b/spec/features/issues/filtered_search/dropdown_hint_spec.rb index 0e296ab2109..965c8968954 100644 --- a/spec/features/issues/filtered_search/dropdown_hint_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_hint_spec.rb @@ -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 diff --git a/spec/features/issues/filtered_search/search_bar_spec.rb b/spec/features/issues/filtered_search/search_bar_spec.rb index 8abab3f35d6..c4468922883 100644 --- a/spec/features/issues/filtered_search/search_bar_spec.rb +++ b/spec/features/issues/filtered_search/search_bar_spec.rb @@ -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 |