Commit 7c8ef2a4 authored by Axel Garcia's avatar Axel Garcia Committed by Phil Hughes

Add alert when moving Service Desk issues

Displays a warning when an issue gets moved from a project with service
desk enabled to a project with service desk disabled, as this would make
the user who created the issue unable to receive email notifications
about new activity
parent f04f6dac
...@@ -6,6 +6,7 @@ import { addDelimiter } from './lib/utils/text_utility'; ...@@ -6,6 +6,7 @@ import { addDelimiter } from './lib/utils/text_utility';
import flash from './flash'; import flash from './flash';
import CreateMergeRequestDropdown from './create_merge_request_dropdown'; import CreateMergeRequestDropdown from './create_merge_request_dropdown';
import IssuablesHelper from './helpers/issuables_helper'; import IssuablesHelper from './helpers/issuables_helper';
import { joinPaths } from '~/lib/utils/url_utility';
import { __ } from './locale'; import { __ } from './locale';
export default class Issue { export default class Issue {
...@@ -14,6 +15,16 @@ export default class Issue { ...@@ -14,6 +15,16 @@ export default class Issue {
if ($('.js-close-blocked-issue-warning').length) this.initIssueWarningBtnEventListener(); if ($('.js-close-blocked-issue-warning').length) this.initIssueWarningBtnEventListener();
if ($('.js-alert-moved-from-service-desk-warning').length) {
const trimmedPathname = window.location.pathname.slice(1);
this.alertMovedFromServiceDeskDismissedKey = joinPaths(
trimmedPathname,
'alert-issue-moved-from-service-desk-dismissed',
);
this.initIssueMovedFromServiceDeskDismissHandler();
}
Issue.$btnNewBranch = $('#new-branch'); Issue.$btnNewBranch = $('#new-branch');
Issue.createMrDropdownWrap = document.querySelector('.create-mr-dropdown-wrap'); Issue.createMrDropdownWrap = document.querySelector('.create-mr-dropdown-wrap');
...@@ -167,6 +178,21 @@ export default class Issue { ...@@ -167,6 +178,21 @@ export default class Issue {
}); });
} }
initIssueMovedFromServiceDeskDismissHandler() {
const alertMovedFromServiceDeskWarning = $('.js-alert-moved-from-service-desk-warning');
if (!localStorage.getItem(this.alertMovedFromServiceDeskDismissedKey)) {
alertMovedFromServiceDeskWarning.show();
}
alertMovedFromServiceDeskWarning.on('click', '.js-close', e => {
e.preventDefault();
e.stopImmediatePropagation();
alertMovedFromServiceDeskWarning.remove();
localStorage.setItem(this.alertMovedFromServiceDeskDismissedKey, true);
});
}
static submitNoteForm(form) { static submitNoteForm(form) {
const noteText = form.find('textarea.js-note-text').val(); const noteText = form.find('textarea.js-note-text').val();
if (noteText && noteText.trim().length > 0) { if (noteText && noteText.trim().length > 0) {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
- can_create_issue = show_new_issue_link?(@project) - can_create_issue = show_new_issue_link?(@project)
= render_if_exists "projects/issues/alert_blocked", issue: @issue, current_user: current_user = render_if_exists "projects/issues/alert_blocked", issue: @issue, current_user: current_user
= render_if_exists "projects/issues/alert_moved_from_service_desk", issue: @issue
.detail-page-header .detail-page-header
.detail-page-header-body .detail-page-header-body
......
- return unless show_moved_service_desk_issue_warning?(issue)
- service_desk_link_url = help_page_path('user/project/service_desk')
- service_desk_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: service_desk_link_url }
.hide.gl-alert.gl-alert-warning.js-alert-moved-from-service-desk-warning.gl-mt-5{ role: 'alert' }
= sprite_icon('warning', size: 16, css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
%button.js-close.gl-alert-dismiss{ type: 'button', 'aria-label' => _('Dismiss') }
= sprite_icon('close', size: 16, css_class: 'gl-icon')
.gl-alert-body.gl-mr-3
= s_('This project does not have %{service_desk_link_start}Service Desk%{service_desk_link_end} enabled, so the user who created the issue will no longer receive email notifications about new activity.').html_safe % { service_desk_link_start: service_desk_link_start, service_desk_link_end: '</a>'.html_safe }
---
title: Display warning for issues moved from service desk on frontend
merge_request: 31803
author:
type: fixed
...@@ -22349,6 +22349,9 @@ msgstr "" ...@@ -22349,6 +22349,9 @@ msgstr ""
msgid "This project does not belong to a group and can therefore not make use of group Runners." msgid "This project does not belong to a group and can therefore not make use of group Runners."
msgstr "" msgstr ""
msgid "This project does not have %{service_desk_link_start}Service Desk%{service_desk_link_end} enabled, so the user who created the issue will no longer receive email notifications about new activity."
msgstr ""
msgid "This project does not have a wiki homepage yet" msgid "This project does not have a wiki homepage yet"
msgstr "" msgstr ""
......
...@@ -95,6 +95,45 @@ describe 'issue move to another project' do ...@@ -95,6 +95,45 @@ describe 'issue move to another project' do
expect(page).to have_no_selector('#move_to_project_id') expect(page).to have_no_selector('#move_to_project_id')
end end
end end
context 'service desk issue moved to a project with service desk disabled', :js do
let(:project_title) { 'service desk disabled project' }
let(:warning_selector) { '.js-alert-moved-from-service-desk-warning' }
let(:namespace) { create(:namespace) }
let(:regular_project) { create(:project, title: project_title, service_desk_enabled: false) }
let(:service_desk_project) { build(:project, :private, namespace: namespace, service_desk_enabled: true) }
let(:service_desk_issue) { create(:issue, project: service_desk_project, author: ::User.support_bot) }
before do
allow(::Gitlab).to receive(:com?).and_return(true)
allow(::Gitlab::IncomingEmail).to receive(:enabled?).and_return(true)
allow(::Gitlab::IncomingEmail).to receive(:supports_wildcard?).and_return(true)
regular_project.add_reporter(user)
service_desk_project.add_reporter(user)
visit issue_path(service_desk_issue)
find('.js-move-issue').click
wait_for_requests
find('.js-move-issue-dropdown-item', text: project_title).click
find('.js-move-issue-confirmation-button').click
end
it 'shows an alert after being moved' do
expect(page).to have_content('This project does not have Service Desk enabled')
end
it 'does not show an alert after being dismissed' do
find("#{warning_selector} .js-close").click
expect(page).to have_no_selector(warning_selector)
page.refresh
expect(page).to have_no_selector(warning_selector)
end
end
end end
def issue_path(issue) def issue_path(issue)
......
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