Commit 4f143aa8 authored by Simon Knox's avatar Simon Knox

re-add Assign to Me link on new MR/Issue forms

parent 9f908cfc
...@@ -60,6 +60,15 @@ ...@@ -60,6 +60,15 @@
}); });
}; };
$('.assign-to-me-link').on('click', (e) => {
e.preventDefault();
$(e.currentTarget).hide();
const $input = $(`input[name="${$dropdown.data('field-name')}"]`);
$input.val(gon.current_user_id);
selectedId = $input.val();
$dropdown.find('.dropdown-toggle-text').text(gon.current_user_fullname).removeClass('is-default');
});
$block.on('click', '.js-assign-yourself', function(e) { $block.on('click', '.js-assign-yourself', function(e) {
e.preventDefault(); e.preventDefault();
...@@ -199,6 +208,11 @@ ...@@ -199,6 +208,11 @@
if ($dropdown.hasClass('js-filter-bulk-update') || $dropdown.hasClass('js-issuable-form-dropdown')) { if ($dropdown.hasClass('js-filter-bulk-update') || $dropdown.hasClass('js-issuable-form-dropdown')) {
e.preventDefault(); e.preventDefault();
selectedId = user.id; selectedId = user.id;
if (selectedId === gon.current_user_id) {
$('.assign-to-me-link').hide();
} else {
$('.assign-to-me-link').show();
}
return; return;
} }
if ($el.closest('.add-issues-modal').length) { if ($el.closest('.add-issues-modal').length) {
...@@ -234,11 +248,16 @@ ...@@ -234,11 +248,16 @@
id: function (user) { id: function (user) {
return user.id; return user.id;
}, },
opened: function(e) {
const $el = $(e.currentTarget);
$el.find('.is-active').removeClass('is-active');
$el.find(`li[data-user-id="${selectedId}"] .dropdown-menu-user-link`).addClass('is-active');
},
renderRow: function(user) { renderRow: function(user) {
var avatar, img, listClosingTags, listWithName, listWithUserName, selected, username; var avatar, img, listClosingTags, listWithName, listWithUserName, selected, username;
username = user.username ? "@" + user.username : ""; username = user.username ? "@" + user.username : "";
avatar = user.avatar_url ? user.avatar_url : false; avatar = user.avatar_url ? user.avatar_url : false;
selected = user.id === selectedId ? "is-active" : ""; selected = user.id === parseInt(selectedId, 10) ? "is-active" : "";
img = ""; img = "";
if (user.beforeDivider != null) { if (user.beforeDivider != null) {
"<li> <a href='#' class='" + selected + "'> " + user.name + " </a> </li>"; "<li> <a href='#' class='" + selected + "'> " + user.name + " </a> </li>";
...@@ -248,7 +267,7 @@ ...@@ -248,7 +267,7 @@
} }
} }
// split into three parts so we can remove the username section if nessesary // split into three parts so we can remove the username section if nessesary
listWithName = "<li> <a href='#' class='dropdown-menu-user-link " + selected + "'> " + img + " <strong class='dropdown-menu-user-full-name'> " + user.name + " </strong>"; listWithName = "<li data-user-id=" + user.id + "> <a href='#' class='dropdown-menu-user-link " + selected + "'> " + img + " <strong class='dropdown-menu-user-full-name'> " + user.name + " </strong>";
listWithUserName = "<span class='dropdown-menu-user-username'> " + username + " </span>"; listWithUserName = "<span class='dropdown-menu-user-username'> " + username + " </span>";
listClosingTags = "</a> </li>"; listClosingTags = "</a> </li>";
if (username === '') { if (username === '') {
......
...@@ -426,6 +426,11 @@ ...@@ -426,6 +426,11 @@
} }
} }
.assign-to-me-link {
padding-left: 12px;
white-space: nowrap;
}
.table-holder { .table-holder {
.ci-table { .ci-table {
......
= form_for [@project.namespace.becomes(Namespace), @project, @issue], html: { class: 'form-horizontal issue-form common-note-form js-quick-submit js-requires-input' } do |f| = form_for [@project.namespace.becomes(Namespace), @project, @issue], html: { class: 'form-horizontal issue-form common-note-form js-quick-submit js-requires-input' } do |f|
= render 'shared/issuable/form', f: f, issuable: @issue = render 'shared/issuable/form', f: f, issuable: @issue
:javascript
$('.assign-to-me-link').on('click', function(e){
$('#issue_assignee_id').val("#{current_user.id}").trigger("change");
e.preventDefault();
});
= form_for [@project.namespace.becomes(Namespace), @project, @merge_request], html: { class: 'merge-request-form form-horizontal common-note-form js-requires-input js-quick-submit' } do |f| = form_for [@project.namespace.becomes(Namespace), @project, @merge_request], html: { class: 'merge-request-form form-horizontal common-note-form js-requires-input js-quick-submit' } do |f|
= render 'shared/issuable/form', f: f, issuable: @merge_request = render 'shared/issuable/form', f: f, issuable: @merge_request
:javascript
$('.assign-to-me-link').on('click', function(e){
$('#merge_request_assignee_id').val("#{current_user.id}").trigger("change");
e.preventDefault();
});
...@@ -51,11 +51,6 @@ ...@@ -51,11 +51,6 @@
.mr-loading-status .mr-loading-status
= spinner = spinner
:javascript
$('.assign-to-me-link').on('click', function(e){
$('#merge_request_assignee_id').val("#{current_user.id}").trigger("change");
e.preventDefault();
});
:javascript :javascript
var merge_request = new MergeRequest({ var merge_request = new MergeRequest({
action: "#{(@show_changes_tab ? 'new/diffs' : 'new')}" action: "#{(@show_changes_tab ? 'new/diffs' : 'new')}"
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
= form.label :assignee_id, "Assignee", class: "control-label #{"col-lg-4" if has_due_date}" = form.label :assignee_id, "Assignee", class: "control-label #{"col-lg-4" if has_due_date}"
.col-sm-10{ class: ("col-lg-8" if has_due_date) } .col-sm-10{ class: ("col-lg-8" if has_due_date) }
.issuable-form-select-holder .issuable-form-select-holder
- if issuable.assignee_id
= form.hidden_field :assignee_id = form.hidden_field :assignee_id
= dropdown_tag(user_dropdown_label(issuable.assignee_id, "Assignee"), options: { toggle_class: "js-dropdown-keep-input js-user-search js-issuable-form-dropdown js-assignee-search", title: "Select assignee", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee js-filter-submit", = dropdown_tag(user_dropdown_label(issuable.assignee_id, "Assignee"), options: { toggle_class: "js-dropdown-keep-input js-user-search js-issuable-form-dropdown js-assignee-search", title: "Select assignee", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee js-filter-submit",
placeholder: "Search assignee", data: { first_user: current_user.try(:username), null_user: true, current_user: true, project_id: issuable.project.try(:id), selected: issuable.assignee_id, field_name: "#{issuable.class.model_name.param_key}[assignee_id]", default_label: "Assignee"} }) placeholder: "Search assignee", data: { first_user: current_user.try(:username), null_user: true, current_user: true, project_id: issuable.project.try(:id), selected: issuable.assignee_id, field_name: "#{issuable.class.model_name.param_key}[assignee_id]", default_label: "Assignee"} })
= link_to 'Assign to me', '#', class: "assign-to-me-link #{'hide' if issuable.assignee_id == current_user.id}"
.form-group.issue-milestone .form-group.issue-milestone
= form.label :milestone_id, "Milestone", class: "control-label #{"col-lg-4" if has_due_date}" = form.label :milestone_id, "Milestone", class: "control-label #{"col-lg-4" if has_due_date}"
.col-sm-10{ class: ("col-lg-8" if has_due_date) } .col-sm-10{ class: ("col-lg-8" if has_due_date) }
......
---
title: Re-add Assign to me link to Merge Request and Issues
merge_request:
author:
...@@ -14,6 +14,7 @@ module Gitlab ...@@ -14,6 +14,7 @@ module Gitlab
if current_user if current_user
gon.current_user_id = current_user.id gon.current_user_id = current_user.id
gon.current_username = current_user.username gon.current_username = current_user.username
gon.current_user_fullname = current_user.name
end end
end end
end end
......
...@@ -3,6 +3,7 @@ require 'rails_helper' ...@@ -3,6 +3,7 @@ require 'rails_helper'
describe 'New/edit issue', feature: true, js: true do describe 'New/edit issue', feature: true, js: true do
let!(:project) { create(:project) } let!(:project) { create(:project) }
let!(:user) { create(:user)} let!(:user) { create(:user)}
let!(:user2) { create(:user)}
let!(:milestone) { create(:milestone, project: project) } let!(:milestone) { create(:milestone, project: project) }
let!(:label) { create(:label, project: project) } let!(:label) { create(:label, project: project) }
let!(:label2) { create(:label, project: project) } let!(:label2) { create(:label, project: project) }
...@@ -10,6 +11,7 @@ describe 'New/edit issue', feature: true, js: true do ...@@ -10,6 +11,7 @@ describe 'New/edit issue', feature: true, js: true do
before do before do
project.team << [user, :master] project.team << [user, :master]
project.team << [user2, :master]
login_as(user) login_as(user)
end end
...@@ -22,14 +24,23 @@ describe 'New/edit issue', feature: true, js: true do ...@@ -22,14 +24,23 @@ describe 'New/edit issue', feature: true, js: true do
fill_in 'issue_title', with: 'title' fill_in 'issue_title', with: 'title'
fill_in 'issue_description', with: 'title' fill_in 'issue_description', with: 'title'
expect(find('a', text: 'Assign to me')).to be_visible
click_button 'Assignee' click_button 'Assignee'
page.within '.dropdown-menu-user' do page.within '.dropdown-menu-user' do
click_link user.name click_link user2.name
end end
expect(find('input[name="issue[assignee_id]"]', visible: false).value).to match(user2.id.to_s)
page.within '.js-assignee-search' do
expect(page).to have_content user2.name
end
expect(find('a', text: 'Assign to me')).to be_visible
click_link 'Assign to me'
expect(find('input[name="issue[assignee_id]"]', visible: false).value).to match(user.id.to_s) expect(find('input[name="issue[assignee_id]"]', visible: false).value).to match(user.id.to_s)
page.within '.js-assignee-search' do page.within '.js-assignee-search' do
expect(page).to have_content user.name expect(page).to have_content user.name
end end
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
click_button 'Milestone' click_button 'Milestone'
page.within '.issue-milestone' do page.within '.issue-milestone' do
...@@ -94,6 +105,7 @@ describe 'New/edit issue', feature: true, js: true do ...@@ -94,6 +105,7 @@ describe 'New/edit issue', feature: true, js: true do
it 'allows user to update issue' do it 'allows user to update issue' do
expect(find('input[name="issue[assignee_id]"]', visible: false).value).to match(user.id.to_s) expect(find('input[name="issue[assignee_id]"]', visible: false).value).to match(user.id.to_s)
expect(find('input[name="issue[milestone_id]"]', visible: false).value).to match(milestone.id.to_s) expect(find('input[name="issue[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
page.within '.js-user-search' do page.within '.js-user-search' do
expect(page).to have_content user.name expect(page).to have_content user.name
......
...@@ -4,12 +4,14 @@ describe 'New/edit merge request', feature: true, js: true do ...@@ -4,12 +4,14 @@ describe 'New/edit merge request', feature: true, js: true do
let!(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let!(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:project, forked_from_project: project) }
let!(:user) { create(:user)} let!(:user) { create(:user)}
let!(:user2) { create(:user)}
let!(:milestone) { create(:milestone, project: project) } let!(:milestone) { create(:milestone, project: project) }
let!(:label) { create(:label, project: project) } let!(:label) { create(:label, project: project) }
let!(:label2) { create(:label, project: project) } let!(:label2) { create(:label, project: project) }
before do before do
project.team << [user, :master] project.team << [user, :master]
project.team << [user2, :master]
end end
context 'owned projects' do context 'owned projects' do
...@@ -33,8 +35,14 @@ describe 'New/edit merge request', feature: true, js: true do ...@@ -33,8 +35,14 @@ describe 'New/edit merge request', feature: true, js: true do
it 'creates new merge request' do it 'creates new merge request' do
click_button 'Assignee' click_button 'Assignee'
page.within '.dropdown-menu-user' do page.within '.dropdown-menu-user' do
click_link user.name click_link user2.name
end
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user2.id.to_s)
page.within '.js-assignee-search' do
expect(page).to have_content user2.name
end end
click_link 'Assign to me'
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s) expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
page.within '.js-assignee-search' do page.within '.js-assignee-search' do
expect(page).to have_content user.name expect(page).to have_content user.name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment