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';
import initProjectLoadingSpinner from '../shared/save_project_loader';
import initProjectPermissionsSettings from '../shared/permissions';
import initProjectRemoveModal from '~/projects/project_remove_modal';
import UserCallout from '~/user_callout';
import initServiceDesk from '~/projects/settings_service_desk';
document.addEventListener('DOMContentLoaded', () => {
initFilePickers();
......@@ -16,6 +18,9 @@ document.addEventListener('DOMContentLoaded', () => {
initProjectRemoveModal();
mountBadgeSettings(PROJECT_BADGE);
new UserCallout({ className: 'js-service-desk-callout' }); // eslint-disable-line no-new
initServiceDesk();
initProjectLoadingSpinner();
initProjectPermissionsSettings();
setupTransferEdit('.js-project-transfer-form', 'select.select2');
......
......@@ -132,7 +132,10 @@ module IssuesHelper
end
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
......
......@@ -750,10 +750,6 @@ module ProjectsHelper
::Feature.enabled?(:resource_access_token, project)
end
def render_service_desk_menu?
false
end
end
ProjectsHelper.prepend_if_ee('EE::ProjectsHelper')
......@@ -114,7 +114,7 @@
%span
= _('Labels')
= render_if_exists 'projects/sidebar/issues_service_desk'
= render 'projects/sidebar/issues_service_desk'
= nav_link(controller: :milestones) do
= link_to project_milestones_path(@project), title: _('Milestones'), class: 'qa-milestones-link' do
......
......@@ -56,7 +56,7 @@
= 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) }
.settings-header
......
......@@ -11,7 +11,7 @@
- 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_moved_from_service_desk", issue: @issue
= render "projects/issues/alert_moved_from_service_desk", issue: @issue
.detail-page-header
.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
= link_to service_desk_project_issues_path(@project), title: 'Service Desk' do
= _('Service Desk')
......@@ -5,6 +5,7 @@
.svg-container
= custom_icon('icon_service_desk')
.user-callout-copy
-# haml-lint:disable NoPlainNodes
%h4
Improve customer support with GitLab Service Desk.
%p
......
---
title: Move service desk feature to core
merge_request: 36613
author:
type: changed
......@@ -2,7 +2,6 @@
import '~/pages/projects/edit';
import mountApprovals from 'ee/approvals/mount_project_settings';
import initServiceDesk from 'ee/projects/settings_service_desk';
import UsersSelect from '~/users_select';
import UserCallout from '~/user_callout';
import groupsSelect from '~/groups_select';
......@@ -11,8 +10,7 @@ document.addEventListener('DOMContentLoaded', () => {
new UsersSelect();
groupsSelect();
new UserCallout({ className: 'js-service-desk-callout' });
new UserCallout({ className: 'js-mr-approval-callout' });
initServiceDesk();
mountApprovals(document.getElementById('js-mr-approvals-settings'));
});
......@@ -50,13 +50,5 @@ module EE
# than the filter epic id on params
epic_id.to_i != issue.epic_issue.epic_id
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
......@@ -264,11 +264,6 @@ module EE
project&.compliance_framework_setting&.present?
end
override :render_service_desk_menu?
def render_service_desk_menu?
true
end
private
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
let_it_be(:project) { create(:project, :repository) }
before do
insert_after_sub_nav_item(
_('Labels'),
within: _('Issues'),
new_sub_nav_item_name: _('Service Desk')
)
project.add_maintainer(user)
sign_in(user)
end
......
......@@ -17,51 +17,6 @@ RSpec.describe 'Promotions', :js do
promotion_issue_weight_session_dismiss: false
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
before do
allow(License).to receive(:current).and_return(nil)
......
......@@ -69,28 +69,4 @@ RSpec.describe EE::IssuesHelper do
expect(helper.issue_in_subepic?(issue, 'subepic_id')).to be_truthy
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
......@@ -717,26 +717,6 @@ RSpec.describe API::Projects do
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
let(:import_url) { generate(:url) }
let(:mirror_params) do
......
......@@ -97,6 +97,45 @@ RSpec.describe 'issue move to another project' do
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)
project_issue_path(issue.project, issue)
end
......
......@@ -9,8 +9,6 @@ RSpec.describe 'Service Desk Issue Tracker', :js do
before do
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(:supports_wildcard?).and_return(true)
......
......@@ -12,17 +12,6 @@ RSpec.describe 'Project navbar' do
let_it_be(:project) { create(:project, :repository) }
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)
sign_in(user)
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 AxiosMockAdapter from 'axios-mock-adapter';
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 httpStatusCodes from '~/lib/utils/http_status';
......
import { shallowMount, mount } from '@vue/test-utils';
import { GlLoadingIcon } from '@gitlab/ui';
import eventHub from 'ee/projects/settings_service_desk/event_hub';
import ServiceDeskSetting from 'ee/projects/settings_service_desk/components/service_desk_setting.vue';
import eventHub from '~/projects/settings_service_desk/event_hub';
import ServiceDeskSetting from '~/projects/settings_service_desk/components/service_desk_setting.vue';
describe('ServiceDeskSetting', () => {
let wrapper;
......
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 httpStatusCodes from '~/lib/utils/http_status';
......
......@@ -209,4 +209,28 @@ RSpec.describe IssuesHelper do
it_behaves_like 'does not display link'
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
......@@ -2679,6 +2679,26 @@ RSpec.describe API::Projects do
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
describe 'POST /projects/:id/archive' do
......
......@@ -42,6 +42,7 @@ RSpec.shared_context 'project navbar structure' do
_('List'),
_('Boards'),
_('Labels'),
_('Service Desk'),
_('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