From dab6aab220ebaf88d69ca5d54181dd8f14404e9f Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 24 Apr 2017 16:15:24 +0100 Subject: [PATCH] Assignee filter on group issues/merge requests only loads group users Closes #29490 --- app/assets/javascripts/users_select.js | 1 + app/views/shared/issuable/_filter.html.haml | 2 +- .../group-assignee-dropdown-send-group-id.yml | 4 ++++ spec/features/groups/issues_spec.rb | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/group-assignee-dropdown-send-group-id.yml diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js index 30902767705..0344ce9ffb4 100644 --- a/app/assets/javascripts/users_select.js +++ b/app/assets/javascripts/users_select.js @@ -33,6 +33,7 @@ var $block, $collapsedSidebar, $dropdown, $loading, $selectbox, $value, abilityName, assignTo, assigneeTemplate, collapsedAssigneeTemplate, defaultLabel, firstUser, issueURL, selectedId, showAnyUser, showNullUser, showMenuAbove; $dropdown = $(dropdown); options.projectId = $dropdown.data('project-id'); + options.groupId = $dropdown.data('group-id'); options.showCurrentUser = $dropdown.data('current-user'); options.todoFilter = $dropdown.data('todo-filter'); options.todoStateFilter = $dropdown.data('todo-state-filter'); diff --git a/app/views/shared/issuable/_filter.html.haml b/app/views/shared/issuable/_filter.html.haml index c72268473ca..1a12f110945 100644 --- a/app/views/shared/issuable/_filter.html.haml +++ b/app/views/shared/issuable/_filter.html.haml @@ -21,7 +21,7 @@ - if params[:assignee_id].present? = hidden_field_tag(:assignee_id, params[:assignee_id]) = dropdown_tag(user_dropdown_label(params[:assignee_id], "Assignee"), options: { toggle_class: "js-user-search js-filter-submit js-assignee-search", title: "Filter by assignee", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee js-filter-submit", - placeholder: "Search assignee", data: { any_user: "Any Assignee", first_user: current_user.try(:username), null_user: true, current_user: true, project_id: @project.try(:id), selected: params[:assignee_id], field_name: "assignee_id", default_label: "Assignee" } }) + placeholder: "Search assignee", data: { any_user: "Any Assignee", first_user: current_user.try(:username), null_user: true, current_user: true, project_id: @project.try(:id), group_id: @group&.id, selected: params[:assignee_id], field_name: "assignee_id", default_label: "Assignee" } }) .filter-item.inline.milestone-filter = render "shared/issuable/milestone_dropdown", selected: finder.milestones.try(:first), name: :milestone_title, show_any: true, show_upcoming: true, show_started: true diff --git a/changelogs/unreleased/group-assignee-dropdown-send-group-id.yml b/changelogs/unreleased/group-assignee-dropdown-send-group-id.yml new file mode 100644 index 00000000000..4f153f9817d --- /dev/null +++ b/changelogs/unreleased/group-assignee-dropdown-send-group-id.yml @@ -0,0 +1,4 @@ +--- +title: Fixed group issues assignee dropdown loading all users +merge_request: +author: diff --git a/spec/features/groups/issues_spec.rb b/spec/features/groups/issues_spec.rb index 1b3747c390b..45f57845c74 100644 --- a/spec/features/groups/issues_spec.rb +++ b/spec/features/groups/issues_spec.rb @@ -23,4 +23,20 @@ feature 'Group issues page', feature: true do it_behaves_like "an autodiscoverable RSS feed without a private token" end end + + context 'assignee', :js do + let(:access_level) { ProjectFeature::ENABLED } + let(:user) { user_in_group } + let(:user2) { user_outside_group } + let(:path) { issues_group_path(group) } + + it 'filters by only group users' do + click_button('Assignee') + + wait_for_ajax + + expect(find('.dropdown-menu-assignee')).to have_link(user.name) + expect(find('.dropdown-menu-assignee')).not_to have_link(user2.name) + end + end end