summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/issue.js31
-rw-r--r--app/assets/javascripts/merge_request.js24
-rw-r--r--app/assets/stylesheets/framework/filters.scss1
-rw-r--r--app/helpers/issuables_helper.rb7
-rw-r--r--app/views/projects/issues/show.html.haml3
-rw-r--r--app/views/projects/merge_requests/_mr_title.html.haml3
-rw-r--r--app/views/shared/issuable/_close_reopen_button.html.haml9
-rw-r--r--app/views/shared/issuable/_close_reopen_report_toggle.html.haml22
8 files changed, 76 insertions, 24 deletions
diff --git a/app/assets/javascripts/issue.js b/app/assets/javascripts/issue.js
index 62ffde6c93c..70007d4d4af 100644
--- a/app/assets/javascripts/issue.js
+++ b/app/assets/javascripts/issue.js
@@ -31,6 +31,11 @@ class Issue {
this.initCloseReopenReport();
+ if (!this.closeReopenReportToggle) {
+ this.closeButtons = $('a.btn-close');
+ this.reopenButtons = $('a.btn-reopen');
+ }
+
if (Issue.createMrDropdownWrap) {
this.createMergeRequestDropdown = new CreateMergeRequestDropdown(Issue.createMrDropdownWrap);
}
@@ -52,7 +57,7 @@ class Issue {
Issue.submitNoteForm($button.closest('form'));
}
- this.closeReopenReportToggle.setDisable(true);
+ this.disableCloseReopenButton($button, true);
url = $button.attr('href');
return $.ajax({
@@ -68,7 +73,7 @@ class Issue {
isClosedBadge.toggleClass('hidden', !isClosed);
isOpenBadge.toggleClass('hidden', isClosed);
- this.closeReopenReportToggle.updateButton(isClosed);
+ this.toggleCloseReopenButton(isClosed);
let numProjectIssues = Number(projectIssuesCounter.text().replace(/[^\d]/, ''));
numProjectIssues = isClosed ? numProjectIssues - 1 : numProjectIssues + 1;
@@ -87,13 +92,16 @@ class Issue {
new Flash(issueFailMessage);
}
- this.closeReopenReportToggle.setDisable(false);
+ this.disableCloseReopenButton($button, false);
});
});
}
initCloseReopenReport() {
const container = document.querySelector('.js-issuable-close-dropdown');
+
+ if (!container) return;
+
const dropdownTrigger = container.querySelector('.js-issuable-close-toggle');
const dropdownList = container.querySelector('.js-issuable-close-menu');
const button = container.querySelector('.js-issuable-close-button');
@@ -107,6 +115,23 @@ class Issue {
this.closeReopenReportToggle.initDroplab();
}
+ disableCloseReopenButton($button, shouldDisable) {
+ if (this.closeReopenReportToggle) {
+ this.closeReopenReportToggle.setDisable(shouldDisable);
+ } else {
+ $button.prop('disabled', shouldDisable);
+ }
+ }
+
+ toggleCloseReopenButton(isClosed) {
+ if (this.closeReopenReportToggle) {
+ this.closeReopenReportToggle.updateButton(isClosed);
+ } else {
+ this.closeButtons.toggleClass('hidden', isClosed);
+ this.reopenButtons.toggleClass('hidden', !isClosed);
+ }
+ }
+
static submitNoteForm(form) {
var noteText;
noteText = form.find("textarea.js-note-text").val();
diff --git a/app/assets/javascripts/merge_request.js b/app/assets/javascripts/merge_request.js
index 412d68dc37a..cae2f290f87 100644
--- a/app/assets/javascripts/merge_request.js
+++ b/app/assets/javascripts/merge_request.js
@@ -22,10 +22,12 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
return _this.showAllCommits();
};
})(this));
+
this.initTabs();
this.initMRBtnListeners();
this.initCommitMessageListeners();
- MergeRequest.initCloseReopenReport();
+ this.initCloseReopenReport();
+
if ($("a.btn-close").length) {
this.taskList = new gl.TaskList({
dataType: 'merge_request',
@@ -66,11 +68,15 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
if (shouldSubmit && $this.data('submitted')) {
return;
}
+
+ _this.disableCloseReopenButton($this, true);
+
if (shouldSubmit) {
if ($this.hasClass('btn-comment-and-close') || $this.hasClass('btn-comment-and-reopen')) {
e.preventDefault();
e.stopImmediatePropagation();
- return _this.submitNoteForm($this.closest('form'), $this);
+
+ _this.submitNoteForm($this.closest('form'), $this);
}
}
});
@@ -121,7 +127,7 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
$el.text(gl.text.addDelimiter(count));
};
- MergeRequest.initCloseReopenReport = function () {
+ MergeRequest.prototype.initCloseReopenReport = function () {
const container = document.querySelector('.js-issuable-close-dropdown');
if (!container) return;
@@ -130,13 +136,21 @@ import CloseReopenReportToggle from './close_reopen_report_toggle';
const dropdownList = container.querySelector('.js-issuable-close-menu');
const button = container.querySelector('.js-issuable-close-button');
- const closeReopenReportToggle = new CloseReopenReportToggle({
+ this.closeReopenReportToggle = new CloseReopenReportToggle({
dropdownTrigger,
dropdownList,
button,
});
- closeReopenReportToggle.initDroplab();
+ this.closeReopenReportToggle.initDroplab();
+ };
+
+ MergeRequest.prototype.disableCloseReopenButton = function ($button, shouldDisable) {
+ if (this.closeReopenReportToggle) {
+ this.closeReopenReportToggle.setDisable(shouldDisable);
+ } else {
+ $button.prop('disabled', shouldDisable);
+ }
};
return MergeRequest;
diff --git a/app/assets/stylesheets/framework/filters.scss b/app/assets/stylesheets/framework/filters.scss
index bc0c78ef5ed..bc2c536ba0e 100644
--- a/app/assets/stylesheets/framework/filters.scss
+++ b/app/assets/stylesheets/framework/filters.scss
@@ -83,6 +83,7 @@
flex: 1;
-webkit-flex: 1;
max-width: inherit;
+ padding: 0;
}
}
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index 44e846c26d4..6f887accf58 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -261,8 +261,11 @@ module IssuablesHelper
issuable_url(issuable, params)
end
- def close_reopen_issuable_url(issuable)
- issuable.closed? ? reopen_issuable_url(issuable) : close_issuable_url(issuable)
+ def close_reopen_issuable_url(issuable, should_inverse = false)
+ is_closed = issuable.closed?
+ is_closed = !is_closed if should_inverse
+
+ is_closed ? reopen_issuable_url(issuable) : close_issuable_url(issuable)
end
def issuable_url(issuable, *options)
diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml
index ec97acea88c..a57844f974e 100644
--- a/app/views/projects/issues/show.html.haml
+++ b/app/views/projects/issues/show.html.haml
@@ -31,7 +31,8 @@
%ul
- if can_update_issue
%li= link_to 'Edit', edit_project_issue_path(@project, @issue)
- %li= link_to 'Report abuse', new_abuse_report_path(user_id: @issue.author.id, ref_url: issue_url(@issue))
+ - unless current_user == @issue.author
+ %li= link_to 'Report abuse', new_abuse_report_path(user_id: @issue.author.id, ref_url: issue_url(@issue))
- if can_update_issue
%li= link_to 'Close issue', issue_path(@issue, issue: { state_event: :close }, format: 'json'), class: "btn-close #{issue_button_visibility(@issue, true)}", title: 'Close issue'
%li= link_to 'Reopen issue', issue_path(@issue, issue: { state_event: :reopen }, format: 'json'), class: "btn-reopen #{issue_button_visibility(@issue, false)}", title: 'Reopen issue'
diff --git a/app/views/projects/merge_requests/_mr_title.html.haml b/app/views/projects/merge_requests/_mr_title.html.haml
index eeb5eafd17a..a2e819fb3a7 100644
--- a/app/views/projects/merge_requests/_mr_title.html.haml
+++ b/app/views/projects/merge_requests/_mr_title.html.haml
@@ -26,7 +26,8 @@
%ul
- if can_update_merge_request
%li= link_to 'Edit', edit_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), class: 'issuable-edit'
- %li= link_to 'Report abuse', new_abuse_report_path(user_id: @merge_request.author.id, ref_url: merge_request_url(@merge_request))
+ - unless current_user == @merge_request.author
+ %li= link_to 'Report abuse', new_abuse_report_path(user_id: @merge_request.author.id, ref_url: merge_request_url(@merge_request))
- if can_update_merge_request
%li{ class: merge_request_button_visibility(@merge_request, true) }
= link_to 'Close', merge_request_path(@merge_request, merge_request: { state_event: :close }), method: :put, title: 'Close merge request'
diff --git a/app/views/shared/issuable/_close_reopen_button.html.haml b/app/views/shared/issuable/_close_reopen_button.html.haml
index 977a8404f5b..4d8721ab54a 100644
--- a/app/views/shared/issuable/_close_reopen_button.html.haml
+++ b/app/views/shared/issuable/_close_reopen_button.html.haml
@@ -1,4 +1,11 @@
-- if can_update
+- is_current_user = current_user == issuable.author
+- display_issuable_type = issuable.model_name.human.downcase
+- button_method = issuable.is_a?(MergeRequest) ? 'put' : ''
+
+- if can_update && is_current_user
+ = link_to "Close #{display_issuable_type}", close_issuable_url(issuable), { method: button_method, class: "hidden-xs hidden-sm btn btn-close btn-grouped #{'hidden' if issuable.closed?}", title: "Close #{display_issuable_type}" }
+ = link_to "Reopen #{display_issuable_type}", reopen_issuable_url(issuable), { method: button_method, class: "hidden-xs hidden-sm btn btn-reopen btn-grouped #{'hidden' unless issuable.closed?}", title: "Reopen #{display_issuable_type}" }
+- elsif can_update && !is_current_user
= render 'shared/issuable/close_reopen_report_toggle', issuable: issuable
- else
= link_to 'Report abuse', new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)), class: 'hidden-xs hidden-sm btn btn-grouped btn-close-color', title: 'Report abuse'
diff --git a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml
index e43e805600d..8a68fd83d92 100644
--- a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml
+++ b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml
@@ -7,7 +7,7 @@
- button_method = issuable.is_a?(MergeRequest) ? 'put' : ''
.pull-left.btn-group.prepend-left-10.issuable-close-dropdown.droplab-dropdown.js-issuable-close-dropdown
- = link_to "#{display_button_action} #{display_issuable_type}", close_reopen_issuable_url(issuable), { method: button_method.to_s, class: "#{button_class} btn-#{button_action}", title: "#{display_button_action} #{display_issuable_type}" }
+ = link_to "#{display_button_action} #{display_issuable_type}", close_reopen_issuable_url(issuable), { method: button_method, class: "#{button_class} btn-#{button_action}", title: "#{display_button_action} #{display_issuable_type}" }
= button_tag type: 'button', class: "#{toggle_class} btn-#{button_action}-color", data: { 'dropdown-trigger' => '#issuable-close-menu' }, 'aria-label' => 'Toggle dropdown' do
= icon('caret-down', class: 'toggle-icon icon')
@@ -31,14 +31,14 @@
= display_issuable_type
%p
- %li.divider.droplab-item-ignore
+ %li.divider.droplab-item-ignore
- %li.report-item{ data: { text: 'Report abuse', url: new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)), button_class: "#{button_class} btn-close-color", toggle_class: "#{toggle_class} btn-close-color", method: '' } }
- %button.btn.btn-transparent
- = icon('check', class: 'icon')
- .description
- %strong Report abuse
- %p
- Report
- = display_issuable_type.pluralize
- that are abusive, inappropriate or spam.
+ %li.report-item{ data: { text: 'Report abuse', url: new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)), button_class: "#{button_class} btn-close-color", toggle_class: "#{toggle_class} btn-close-color", method: '' } }
+ %button.btn.btn-transparent
+ = icon('check', class: 'icon')
+ .description
+ %strong Report abuse
+ %p
+ Report
+ = display_issuable_type.pluralize
+ that are abusive, inappropriate or spam.