Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
aaf84be4
Commit
aaf84be4
authored
Oct 23, 2020
by
Donald Cook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated service desk incoming email to use custom email
Also fixed tests
parent
497143d0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
117 deletions
+30
-117
app/assets/javascripts/projects/settings_service_desk/components/service_desk_root.vue
...ts/settings_service_desk/components/service_desk_root.vue
+9
-24
app/assets/javascripts/projects/settings_service_desk/components/service_desk_setting.vue
...settings_service_desk/components/service_desk_setting.vue
+16
-6
app/assets/javascripts/projects/settings_service_desk/index.js
...ssets/javascripts/projects/settings_service_desk/index.js
+3
-1
app/assets/javascripts/projects/settings_service_desk/services/service_desk_service.js
...ts/settings_service_desk/services/service_desk_service.js
+0
-4
app/views/projects/_service_desk_settings.html.haml
app/views/projects/_service_desk_settings.html.haml
+1
-1
locale/gitlab.pot
locale/gitlab.pot
+0
-3
spec/frontend/projects/settings_service_desk/components/service_desk_root_spec.js
...ettings_service_desk/components/service_desk_root_spec.js
+1
-60
spec/frontend/projects/settings_service_desk/services/service_desk_service_spec.js
...ttings_service_desk/services/service_desk_service_spec.js
+0
-18
No files found.
app/assets/javascripts/projects/settings_service_desk/components/service_desk_root.vue
View file @
aaf84be4
...
@@ -20,7 +20,12 @@ export default {
...
@@ -20,7 +20,12 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
initialIncomingEmail
:
{
incomingEmail
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
customEmail
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
''
,
default
:
''
,
...
@@ -50,23 +55,18 @@ export default {
...
@@ -50,23 +55,18 @@ export default {
data
()
{
data
()
{
return
{
return
{
isEnabled
:
this
.
initialIsEnabled
,
isEnabled
:
this
.
initialIsEnabled
,
incomingEmail
:
this
.
initialIncomingEmail
,
isTemplateSaving
:
false
,
isTemplateSaving
:
false
,
isAlertShowing
:
false
,
isAlertShowing
:
false
,
alertVariant
:
'
danger
'
,
alertVariant
:
'
danger
'
,
alertMessage
:
''
,
alertMessage
:
''
,
updatedCustomEmail
:
this
.
customEmail
,
};
};
},
},
created
()
{
created
()
{
eventHub
.
$on
(
'
serviceDeskEnabledCheckboxToggled
'
,
this
.
onEnableToggled
);
eventHub
.
$on
(
'
serviceDeskEnabledCheckboxToggled
'
,
this
.
onEnableToggled
);
eventHub
.
$on
(
'
serviceDeskTemplateSave
'
,
this
.
onSaveTemplate
);
eventHub
.
$on
(
'
serviceDeskTemplateSave
'
,
this
.
onSaveTemplate
);
this
.
service
=
new
ServiceDeskService
(
this
.
endpoint
);
this
.
service
=
new
ServiceDeskService
(
this
.
endpoint
);
if
(
this
.
isEnabled
&&
!
this
.
incomingEmail
)
{
this
.
fetchIncomingEmail
();
}
},
},
beforeDestroy
()
{
beforeDestroy
()
{
...
@@ -75,22 +75,6 @@ export default {
...
@@ -75,22 +75,6 @@ export default {
},
},
methods
:
{
methods
:
{
fetchIncomingEmail
()
{
this
.
service
.
fetchIncomingEmail
()
.
then
(({
data
})
=>
{
const
email
=
data
.
service_desk_address
;
if
(
!
email
)
{
throw
new
Error
(
__
(
"
Response didn't include `service_desk_address`
"
));
}
this
.
incomingEmail
=
email
;
})
.
catch
(()
=>
this
.
showAlert
(
__
(
'
An error occurred while fetching the Service Desk address.
'
)),
);
},
onEnableToggled
(
isChecked
)
{
onEnableToggled
(
isChecked
)
{
this
.
isEnabled
=
isChecked
;
this
.
isEnabled
=
isChecked
;
this
.
incomingEmail
=
''
;
this
.
incomingEmail
=
''
;
...
@@ -119,7 +103,7 @@ export default {
...
@@ -119,7 +103,7 @@ export default {
this
.
service
this
.
service
.
updateTemplate
({
selectedTemplate
,
outgoingName
,
projectKey
},
this
.
isEnabled
)
.
updateTemplate
({
selectedTemplate
,
outgoingName
,
projectKey
},
this
.
isEnabled
)
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
this
.
incoming
Email
=
data
?.
service_desk_address
;
this
.
updatedCustom
Email
=
data
?.
service_desk_address
;
this
.
showAlert
(
__
(
'
Changes were successfully made.
'
),
'
success
'
);
this
.
showAlert
(
__
(
'
Changes were successfully made.
'
),
'
success
'
);
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
...
@@ -155,6 +139,7 @@ export default {
...
@@ -155,6 +139,7 @@ export default {
<service-desk-setting
<service-desk-setting
:is-enabled=
"isEnabled"
:is-enabled=
"isEnabled"
:incoming-email=
"incomingEmail"
:incoming-email=
"incomingEmail"
:custom-email=
"updatedCustomEmail"
:initial-selected-template=
"selectedTemplate"
:initial-selected-template=
"selectedTemplate"
:initial-outgoing-name=
"outgoingName"
:initial-outgoing-name=
"outgoingName"
:initial-project-key=
"projectKey"
:initial-project-key=
"projectKey"
...
...
app/assets/javascripts/projects/settings_service_desk/components/service_desk_setting.vue
View file @
aaf84be4
...
@@ -26,6 +26,11 @@ export default {
...
@@ -26,6 +26,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
''
,
default
:
''
,
},
},
customEmail
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
initialSelectedTemplate
:
{
initialSelectedTemplate
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
...
@@ -57,7 +62,6 @@ export default {
...
@@ -57,7 +62,6 @@ export default {
selectedTemplate
:
this
.
initialSelectedTemplate
,
selectedTemplate
:
this
.
initialSelectedTemplate
,
outgoingName
:
this
.
initialOutgoingName
||
__
(
'
GitLab Support Bot
'
),
outgoingName
:
this
.
initialOutgoingName
||
__
(
'
GitLab Support Bot
'
),
projectKey
:
this
.
initialProjectKey
,
projectKey
:
this
.
initialProjectKey
,
baseEmail
:
this
.
incomingEmail
.
replace
(
this
.
initialProjectKey
,
''
),
};
};
},
},
computed
:
{
computed
:
{
...
@@ -67,6 +71,12 @@ export default {
...
@@ -67,6 +71,12 @@ export default {
hasProjectKeySupport
()
{
hasProjectKeySupport
()
{
return
Boolean
(
this
.
glFeatures
.
serviceDeskCustomAddress
);
return
Boolean
(
this
.
glFeatures
.
serviceDeskCustomAddress
);
},
},
email
()
{
return
this
.
customEmail
||
this
.
incomingEmail
;
},
hasCustomEmail
()
{
return
this
.
customEmail
&&
this
.
customEmail
!==
this
.
incomingEmail
;
},
},
},
methods
:
{
methods
:
{
onCheckboxToggle
(
isChecked
)
{
onCheckboxToggle
(
isChecked
)
{
...
@@ -101,7 +111,7 @@ export default {
...
@@ -101,7 +111,7 @@ export default {
<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=
"
incomingE
mail"
>
<template
v-if=
"
e
mail"
>
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<input
<input
ref=
"service-desk-incoming-email"
ref=
"service-desk-incoming-email"
...
@@ -110,21 +120,21 @@ export default {
...
@@ -110,21 +120,21 @@ export default {
: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=
"
incomingE
mail"
:value=
"
e
mail"
disabled=
"true"
disabled=
"true"
/>
/>
<div
class=
"input-group-append"
>
<div
class=
"input-group-append"
>
<clipboard-button
<clipboard-button
:title=
"__('Copy')"
:title=
"__('Copy')"
:text=
"
incomingE
mail"
:text=
"
e
mail"
css-class=
"input-group-text qa-clipboard-button"
css-class=
"input-group-text qa-clipboard-button"
/>
/>
</div>
</div>
</div>
</div>
<span
v-if=
"
projectKey
"
class=
"form-text text-muted"
>
<span
v-if=
"
hasCustomEmail
"
class=
"form-text text-muted"
>
<gl-sprintf
:message=
"__('Emails sent to %
{email} will still be supported')">
<gl-sprintf
:message=
"__('Emails sent to %
{email} will still be supported')">
<template
#email
>
<template
#email
>
<code>
{{
base
Email
}}
</code>
<code>
{{
incoming
Email
}}
</code>
</
template
>
</
template
>
</gl-sprintf>
</gl-sprintf>
</span>
</span>
...
...
app/assets/javascripts/projects/settings_service_desk/index.js
View file @
aaf84be4
...
@@ -17,6 +17,7 @@ export default () => {
...
@@ -17,6 +17,7 @@ export default () => {
initialIsEnabled
:
parseBoolean
(
dataset
.
enabled
),
initialIsEnabled
:
parseBoolean
(
dataset
.
enabled
),
endpoint
:
dataset
.
endpoint
,
endpoint
:
dataset
.
endpoint
,
incomingEmail
:
dataset
.
incomingEmail
,
incomingEmail
:
dataset
.
incomingEmail
,
customEmail
:
dataset
.
customEmail
,
selectedTemplate
:
dataset
.
selectedTemplate
,
selectedTemplate
:
dataset
.
selectedTemplate
,
outgoingName
:
dataset
.
outgoingName
,
outgoingName
:
dataset
.
outgoingName
,
projectKey
:
dataset
.
projectKey
,
projectKey
:
dataset
.
projectKey
,
...
@@ -28,7 +29,8 @@ export default () => {
...
@@ -28,7 +29,8 @@ export default () => {
props
:
{
props
:
{
initialIsEnabled
:
this
.
initialIsEnabled
,
initialIsEnabled
:
this
.
initialIsEnabled
,
endpoint
:
this
.
endpoint
,
endpoint
:
this
.
endpoint
,
initialIncomingEmail
:
this
.
incomingEmail
,
incomingEmail
:
this
.
incomingEmail
,
customEmail
:
this
.
customEmail
,
selectedTemplate
:
this
.
selectedTemplate
,
selectedTemplate
:
this
.
selectedTemplate
,
outgoingName
:
this
.
outgoingName
,
outgoingName
:
this
.
outgoingName
,
projectKey
:
this
.
projectKey
,
projectKey
:
this
.
projectKey
,
...
...
app/assets/javascripts/projects/settings_service_desk/services/service_desk_service.js
View file @
aaf84be4
...
@@ -5,10 +5,6 @@ class ServiceDeskService {
...
@@ -5,10 +5,6 @@ class ServiceDeskService {
this
.
endpoint
=
endpoint
;
this
.
endpoint
=
endpoint
;
}
}
fetchIncomingEmail
()
{
return
axios
.
get
(
this
.
endpoint
);
}
toggleServiceDesk
(
enable
)
{
toggleServiceDesk
(
enable
)
{
return
axios
.
put
(
this
.
endpoint
,
{
service_desk_enabled
:
enable
});
return
axios
.
put
(
this
.
endpoint
,
{
service_desk_enabled
:
enable
});
}
}
...
...
app/views/projects/_service_desk_settings.html.haml
View file @
aaf84be4
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
-
if
::
Gitlab
::
ServiceDesk
.
supported?
-
if
::
Gitlab
::
ServiceDesk
.
supported?
.js-service-desk-setting-root
{
data:
{
endpoint:
project_service_desk_path
(
@project
),
.js-service-desk-setting-root
{
data:
{
endpoint:
project_service_desk_path
(
@project
),
enabled:
"#{@project.service_desk_enabled}"
,
enabled:
"#{@project.service_desk_enabled}"
,
incoming_email:
(
@project
.
service_desk_address
if
@project
.
service_desk_enabled
),
incoming_email:
(
@project
.
service_desk_
incoming_
address
if
@project
.
service_desk_enabled
),
custom_email:
(
@project
.
service_desk_custom_address
if
@project
.
service_desk_enabled
),
custom_email:
(
@project
.
service_desk_custom_address
if
@project
.
service_desk_enabled
),
selected_template:
"#{@project.service_desk_setting&.issue_template_key}"
,
selected_template:
"#{@project.service_desk_setting&.issue_template_key}"
,
outgoing_name:
"#{@project.service_desk_setting&.outgoing_name}"
,
outgoing_name:
"#{@project.service_desk_setting&.outgoing_name}"
,
...
...
locale/gitlab.pot
View file @
aaf84be4
...
@@ -3013,9 +3013,6 @@ msgstr ""
...
@@ -3013,9 +3013,6 @@ msgstr ""
msgid "An error occurred while fetching terraform reports."
msgid "An error occurred while fetching terraform reports."
msgstr ""
msgstr ""
msgid "An error occurred while fetching the Service Desk address."
msgstr ""
msgid "An error occurred while fetching the board lists. Please try again."
msgid "An error occurred while fetching the board lists. Please try again."
msgstr ""
msgstr ""
...
...
spec/frontend/projects/settings_service_desk/components/service_desk_root_spec.js
View file @
aaf84be4
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
{
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
'
~/projects/settings_service_desk/components/service_desk_root.vue
'
;
import
ServiceDeskRoot
from
'
~/projects/settings_service_desk/components/service_desk_root.vue
'
;
...
@@ -24,65 +24,6 @@ describe('ServiceDeskRoot', () => {
...
@@ -24,65 +24,6 @@ describe('ServiceDeskRoot', () => {
}
}
});
});
it
(
'
fetches incoming email when there is no incoming email provided
'
,
()
=>
{
axiosMock
.
onGet
(
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
);
wrapper
=
shallowMount
(
ServiceDeskRoot
,
{
propsData
:
{
initialIsEnabled
:
true
,
initialIncomingEmail
:
''
,
endpoint
,
},
});
return
wrapper
.
vm
.
$nextTick
()
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
axiosMock
.
history
.
get
).
toHaveLength
(
1
);
});
});
it
(
'
does not fetch incoming email when there is an incoming email provided
'
,
()
=>
{
axiosMock
.
onGet
(
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
);
wrapper
=
shallowMount
(
ServiceDeskRoot
,
{
propsData
:
{
initialIsEnabled
:
true
,
initialIncomingEmail
,
endpoint
,
},
});
return
wrapper
.
vm
.
$nextTick
()
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
axiosMock
.
history
.
get
).
toHaveLength
(
0
);
});
});
it
(
'
shows an error message when incoming email is not fetched correctly
'
,
()
=>
{
axiosMock
.
onGet
(
endpoint
).
networkError
();
wrapper
=
shallowMount
(
ServiceDeskRoot
,
{
propsData
:
{
initialIsEnabled
:
true
,
initialIncomingEmail
:
''
,
endpoint
,
},
});
return
wrapper
.
vm
.
$nextTick
()
.
then
(
waitForPromises
)
.
then
(()
=>
{
expect
(
wrapper
.
html
()).
toContain
(
'
An error occurred while fetching the Service Desk address.
'
,
);
});
});
it
(
'
sends a request to toggle service desk off when the toggle is clicked from the on state
'
,
()
=>
{
it
(
'
sends a request to toggle service desk off when the toggle is clicked from the on state
'
,
()
=>
{
axiosMock
.
onPut
(
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
);
axiosMock
.
onPut
(
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
);
...
...
spec/frontend/projects/settings_service_desk/services/service_desk_service_spec.js
View file @
aaf84be4
...
@@ -19,24 +19,6 @@ describe('ServiceDeskService', () => {
...
@@ -19,24 +19,6 @@ describe('ServiceDeskService', () => {
axiosMock
.
restore
();
axiosMock
.
restore
();
});
});
describe
(
'
fetchIncomingEmail
'
,
()
=>
{
it
(
'
makes a request to fetch incoming email
'
,
()
=>
{
axiosMock
.
onGet
(
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
,
dummyResponse
);
return
service
.
fetchIncomingEmail
().
then
(
response
=>
{
expect
(
response
.
data
).
toEqual
(
dummyResponse
);
});
});
it
(
'
fails on error response
'
,
()
=>
{
axiosMock
.
onGet
(
endpoint
).
networkError
();
return
service
.
fetchIncomingEmail
().
catch
(
error
=>
{
expect
(
error
.
message
).
toBe
(
errorMessage
);
});
});
});
describe
(
'
toggleServiceDesk
'
,
()
=>
{
describe
(
'
toggleServiceDesk
'
,
()
=>
{
it
(
'
makes a request to set service desk
'
,
()
=>
{
it
(
'
makes a request to set service desk
'
,
()
=>
{
axiosMock
.
onPut
(
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
,
dummyResponse
);
axiosMock
.
onPut
(
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
,
dummyResponse
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment