Commit 3a292fd4 authored by Felipe Artur's avatar Felipe Artur

Move service desk frontend files to core

Move frontend service desk related files to core.
More information on https://gitlab.com/gitlab-org/gitlab/-/issues/215364
parent 7ce7a8a3
...@@ -8,6 +8,8 @@ import initFilePickers from '~/file_pickers'; ...@@ -8,6 +8,8 @@ import initFilePickers from '~/file_pickers';
import initProjectLoadingSpinner from '../shared/save_project_loader'; import initProjectLoadingSpinner from '../shared/save_project_loader';
import initProjectPermissionsSettings from '../shared/permissions'; import initProjectPermissionsSettings from '../shared/permissions';
import initProjectRemoveModal from '~/projects/project_remove_modal'; import initProjectRemoveModal from '~/projects/project_remove_modal';
import UserCallout from '~/user_callout';
import initServiceDesk from '~/projects/settings_service_desk';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
initFilePickers(); initFilePickers();
...@@ -16,6 +18,9 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -16,6 +18,9 @@ document.addEventListener('DOMContentLoaded', () => {
initProjectRemoveModal(); initProjectRemoveModal();
mountBadgeSettings(PROJECT_BADGE); mountBadgeSettings(PROJECT_BADGE);
new UserCallout({ className: 'js-service-desk-callout' }); // eslint-disable-line no-new
initServiceDesk();
initProjectLoadingSpinner(); initProjectLoadingSpinner();
initProjectPermissionsSettings(); initProjectPermissionsSettings();
setupTransferEdit('.js-project-transfer-form', 'select.select2'); setupTransferEdit('.js-project-transfer-form', 'select.select2');
......
...@@ -132,7 +132,10 @@ module IssuesHelper ...@@ -132,7 +132,10 @@ module IssuesHelper
end end
def show_moved_service_desk_issue_warning?(issue) def show_moved_service_desk_issue_warning?(issue)
false return false unless issue.moved_from
return false unless issue.from_service_desk?
issue.moved_from.project.service_desk_enabled? && !issue.project.service_desk_enabled?
end end
end end
......
...@@ -750,10 +750,6 @@ module ProjectsHelper ...@@ -750,10 +750,6 @@ module ProjectsHelper
::Feature.enabled?(:resource_access_token, project) ::Feature.enabled?(:resource_access_token, project)
end end
def render_service_desk_menu?
false
end
end end
ProjectsHelper.prepend_if_ee('EE::ProjectsHelper') ProjectsHelper.prepend_if_ee('EE::ProjectsHelper')
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
%span %span
= _('Labels') = _('Labels')
= render_if_exists 'projects/sidebar/issues_service_desk' = render 'projects/sidebar/issues_service_desk'
= nav_link(controller: :milestones) do = nav_link(controller: :milestones) do
= link_to project_milestones_path(@project), title: _('Milestones'), class: 'qa-milestones-link' do = link_to project_milestones_path(@project), title: _('Milestones'), class: 'qa-milestones-link' do
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
= render_if_exists 'projects/settings/default_issue_template' = render_if_exists 'projects/settings/default_issue_template'
= render_if_exists 'projects/service_desk_settings' = render 'projects/service_desk_settings'
%section.qa-advanced-settings.settings.advanced-settings.no-animate#js-project-advanced-settings{ class: ('expanded' if expanded) } %section.qa-advanced-settings.settings.advanced-settings.no-animate#js-project-advanced-settings{ class: ('expanded' if expanded) }
.settings-header .settings-header
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +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 = render "projects/issues/alert_moved_from_service_desk", issue: @issue
.detail-page-header .detail-page-header
.detail-page-header-body .detail-page-header-body
......
-# TODO - Remove this check when service desk gets moved into core tier
-# More information on: https://gitlab.com/gitlab-org/gitlab/-/issues/215364
- return unless render_service_desk_menu?
= nav_link(controller: :issues, action: :service_desk ) do = nav_link(controller: :issues, action: :service_desk ) do
= link_to service_desk_project_issues_path(@project), title: 'Service Desk' do = link_to service_desk_project_issues_path(@project), title: 'Service Desk' do
= _('Service Desk') = _('Service Desk')
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
.svg-container .svg-container
= custom_icon('icon_service_desk') = custom_icon('icon_service_desk')
.user-callout-copy .user-callout-copy
-# haml-lint:disable NoPlainNodes
%h4 %h4
Improve customer support with GitLab Service Desk. Improve customer support with GitLab Service Desk.
%p %p
......
---
title: Move service desk feature to core
merge_request: 36613
author:
type: changed
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import '~/pages/projects/edit'; import '~/pages/projects/edit';
import mountApprovals from 'ee/approvals/mount_project_settings'; import mountApprovals from 'ee/approvals/mount_project_settings';
import initServiceDesk from 'ee/projects/settings_service_desk';
import UsersSelect from '~/users_select'; import UsersSelect from '~/users_select';
import UserCallout from '~/user_callout'; import UserCallout from '~/user_callout';
import groupsSelect from '~/groups_select'; import groupsSelect from '~/groups_select';
...@@ -11,8 +10,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -11,8 +10,7 @@ document.addEventListener('DOMContentLoaded', () => {
new UsersSelect(); new UsersSelect();
groupsSelect(); groupsSelect();
new UserCallout({ className: 'js-service-desk-callout' });
new UserCallout({ className: 'js-mr-approval-callout' }); new UserCallout({ className: 'js-mr-approval-callout' });
initServiceDesk();
mountApprovals(document.getElementById('js-mr-approvals-settings')); mountApprovals(document.getElementById('js-mr-approvals-settings'));
}); });
...@@ -50,13 +50,5 @@ module EE ...@@ -50,13 +50,5 @@ module EE
# than the filter epic id on params # than the filter epic id on params
epic_id.to_i != issue.epic_issue.epic_id epic_id.to_i != issue.epic_issue.epic_id
end end
override :show_moved_service_desk_issue_warning?
def show_moved_service_desk_issue_warning?(issue)
return false unless issue.moved_from
return false unless issue.from_service_desk?
issue.moved_from.project.service_desk_enabled? && !issue.project.service_desk_enabled?
end
end end
end end
...@@ -264,11 +264,6 @@ module EE ...@@ -264,11 +264,6 @@ module EE
project&.compliance_framework_setting&.present? project&.compliance_framework_setting&.present?
end end
override :render_service_desk_menu?
def render_service_desk_menu?
true
end
private private
def get_project_security_nav_tabs(project, current_user) def get_project_security_nav_tabs(project, current_user)
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'issue move to another project' do
let(:user) { create(:user) }
let(:old_project) { create(:project, :repository) }
let(:text) { 'Some issue description' }
let(:issue) do
create(:issue, description: text, project: old_project, author: user)
end
before do
sign_in(user)
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
...@@ -11,12 +11,6 @@ RSpec.describe 'Project navbar' do ...@@ -11,12 +11,6 @@ RSpec.describe 'Project navbar' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
before do before do
insert_after_sub_nav_item(
_('Labels'),
within: _('Issues'),
new_sub_nav_item_name: _('Service Desk')
)
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
end end
......
...@@ -17,51 +17,6 @@ RSpec.describe 'Promotions', :js do ...@@ -17,51 +17,6 @@ RSpec.describe 'Promotions', :js do
promotion_issue_weight_session_dismiss: false promotion_issue_weight_session_dismiss: false
end end
describe 'for service desk', :js do
before do
project.add_maintainer(user)
sign_in(user)
end
context 'when service desk is not supported' do
before do
allow(::Gitlab::ServiceDesk).to receive(:supported?).and_return(false)
end
it 'appears in project edit page' do
visit edit_project_path(project)
expect(find('#promote_service_desk')).to have_content 'Improve customer support with GitLab Service Desk.'
end
it 'does not show when cookie is set' do
visit edit_project_path(project)
within('#promote_service_desk') do
find('.close').click
end
wait_for_requests
visit edit_project_path(project)
expect(page).not_to have_selector('#promote_service_desk')
end
end
context 'when service desk is supported' do
before do
allow(::Gitlab::ServiceDesk).to receive(:supported?).and_return(true)
end
it 'does not show promotion' do
visit edit_project_path(project)
expect(page).not_to have_selector('#promote_service_desk')
end
end
end
describe 'for merge request improve', :js do describe 'for merge request improve', :js do
before do before do
allow(License).to receive(:current).and_return(nil) allow(License).to receive(:current).and_return(nil)
......
...@@ -69,28 +69,4 @@ RSpec.describe EE::IssuesHelper do ...@@ -69,28 +69,4 @@ RSpec.describe EE::IssuesHelper do
expect(helper.issue_in_subepic?(issue, 'subepic_id')).to be_truthy expect(helper.issue_in_subepic?(issue, 'subepic_id')).to be_truthy
end end
end end
describe '#show_moved_service_desk_issue_warning?' do
let(:project1) { create(:project, service_desk_enabled: true) }
let(:project2) { create(:project, service_desk_enabled: true) }
let!(:old_issue) { create(:issue, author: User.support_bot, project: project1) }
let!(:new_issue) { create(:issue, author: User.support_bot, project: project2) }
before do
allow(Gitlab::IncomingEmail).to receive(:enabled?) { true }
allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true }
old_issue.update(moved_to: new_issue)
end
it 'is true when moved issue project has service desk disabled' do
project2.update!(service_desk_enabled: false)
expect(helper.show_moved_service_desk_issue_warning?(new_issue)).to be(true)
end
it 'is false when moved issue project has service desk enabled' do
expect(helper.show_moved_service_desk_issue_warning?(new_issue)).to be(false)
end
end
end end
...@@ -717,26 +717,6 @@ RSpec.describe API::Projects do ...@@ -717,26 +717,6 @@ RSpec.describe API::Projects do
end end
end end
context 'when updating service desk' do
subject { put(api("/projects/#{project.id}", user), params: { service_desk_enabled: true }) }
before do
project.update!(service_desk_enabled: false)
allow(::Gitlab::IncomingEmail).to receive(:enabled?).and_return(true)
end
it 'returns 200' do
subject
expect(response).to have_gitlab_http_status(:ok)
end
it 'enables the service_desk' do
expect { subject }.to change { project.reload.service_desk_enabled }.to(true)
end
end
context 'when updating mirror related attributes' do context 'when updating mirror related attributes' do
let(:import_url) { generate(:url) } let(:import_url) { generate(:url) }
let(:mirror_params) do let(:mirror_params) do
......
...@@ -97,6 +97,45 @@ RSpec.describe 'issue move to another project' do ...@@ -97,6 +97,45 @@ RSpec.describe 'issue move to another project' do
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
def issue_path(issue) def issue_path(issue)
project_issue_path(issue.project, issue) project_issue_path(issue.project, issue)
end end
......
...@@ -9,8 +9,6 @@ RSpec.describe 'Service Desk Issue Tracker', :js do ...@@ -9,8 +9,6 @@ RSpec.describe 'Service Desk Issue Tracker', :js do
before do before do
stub_feature_flags(vue_issuables_list: false) stub_feature_flags(vue_issuables_list: false)
allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:service_desk).and_return(true)
allow(Gitlab::IncomingEmail).to receive(:enabled?).and_return(true) allow(Gitlab::IncomingEmail).to receive(:enabled?).and_return(true)
allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?).and_return(true) allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?).and_return(true)
......
...@@ -12,17 +12,6 @@ RSpec.describe 'Project navbar' do ...@@ -12,17 +12,6 @@ RSpec.describe 'Project navbar' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
before do before do
# TODO - This can be moved into 'project navbar structure' shared
# context when service desk feature gets moved to core.
# More information in: https://gitlab.com/gitlab-org/gitlab/-/issues/215364
if Gitlab.ee?
insert_after_sub_nav_item(
_('Labels'),
within: _('Issues'),
new_sub_nav_item_name: _('Service Desk')
)
end
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Promotions', :js do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project_empty_repo) }
describe 'for service desk', :js do
before do
project.add_maintainer(user)
sign_in(user)
end
context 'when service desk is not supported' do
before do
allow(::Gitlab::ServiceDesk).to receive(:supported?).and_return(false)
end
it 'appears in project edit page' do
visit edit_project_path(project)
expect(find('#promote_service_desk')).to have_content 'Improve customer support with GitLab Service Desk.'
end
it 'does not show when cookie is set' do
visit edit_project_path(project)
within('#promote_service_desk') do
find('.close').click
end
wait_for_requests
visit edit_project_path(project)
expect(page).not_to have_selector('#promote_service_desk')
end
end
context 'when service desk is supported' do
before do
allow(::Gitlab::ServiceDesk).to receive(:supported?).and_return(true)
end
it 'does not show promotion' do
visit edit_project_path(project)
expect(page).not_to have_selector('#promote_service_desk')
end
end
end
end
import { shallowMount, mount } from '@vue/test-utils'; import { shallowMount, mount } from '@vue/test-utils';
import AxiosMockAdapter from 'axios-mock-adapter'; import AxiosMockAdapter from 'axios-mock-adapter';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import ServiceDeskRoot from 'ee/projects/settings_service_desk/components/service_desk_root.vue'; import ServiceDeskRoot from '~/projects/settings_service_desk/components/service_desk_root.vue';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
......
import { shallowMount, mount } from '@vue/test-utils'; import { shallowMount, mount } from '@vue/test-utils';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import eventHub from 'ee/projects/settings_service_desk/event_hub'; import eventHub from '~/projects/settings_service_desk/event_hub';
import ServiceDeskSetting from 'ee/projects/settings_service_desk/components/service_desk_setting.vue'; import ServiceDeskSetting from '~/projects/settings_service_desk/components/service_desk_setting.vue';
describe('ServiceDeskSetting', () => { describe('ServiceDeskSetting', () => {
let wrapper; let wrapper;
......
import AxiosMockAdapter from 'axios-mock-adapter'; import AxiosMockAdapter from 'axios-mock-adapter';
import ServiceDeskService from 'ee/projects/settings_service_desk/services/service_desk_service'; import ServiceDeskService from '~/projects/settings_service_desk/services/service_desk_service';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
......
...@@ -209,4 +209,28 @@ RSpec.describe IssuesHelper do ...@@ -209,4 +209,28 @@ RSpec.describe IssuesHelper do
it_behaves_like 'does not display link' it_behaves_like 'does not display link'
end end
end end
describe '#show_moved_service_desk_issue_warning?' do
let(:project1) { create(:project, service_desk_enabled: true) }
let(:project2) { create(:project, service_desk_enabled: true) }
let!(:old_issue) { create(:issue, author: User.support_bot, project: project1) }
let!(:new_issue) { create(:issue, author: User.support_bot, project: project2) }
before do
allow(Gitlab::IncomingEmail).to receive(:enabled?) { true }
allow(Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true }
old_issue.update(moved_to: new_issue)
end
it 'is true when moved issue project has service desk disabled' do
project2.update!(service_desk_enabled: false)
expect(helper.show_moved_service_desk_issue_warning?(new_issue)).to be(true)
end
it 'is false when moved issue project has service desk enabled' do
expect(helper.show_moved_service_desk_issue_warning?(new_issue)).to be(false)
end
end
end end
...@@ -2679,6 +2679,26 @@ RSpec.describe API::Projects do ...@@ -2679,6 +2679,26 @@ RSpec.describe API::Projects do
end end
end end
end end
context 'when updating service desk' do
subject { put(api("/projects/#{project.id}", user), params: { service_desk_enabled: true }) }
before do
project.update!(service_desk_enabled: false)
allow(::Gitlab::IncomingEmail).to receive(:enabled?).and_return(true)
end
it 'returns 200' do
subject
expect(response).to have_gitlab_http_status(:ok)
end
it 'enables the service_desk' do
expect { subject }.to change { project.reload.service_desk_enabled }.to(true)
end
end
end end
describe 'POST /projects/:id/archive' do describe 'POST /projects/:id/archive' do
......
...@@ -42,6 +42,7 @@ RSpec.shared_context 'project navbar structure' do ...@@ -42,6 +42,7 @@ RSpec.shared_context 'project navbar structure' do
_('List'), _('List'),
_('Boards'), _('Boards'),
_('Labels'), _('Labels'),
_('Service Desk'),
_('Milestones') _('Milestones')
] ]
}, },
......
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