Commit 43bd9335 authored by Phil Hughes's avatar Phil Hughes

Merge branch '2201-fe-service-desk-incoming-mail-address' into 'master'

Add project name suffix support in Service Desk

See merge request gitlab-org/gitlab!25240
parents be07223d e7db65ac
...@@ -35,6 +35,11 @@ export default { ...@@ -35,6 +35,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
projectKey: {
type: String,
required: false,
default: '',
},
templates: { templates: {
type: Array, type: Array,
required: false, required: false,
...@@ -109,10 +114,10 @@ export default { ...@@ -109,10 +114,10 @@ export default {
}); });
}, },
onSaveTemplate({ selectedTemplate, outgoingName }) { onSaveTemplate({ selectedTemplate, outgoingName, projectKey }) {
this.isTemplateSaving = true; this.isTemplateSaving = true;
this.service this.service
.updateTemplate({ selectedTemplate, outgoingName }, this.isEnabled) .updateTemplate({ selectedTemplate, outgoingName, projectKey }, this.isEnabled)
.then(() => this.showAlert(__('Template was successfully saved.'), 'success')) .then(() => this.showAlert(__('Template was successfully saved.'), 'success'))
.catch(() => .catch(() =>
this.showAlert( this.showAlert(
...@@ -139,14 +144,15 @@ export default { ...@@ -139,14 +144,15 @@ export default {
<template> <template>
<div> <div>
<gl-alert v-if="isAlertShowing" class="mb-3" :variant="alertVariant" @dismiss="onDismiss">{{ <gl-alert v-if="isAlertShowing" class="mb-3" :variant="alertVariant" @dismiss="onDismiss">
alertMessage {{ alertMessage }}
}}</gl-alert> </gl-alert>
<service-desk-setting <service-desk-setting
:is-enabled="isEnabled" :is-enabled="isEnabled"
:incoming-email="incomingEmail" :incoming-email="incomingEmail"
:initial-selected-template="selectedTemplate" :initial-selected-template="selectedTemplate"
:initial-outgoing-name="outgoingName" :initial-outgoing-name="outgoingName"
:initial-project-key="projectKey"
:templates="templates" :templates="templates"
:is-template-saving="isTemplateSaving" :is-template-saving="isTemplateSaving"
/> />
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlDeprecatedButton, GlFormSelect, GlToggle, GlLoadingIcon } from '@gitlab/ui'; import { GlDeprecatedButton, GlFormSelect, GlToggle, GlLoadingIcon } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -17,6 +18,7 @@ export default { ...@@ -17,6 +18,7 @@ export default {
GlToggle, GlToggle,
GlLoadingIcon, GlLoadingIcon,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
isEnabled: { isEnabled: {
type: Boolean, type: Boolean,
...@@ -37,6 +39,11 @@ export default { ...@@ -37,6 +39,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
initialProjectKey: {
type: String,
required: false,
default: '',
},
templates: { templates: {
type: Array, type: Array,
required: false, required: false,
...@@ -52,12 +59,16 @@ export default { ...@@ -52,12 +59,16 @@ export default {
return { return {
selectedTemplate: this.initialSelectedTemplate, selectedTemplate: this.initialSelectedTemplate,
outgoingName: this.initialOutgoingName || __('GitLab Support Bot'), outgoingName: this.initialOutgoingName || __('GitLab Support Bot'),
projectKey: this.initialProjectKey,
}; };
}, },
computed: { computed: {
templateOptions() { templateOptions() {
return [''].concat(this.templates); return [''].concat(this.templates);
}, },
hasProjectKeySupport() {
return Boolean(this.glFeatures.serviceDeskCustomAddress);
},
}, },
methods: { methods: {
onCheckboxToggle(isChecked) { onCheckboxToggle(isChecked) {
...@@ -67,6 +78,7 @@ export default { ...@@ -67,6 +78,7 @@ export default {
eventHub.$emit('serviceDeskTemplateSave', { eventHub.$emit('serviceDeskTemplateSave', {
selectedTemplate: this.selectedTemplate, selectedTemplate: this.selectedTemplate,
outgoingName: this.outgoingName, outgoingName: this.outgoingName,
projectKey: this.projectKey,
}); });
}, },
}, },
...@@ -83,14 +95,14 @@ export default { ...@@ -83,14 +95,14 @@ export default {
:label-off="__('Service Desk is off')" :label-off="__('Service Desk is off')"
@change="onCheckboxToggle" @change="onCheckboxToggle"
/> />
<label class="align-middle" for="service-desk-checkbox">{{ <label class="align-middle" for="service-desk-checkbox">
__('Activate Service Desk') {{ __('Activate Service Desk') }}
}}</label> </label>
<div v-if="isEnabled" class="row mt-3"> <div v-if="isEnabled" class="row mt-3">
<div class="col-md-9 mb-0"> <div class="col-md-9 mb-0">
<strong id="incoming-email-describer" class="d-block mb-1">{{ <strong id="incoming-email-describer" class="d-block mb-1">
__('Forward external support email address to') {{ __('Forward external support email address to') }}
}}</strong> </strong>
<template v-if="incomingEmail"> <template v-if="incomingEmail">
<div class="input-group"> <div class="input-group">
<input <input
...@@ -117,21 +129,34 @@ export default { ...@@ -117,21 +129,34 @@ export default {
<span class="sr-only">{{ __('Fetching incoming email') }}</span> <span class="sr-only">{{ __('Fetching incoming email') }}</span>
</template> </template>
<label for="service-desk-template-select" class="mt-3">{{ <label for="service-desk-template-select" class="mt-3">
__('Template to append to all Service Desk issues') {{ __('Template to append to all Service Desk issues') }}
}}</label> </label>
<gl-form-select <gl-form-select
id="service-desk-template-select" id="service-desk-template-select"
v-model="selectedTemplate" v-model="selectedTemplate"
:options="templateOptions" :options="templateOptions"
/> />
<label for="service-desk-email-from-name" class="mt-3">{{ <label for="service-desk-email-from-name" class="mt-3">
__('Email display name') {{ __('Email display name') }}
}}</label> </label>
<input id="service-desk-email-from-name" v-model.trim="outgoingName" class="form-control" /> <input id="service-desk-email-from-name" v-model.trim="outgoingName" class="form-control" />
<span class="form-text text-muted mb-3">{{ <span class="form-text text-muted">
__('Emails sent from Service Desk will have this name') {{ __('Emails sent from Service Desk will have this name') }}
}}</span> </span>
<template v-if="hasProjectKeySupport">
<label for="service-desk-project-suffix" class="mt-3">
{{ __('Project name suffix') }}
</label>
<input id="service-desk-project-suffix" v-model.trim="projectKey" class="form-control" />
<span class="form-text text-muted mb-3">
{{
__(
'Project name suffix is a user-defined string which will be appended to the project path, and will form the Service Desk email address.',
)
}}
</span>
</template>
<gl-deprecated-button <gl-deprecated-button
variant="success" variant="success"
:disabled="isTemplateSaving" :disabled="isTemplateSaving"
......
...@@ -19,6 +19,7 @@ export default () => { ...@@ -19,6 +19,7 @@ export default () => {
incomingEmail: dataset.incomingEmail, incomingEmail: dataset.incomingEmail,
selectedTemplate: dataset.selectedTemplate, selectedTemplate: dataset.selectedTemplate,
outgoingName: dataset.outgoingName, outgoingName: dataset.outgoingName,
projectKey: dataset.projectKey,
templates: JSON.parse(dataset.templates), templates: JSON.parse(dataset.templates),
}; };
}, },
...@@ -30,6 +31,7 @@ export default () => { ...@@ -30,6 +31,7 @@ export default () => {
initialIncomingEmail: this.incomingEmail, initialIncomingEmail: this.incomingEmail,
selectedTemplate: this.selectedTemplate, selectedTemplate: this.selectedTemplate,
outgoingName: this.outgoingName, outgoingName: this.outgoingName,
projectKey: this.projectKey,
templates: this.templates, templates: this.templates,
}, },
}); });
......
...@@ -13,10 +13,11 @@ class ServiceDeskService { ...@@ -13,10 +13,11 @@ class ServiceDeskService {
return axios.put(this.endpoint, { service_desk_enabled: enable }); return axios.put(this.endpoint, { service_desk_enabled: enable });
} }
updateTemplate({ selectedTemplate, outgoingName }, isEnabled) { updateTemplate({ selectedTemplate, outgoingName, projectKey = '' }, isEnabled) {
const body = { const body = {
issue_template_key: selectedTemplate, issue_template_key: selectedTemplate,
outgoing_name: outgoingName, outgoing_name: outgoingName,
project_key: projectKey,
service_desk_enabled: isEnabled, service_desk_enabled: isEnabled,
}; };
return axios.put(this.endpoint, body); return axios.put(this.endpoint, body);
......
...@@ -9,6 +9,10 @@ module EE ...@@ -9,6 +9,10 @@ module EE
before_action :log_download_export_audit_event, only: [:download_export] before_action :log_download_export_audit_event, only: [:download_export]
before_action :log_archive_audit_event, only: [:archive] before_action :log_archive_audit_event, only: [:archive]
before_action :log_unarchive_audit_event, only: [:unarchive] before_action :log_unarchive_audit_event, only: [:unarchive]
before_action do
push_frontend_feature_flag(:service_desk_custom_address)
end
end end
def restore def restore
......
---
title: Added setting to use a custom service desk email
merge_request: 25240
author:
type: added
...@@ -160,6 +160,7 @@ describe('ServiceDeskRoot', () => { ...@@ -160,6 +160,7 @@ describe('ServiceDeskRoot', () => {
selectedTemplate: 'Bug', selectedTemplate: 'Bug',
outgoingName: 'GitLab Support Bot', outgoingName: 'GitLab Support Bot',
templates: ['Bug', 'Documentation'], templates: ['Bug', 'Documentation'],
projectKey: 'key',
}, },
}); });
...@@ -169,6 +170,7 @@ describe('ServiceDeskRoot', () => { ...@@ -169,6 +170,7 @@ describe('ServiceDeskRoot', () => {
expect(spy).toHaveBeenCalledWith(endpoint, { expect(spy).toHaveBeenCalledWith(endpoint, {
issue_template_key: 'Bug', issue_template_key: 'Bug',
outgoing_name: 'GitLab Support Bot', outgoing_name: 'GitLab Support Bot',
project_key: 'key',
service_desk_enabled: true, service_desk_enabled: true,
}); });
}); });
......
...@@ -175,6 +175,7 @@ describe('ServiceDeskSetting', () => { ...@@ -175,6 +175,7 @@ describe('ServiceDeskSetting', () => {
isEnabled: true, isEnabled: true,
initialSelectedTemplate: 'Bug', initialSelectedTemplate: 'Bug',
initialOutgoingName: 'GitLab Support Bot', initialOutgoingName: 'GitLab Support Bot',
initialProjectKey: 'key',
}, },
}); });
...@@ -183,6 +184,7 @@ describe('ServiceDeskSetting', () => { ...@@ -183,6 +184,7 @@ describe('ServiceDeskSetting', () => {
expect(eventSpy).toHaveBeenCalledWith({ expect(eventSpy).toHaveBeenCalledWith({
selectedTemplate: 'Bug', selectedTemplate: 'Bug',
outgoingName: 'GitLab Support Bot', outgoingName: 'GitLab Support Bot',
projectKey: 'key',
}); });
eventHub.$off('serviceDeskTemplateSave', eventSpy); eventHub.$off('serviceDeskTemplateSave', eventSpy);
......
...@@ -111,6 +111,7 @@ describe('ServiceDeskService', () => { ...@@ -111,6 +111,7 @@ describe('ServiceDeskService', () => {
{ {
selectedTemplate: 'Bug', selectedTemplate: 'Bug',
outgoingName: 'GitLab Support Bot', outgoingName: 'GitLab Support Bot',
projectKey: 'key',
}, },
true, true,
); );
...@@ -118,6 +119,7 @@ describe('ServiceDeskService', () => { ...@@ -118,6 +119,7 @@ describe('ServiceDeskService', () => {
expect(spy).toHaveBeenCalledWith(endpoint, { expect(spy).toHaveBeenCalledWith(endpoint, {
issue_template_key: 'Bug', issue_template_key: 'Bug',
outgoing_name: 'GitLab Support Bot', outgoing_name: 'GitLab Support Bot',
project_key: 'key',
service_desk_enabled: true, service_desk_enabled: true,
}); });
......
...@@ -15632,6 +15632,12 @@ msgstr "" ...@@ -15632,6 +15632,12 @@ msgstr ""
msgid "Project name" msgid "Project name"
msgstr "" msgstr ""
msgid "Project name suffix"
msgstr ""
msgid "Project name suffix is a user-defined string which will be appended to the project path, and will form the Service Desk email address."
msgstr ""
msgid "Project order will not be saved as local storage is not available." msgid "Project order will not be saved as local storage is not available."
msgstr "" msgstr ""
......
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