diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-10 11:44:10 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-10 11:44:10 +0000 |
commit | 149195eded675717e6c5c1e3a8b1dae2d4082ae0 (patch) | |
tree | 6e0e54c20d4f549ac60c27d10817807521917e6f | |
parent | 1ff40a79462dcb0d8e717b51ad3048b1da817651 (diff) | |
parent | 3d2c3878408bd27af64293a22eff6857ad9b38dd (diff) | |
download | gitlab-ce-149195eded675717e6c5c1e3a8b1dae2d4082ae0.tar.gz |
Merge branch 'current-user-to-top-filter' into 'master'
Move current user to the top of the list in author/assignee filter
### What does this MR do?
This MR puts the current user at the top of the user list in the author/assignee filters.
### Are there points in the code the reviewer needs to double check?
Is it best to do this in the JavaScript as it is in this MR, or are we better off adding an argument to the `/users` API to put the current user on top?
Also, I elected to put the current user after "Any" and "Unassigned"--it looked better. Do you agree?
### Why was this MR needed?
If you're trying to look for "Me" in the list, often you have to scroll down a long way to find yourself. Using the filter to find yourself is yet another step requiring the keyboard, and it's easy to forget that feature is available.
### What are the relevant issue numbers / [Feature requests](http://feedback.gitlab.com/)?
#1321 and #1396
### Screenshots
Before:

After:

See merge request !505
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/assets/javascripts/users_select.js.coffee | 8 | ||||
-rw-r--r-- | app/helpers/selects_helper.rb | 2 | ||||
-rw-r--r-- | app/views/projects/issues/_issue_context.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/_issuable_filter.html.haml | 4 | ||||
-rw-r--r-- | features/project/issues/issues.feature | 6 | ||||
-rw-r--r-- | features/steps/project/issues/issues.rb | 12 | ||||
-rw-r--r-- | features/steps/shared/project.rb | 7 |
8 files changed, 39 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG index 5b3e9fd4a41..7901b8be732 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ v 7.10.0 (unreleased) - Fix bug where Wiki pages that included a '/' were no longer accessible (Stan Hu) - Fix bug where error messages from Dropzone would not be displayed on the issues page (Stan Hu) - Add ability to configure Reply-To address in gitlab.yml (Stan Hu) + - Move current user to the top of the list in assignee/author filters (Stan Hu) - Fix broken side-by-side diff view on merge request page (Stan Hu) - Set Application controller default URL options to ensure all url_for calls are consistent (Stan Hu) - Allow HTML tags in Markdown input diff --git a/app/assets/javascripts/users_select.js.coffee b/app/assets/javascripts/users_select.js.coffee index f464067686e..ccd85f2455d 100644 --- a/app/assets/javascripts/users_select.js.coffee +++ b/app/assets/javascripts/users_select.js.coffee @@ -8,6 +8,7 @@ class @UsersSelect @groupId = $(select).data('group-id') showNullUser = $(select).data('null-user') showAnyUser = $(select).data('any-user') + firstUser = $(select).data('first-user') $(select).select2 placeholder: "Search for a user" @@ -32,6 +33,13 @@ class @UsersSelect id: 0 } + if firstUser + # Move current user to the front of the list + for obj, index in data.results + if obj.username == firstUser + data.results.splice(index, 1) + data.results.unshift(obj) + break if showNullUser data.results.unshift(nullUser) if showAnyUser diff --git a/app/helpers/selects_helper.rb b/app/helpers/selects_helper.rb index 457cd3fa46b..54e0f4f9b3e 100644 --- a/app/helpers/selects_helper.rb +++ b/app/helpers/selects_helper.rb @@ -8,12 +8,14 @@ module SelectsHelper null_user = opts[:null_user] || false any_user = opts[:any_user] || false + first_user = opts[:first_user] && current_user ? current_user.username : false html = { class: css_class, 'data-placeholder' => placeholder, 'data-null-user' => null_user, 'data-any-user' => any_user, + 'data-first-user' => first_user } unless opts[:scope] == :all diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml index 52e38050419..9228074d833 100644 --- a/app/views/projects/issues/_issue_context.html.haml +++ b/app/views/projects/issues/_issue_context.html.haml @@ -8,7 +8,7 @@ - else none - if can?(current_user, :modify_issue, @issue) - = users_select_tag('issue[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: @issue.assignee_id, null_user: true) + = users_select_tag('issue[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: @issue.assignee_id, null_user: true, first_user: true) %div.prepend-top-20.clearfix .issuable-context-title diff --git a/app/views/shared/_issuable_filter.html.haml b/app/views/shared/_issuable_filter.html.haml index f169733f2e9..83f5a3a8015 100644 --- a/app/views/shared/_issuable_filter.html.haml +++ b/app/views/shared/_issuable_filter.html.haml @@ -24,11 +24,11 @@ .issues-other-filters .filter-item.inline = users_select_tag(:assignee_id, selected: params[:assignee_id], - placeholder: 'Assignee', class: 'trigger-submit', any_user: true, null_user: true) + placeholder: 'Assignee', class: 'trigger-submit', any_user: true, null_user: true, first_user: true) .filter-item.inline = users_select_tag(:author_id, selected: params[:author_id], - placeholder: 'Author', class: 'trigger-submit', any_user: true) + placeholder: 'Author', class: 'trigger-submit', any_user: true, first_user: true) .filter-item.inline.milestone-filter = select_tag('milestone_id', projects_milestones_options, class: "select2 trigger-submit", prompt: 'Milestone') diff --git a/features/project/issues/issues.feature b/features/project/issues/issues.feature index af01c7058ea..eb813884d1e 100644 --- a/features/project/issues/issues.feature +++ b/features/project/issues/issues.feature @@ -25,6 +25,12 @@ Feature: Project Issues Given I click link "Release 0.4" Then I should see issue "Release 0.4" + @javascript + Scenario: I visit issue page + Given I add a user to project "Shop" + And I click "author" dropdown + Then I see current user as the first user + Scenario: I submit new unassigned issue Given I click link "New Issue" And I submit new issue "500 error on profile" diff --git a/features/steps/project/issues/issues.rb b/features/steps/project/issues/issues.rb index e2834d51a27..b8e282b2029 100644 --- a/features/steps/project/issues/issues.rb +++ b/features/steps/project/issues/issues.rb @@ -59,6 +59,18 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps click_link "New Issue" end + step 'I click "author" dropdown' do + first('.ajax-users-select').click + end + + step 'I see current user as the first user' do + expect(page).to have_selector('.user-result', visible: true, count: 4) + users = page.all('.user-name') + users[0].text.should == 'Any' + users[1].text.should == 'Unassigned' + users[2].text.should == current_user.name + end + step 'I submit new issue "500 error on profile"' do fill_in "issue_title", with: "500 error on profile" click_button "Submit new issue" diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index 41f71ae29cb..b60ac5e3423 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -14,6 +14,13 @@ module SharedProject @project.team << [@user, :master] end + # Add another user to project "Shop" + step 'I add a user to project "Shop"' do + @project = Project.find_by(name: "Shop") + other_user = create(:user, name: 'Alpha') + @project.team << [other_user, :master] + end + # Create another specific project called "Forum" step 'I own project "Forum"' do @project = Project.find_by(name: "Forum") |