Commit 61f6c080 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'rajatgitlab/service-desk-pj' into 'master'

Make Service Desk Pajamas Compliant

See merge request gitlab-org/gitlab!74795
parents 7b1d7a9a c9a40be0
<script> <script>
import { GlButton, GlToggle, GlLoadingIcon, GlSprintf, GlFormInput, GlLink } from '@gitlab/ui'; import {
GlButton,
GlToggle,
GlLoadingIcon,
GlSprintf,
GlFormInputGroup,
GlFormGroup,
GlFormInput,
GlLink,
} from '@gitlab/ui';
import { helpPagePath } from '~/helpers/help_page_helper'; import { helpPagePath } from '~/helpers/help_page_helper';
import { __ } from '~/locale'; import { __ } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
...@@ -16,6 +25,8 @@ export default { ...@@ -16,6 +25,8 @@ export default {
GlLoadingIcon, GlLoadingIcon,
GlSprintf, GlSprintf,
GlFormInput, GlFormInput,
GlFormGroup,
GlFormInputGroup,
GlLink, GlLink,
ServiceDeskTemplateDropdown, ServiceDeskTemplateDropdown,
}, },
...@@ -143,31 +154,29 @@ export default { ...@@ -143,31 +154,29 @@ export default {
</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 <gl-form-group
id="incoming-email-describer" :label="__('Email address to use for Support Desk')"
class="gl-display-block gl-mb-1" label-for="incoming-email"
data-testid="incoming-email-describer" data-testid="incoming-email-label"
> >
{{ __('Email address to use for Support Desk') }} <gl-form-input-group v-if="email">
</strong> <gl-form-input
<template v-if="email"> id="incoming-email"
<div class="input-group">
<input
ref="service-desk-incoming-email" ref="service-desk-incoming-email"
type="text" type="text"
class="form-control"
data-testid="incoming-email" data-testid="incoming-email"
:placeholder="__('Incoming email')" :placeholder="__('Incoming email')"
:aria-label="__('Incoming email')" :aria-label="__('Incoming email')"
aria-describedby="incoming-email-describer" aria-describedby="incoming-email-describer"
:value="email" :value="email"
disabled="true" :disabled="true"
/> />
<div class="input-group-append"> <template #append>
<clipboard-button :title="__('Copy')" :text="email" css-class="input-group-text" /> <clipboard-button :title="__('Copy')" :text="email" css-class="input-group-text" />
</div> </template>
</div> </gl-form-input-group>
<span v-if="hasCustomEmail" class="form-text text-muted"> <template v-if="email && hasCustomEmail" #description>
<span class="gl-mt-2 d-inline-block">
<gl-sprintf :message="__('Emails sent to %{email} are also supported.')"> <gl-sprintf :message="__('Emails sent to %{email} are also supported.')">
<template #email> <template #email>
<code>{{ incomingEmail }}</code> <code>{{ incomingEmail }}</code>
...@@ -175,31 +184,22 @@ export default { ...@@ -175,31 +184,22 @@ export default {
</gl-sprintf> </gl-sprintf>
</span> </span>
</template> </template>
<template v-else> <template v-if="!email">
<gl-loading-icon size="sm" :inline="true" /> <gl-loading-icon size="sm" :inline="true" />
<span class="sr-only">{{ __('Fetching incoming email') }}</span> <span class="sr-only">{{ __('Fetching incoming email') }}</span>
</template> </template>
</gl-form-group>
<label for="service-desk-project-suffix" class="mt-3"> <gl-form-group :label="__('Email address suffix')" :state="!projectKeyError">
{{ __('Email address suffix') }}
</label>
<gl-form-input <gl-form-input
v-if="hasProjectKeySupport" v-if="hasProjectKeySupport"
id="service-desk-project-suffix" id="service-desk-project-suffix"
v-model.trim="projectKey" v-model.trim="projectKey"
data-testid="project-suffix" data-testid="project-suffix"
class="form-control"
:state="!projectKeyError"
@blur="validateProjectKey" @blur="validateProjectKey"
/> />
<span v-if="hasProjectKeySupport && projectKeyError" class="form-text text-danger">
{{ projectKeyError }} <template v-if="hasProjectKeySupport" #description>
</span>
<span
v-if="hasProjectKeySupport"
class="form-text text-muted"
:class="{ 'gl-mt-2!': hasProjectKeySupport && projectKeyError }"
>
<gl-sprintf <gl-sprintf
:message=" :message="
__('Add a suffix to Service Desk email address. %{linkStart}Learn more.%{linkEnd}') __('Add a suffix to Service Desk email address. %{linkStart}Learn more.%{linkEnd}')
...@@ -214,8 +214,8 @@ export default { ...@@ -214,8 +214,8 @@ export default {
</gl-link> </gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
</span> </template>
<span v-else class="form-text text-muted"> <template v-else #description>
<gl-sprintf <gl-sprintf
:message=" :message="
__( __(
...@@ -232,25 +232,44 @@ export default { ...@@ -232,25 +232,44 @@ export default {
</gl-link> </gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
</span> </template>
<label for="service-desk-template-select" class="mt-3"> <template v-if="hasProjectKeySupport && projectKeyError" #invalid-feedback>
{{ __('Template to append to all Service Desk issues') }} {{ projectKeyError }}
</label> </template>
</gl-form-group>
<gl-form-group
:label="__('Template to append to all Service Desk issues')"
:state="!projectKeyError"
class="mt-3"
>
<service-desk-template-dropdown <service-desk-template-dropdown
:selected-template="selectedTemplate" :selected-template="selectedTemplate"
:selected-file-template-project-id="selectedFileTemplateProjectId" :selected-file-template-project-id="selectedFileTemplateProjectId"
:templates="templates" :templates="templates"
@change="templateChange" @change="templateChange"
/> />
</gl-form-group>
<label for="service-desk-email-from-name" class="mt-3"> <gl-form-group
{{ __('Email display name') }} :label="__('Email display name')"
</label> label-for="service-desk-email-from-name"
<input id="service-desk-email-from-name" v-model.trim="outgoingName" class="form-control" /> :state="!projectKeyError"
<span class="form-text text-muted"> class="mt-3"
>
<gl-form-input
v-if="hasProjectKeySupport"
id="service-desk-email-from-name"
v-model.trim="outgoingName"
data-testid="email-from-name"
/>
<template v-if="hasProjectKeySupport" #description>
{{ __('Emails sent from Service Desk have this name.') }} {{ __('Emails sent from Service Desk have this name.') }}
</span> </template>
</gl-form-group>
<div class="gl-display-flex gl-justify-content-end"> <div class="gl-display-flex gl-justify-content-end">
<gl-button <gl-button
variant="success" variant="success"
......
import { GlButton, GlDropdown, GlLoadingIcon, GlToggle } from '@gitlab/ui'; import { GlButton, GlDropdown, GlLoadingIcon, GlToggle } from '@gitlab/ui';
import { shallowMount, mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import ServiceDeskSetting from '~/projects/settings_service_desk/components/service_desk_setting.vue'; import ServiceDeskSetting from '~/projects/settings_service_desk/components/service_desk_setting.vue';
...@@ -11,14 +11,14 @@ describe('ServiceDeskSetting', () => { ...@@ -11,14 +11,14 @@ describe('ServiceDeskSetting', () => {
const findButton = () => wrapper.find(GlButton); const findButton = () => wrapper.find(GlButton);
const findClipboardButton = () => wrapper.find(ClipboardButton); const findClipboardButton = () => wrapper.find(ClipboardButton);
const findIncomingEmail = () => wrapper.findByTestId('incoming-email'); const findIncomingEmail = () => wrapper.findByTestId('incoming-email');
const findIncomingEmailLabel = () => wrapper.findByTestId('incoming-email-describer'); const findIncomingEmailLabel = () => wrapper.findByTestId('incoming-email-label');
const findLoadingIcon = () => wrapper.find(GlLoadingIcon); const findLoadingIcon = () => wrapper.find(GlLoadingIcon);
const findTemplateDropdown = () => wrapper.find(GlDropdown); const findTemplateDropdown = () => wrapper.find(GlDropdown);
const findToggle = () => wrapper.find(GlToggle); const findToggle = () => wrapper.find(GlToggle);
const createComponent = ({ props = {}, mountFunction = shallowMount } = {}) => const createComponent = ({ props = {} } = {}) =>
extendedWrapper( extendedWrapper(
mountFunction(ServiceDeskSetting, { mount(ServiceDeskSetting, {
propsData: { propsData: {
isEnabled: true, isEnabled: true,
...props, ...props,
...@@ -131,8 +131,7 @@ describe('ServiceDeskSetting', () => { ...@@ -131,8 +131,7 @@ describe('ServiceDeskSetting', () => {
it('shows error when value contains uppercase or special chars', async () => { it('shows error when value contains uppercase or special chars', async () => {
wrapper = createComponent({ wrapper = createComponent({
props: { customEmailEnabled: true }, props: { email: 'foo@bar.com', customEmailEnabled: true },
mountFunction: mount,
}); });
const input = wrapper.findByTestId('project-suffix'); const input = wrapper.findByTestId('project-suffix');
...@@ -142,7 +141,7 @@ describe('ServiceDeskSetting', () => { ...@@ -142,7 +141,7 @@ describe('ServiceDeskSetting', () => {
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
const errorText = wrapper.find('.text-danger'); const errorText = wrapper.find('.invalid-feedback');
expect(errorText.exists()).toBe(true); expect(errorText.exists()).toBe(true);
}); });
}); });
......
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