Adds Service Desk settings custom email verification started state
Feature context
Click to expand 👇
Right now it is not possible to customize the Service Desk email address (intake and sending) in its entirety. On self-hosted instances you have more control over the used addresses, but you will still have a rather cryptic target email address for a specific service desk in a project. For .com users it's currently not possible to customize the Service Desk email at all.
There is a proposal and a further exploration around this issue. A summary of the solution path is the following: Users set up their custom email to forward all emails to the cryptic Service Desk email and provide SMTP credentials so we can send emails on their behalf. This way customers seeking support will only see the custom email address in their communication.
There is further discussion about improving and changing the general infrastructure, but this approach is a MVC to solve the issue for our customers.
🗺 How does it contribute to the whole feature?
This MR is part of a series of MRs that will follow in order to complete this feature. See #329990 (comment 1227384943) for a detailed breakdown. Here's a summary:
-
✅ Using SMTP credentials. Foundation work. -
✅ Verify email ownership, correct function and setup -
🎯 Add settings and validation to Settings page.- Backend
-
✅ Create and Destroy Services -
✅ CustomEmailController
-
- Frontend
-
✅ CustomEmail component foundation with initial resource fetching -
✅ CustomEmailForm component with resource saving -
🎯 CustomEmailStateStarted and CustomEmailConfirmModal components (with resource deletion) -
👷🏻 CustomEmailStateFailed component (with resource deletion) -
🚫 CustomEmailStateFinished component with resource update
-
- Backend
- Ingest replies from custom email
-
👷🏻 Add documentation
What does this MR do and why?
Adds Service Desk settings custom email form co... (!128095 - merged) is a merge request dependency and this MR targets the dependency's branch to clean up diffs. Once !128095 (merged) has been merged, I'll rebase this MR on the current master. Rebased on master
This MR introduces the following:
-
CustomEmailConfirmModal
component that displays a generic confirm modal for resetting the custom email configuration (will be reused by buttons on all other upcoming state screens) -
CustomEmailStateStarted
component that's the screen the administrator will see when they saved the custom email configuration until the verification transitioned into the final statesfailed
orfinished
. - Additions to
CustomEmail
component. Adds the above mentioned components and wires everything up. Adds resource deletion methods. Saving the custom email configuration triggers a verification process, where we send a verification email to the custom email using the provided SMTP credentials. While we wait for the process to finish, theCustomEmail
component will poll the resource endpoint every 8 seconds for updates.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
There are no before/after screenshots, because the components/screens are new.
Verification state started
screen after the custom email configuration has been saved successfully:
Confirm modal. Confirms resetting and deleting the current custom email configuration. Please note that this modal will be reused by all other state screens (failed
and finished
, handled in future MRs):
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Turn on (at least)
incoming_email
in yourgitlab.yml
so you can use Service Desk. You can add an example configuration, it doesn't matter for this MR. The below should do the trick. If not copy the full config ofincoming_email
from theproduction
section:incoming_email: enabled: true address: "gitlab-incoming+%{key}@gmail.com"
-
Enable
service_desk_custom_email
feature flag🎏 , e.g. forFlight
project:Feature.enable(:service_desk_custom_email, Project.find(7)) # or your project id
Now you have two options: 1) provide correct credentials, so the verification doesn't fail immediately or 2) fake-set-up a custom email configuration in the started
state:
Provide correct credentials
- Browse to
http://127.0.0.1:3000/flightjs/Flight/edit
and expand theService Desk
section and find the custom email card below the general settings. - Fill in the fields and save the configuration
- You should find a verification email in the custom email inbox and if you set up email forwarding (not necessary to test this MR) also in the forwarding target.
Fake-set-up custom email in started
state (recommended):
-
Add an example configuration in the
started
state via the rails consolebin/rails c
assuming project id7
:project = Project.find(7) current_user = User.first custom_email = 'support@example.com' setting = ServiceDeskSetting.find_or_create_by!(project_id: project.id) setting.update!(custom_email: custom_email) credential = ServiceDesk::CustomEmailCredential.create!( project_id: project.id, smtp_address: 'smtp.gmail.com', # we need a valid smtp address smtp_port: 587, smtp_username: custom_email, smtp_password: 'supersecret' ) verification = ServiceDesk::CustomEmailVerification.new( project_id: project.id ) verification.mark_as_started!(current_user)
-
Browse to
http://127.0.0.1:3000/flightjs/Flight/edit
and expand theService Desk
section and find the custom email card below the general settings.
continue
- See the
CustomEmailStateStarted
component is being displayed - Open the developer tools and see that the resource is being updated every 8 seconds via a backend API call.
- Select
Cancel & reset custom email
and see theCustomEmailConfirmModal
being displayed. - Select
Cancel
orX
and see that the state didn't change and there was no API call to delete the resource. - Select
Cancel & reset custom email
again and thenReset custom email and delete credentials
and see aDELETE
API call in the developer tools. In the app the form should be displayed and the toast messageReset custom email address.
should appear.
If you're stuck and you'd like to delete the current configuration use this snippet:
project = Project.find(7)
current_user = User.first
::ServiceDesk::CustomEmails::DestroyService.new(
project: project,
current_user: current_user
).execute
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.