Commit 3f3160b4 authored by Scott Stern's avatar Scott Stern Committed by Andrew Fontaine

Add stopPropagation and specs to report abuse link

parent ce721bd7
...@@ -100,6 +100,13 @@ export default class Issue { ...@@ -100,6 +100,13 @@ export default class Issue {
initIssueBtnEventListeners() { initIssueBtnEventListeners() {
const issueFailMessage = __('Unable to update this issue at this time.'); const issueFailMessage = __('Unable to update this issue at this time.');
$('.report-abuse-link').on('click', e => {
// this is needed because of the implementation of
// the dropdown toggle and Report Abuse needing to be
// linked to another page.
e.stopPropagation();
});
// NOTE: data attribute seems unnecessary but is actually necessary // NOTE: data attribute seems unnecessary but is actually necessary
return $('.js-issuable-buttons[data-action="close-reopen"]').on( return $('.js-issuable-buttons[data-action="close-reopen"]').on(
'click', 'click',
......
...@@ -66,6 +66,14 @@ MergeRequest.prototype.showAllCommits = function() { ...@@ -66,6 +66,14 @@ MergeRequest.prototype.showAllCommits = function() {
MergeRequest.prototype.initMRBtnListeners = function() { MergeRequest.prototype.initMRBtnListeners = function() {
const _this = this; const _this = this;
$('.report-abuse-link').on('click', e => {
// this is needed because of the implementation of
// the dropdown toggle and Report Abuse needing to be
// linked to another page.
e.stopPropagation();
});
return $('.btn-close, .btn-reopen').on('click', function(e) { return $('.btn-close, .btn-reopen').on('click', function(e) {
const $this = $(this); const $this = $(this);
const shouldSubmit = $this.hasClass('btn-comment'); const shouldSubmit = $this.hasClass('btn-comment');
......
...@@ -39,10 +39,8 @@ ...@@ -39,10 +39,8 @@
%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)), %li.report-item{ data: { text: _('Report abuse'), button_class: "#{button_class} btn-close-color", toggle_class: "#{toggle_class} btn-close-color", method: '' } }
button_class: "#{button_class} btn-close-color", toggle_class: "#{toggle_class} btn-close-color", method: '' } } %a.report-abuse-link{ :href => new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)) }
%button.btn.btn-transparent
= icon('check', class: 'icon')
.description .description
%strong.title= _('Report abuse') %strong.title= _('Report abuse')
%p.text %p.text
......
---
title: Fix report abuse button in issues and mrs
merge_request: 40918
author:
type: fixed
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Issuables Close/Reopen/Report toggle' do RSpec.describe 'Issuables Close/Reopen/Report toggle' do
include IssuablesHelper
let(:user) { create(:user) } let(:user) { create(:user) }
shared_examples 'an issuable close/reopen/report toggle' do shared_examples 'an issuable close/reopen/report toggle' do
...@@ -27,19 +29,11 @@ RSpec.describe 'Issuables Close/Reopen/Report toggle' do ...@@ -27,19 +29,11 @@ RSpec.describe 'Issuables Close/Reopen/Report toggle' do
expect(container).not_to have_selector('.reopen-item') expect(container).not_to have_selector('.reopen-item')
end end
it 'changes the button when an item is selected' do it 'links to Report Abuse' do
button = container.find('.issuable-close-button')
container.find('.dropdown-toggle').click
container.find('.report-item').click
expect(container).not_to have_selector('.dropdown-menu')
expect(button).to have_content('Report abuse')
container.find('.dropdown-toggle').click container.find('.dropdown-toggle').click
container.find('.close-item').click container.find('.report-abuse-link').click
expect(button).to have_content("Close #{human_model_name}") expect(page).to have_content('Report abuse to admin')
end end
end end
......
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