Skip to content

Adds CustomEmailStateFinished component

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:

  1. Using SMTP credentials. Foundation work.
  2. Verify email ownership, correct function and setup
  3. 🎯 Add settings and validation to Settings page.
  4. Ingest replies from custom email
  5. 👷🏻 Add documentation

What does this MR do and why?

Reworks custom email settings and adds `failed`... (!129004 - merged) introduces the failed state.

🎏 This feature is hidden behind a feature flag and not used on production yet.

This MR adds the CustomEmailStateFailed component to the CustomEmail wrapper component that is displayed on the projects settings page in the "Service Desk" section. After saving the custom email configuration in the form, GitLab triggers a verification process that sends a verification email to the custom email address. The verification process will end as failed or finished.

If the verification was successful this new component will be displayed. The administrator can then toggle the usage of the configured custom email or reset the custom email.

The component uses the same mechanics to reset the custom email configuration as the CustomEmailStateStarted component. It emits a reset event on button click that shows the confirm modal in the CustomEmail component.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

With disabled custom email address

image

With enabled custom email address (incl. toast)

image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Numbered steps to set up and validate the change are strongly suggested.

  1. Turn on (at least) incoming_email in your gitlab.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 of incoming_email from the production section:

    incoming_email:
     enabled: true
     address: "gitlab-incoming+%{key}@gmail.com"
  2. Enable service_desk_custom_email feature flag 🎏, e.g. for Flight project:

    Feature.enable(:service_desk_custom_email, Project.find(7)) # or your project id
  3. Run the following from the rails console to create a custom email address in the finished state:

    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)
    verification.mark_as_finished!
  4. Browse to http://127.0.0.1:3000/flightjs/Flight/edit and expand the Service Desk section and find the custom email card below the general settings. You should see the CustomEmailStateFinished component in the CustomEmail wrapper.

  5. Toggle the use of the custom email. In the network tab of the developer tools, you should see API calls that return either custom_email_enabled: true or false. You should also see a toast message.

  6. Reset the custom email. After resetting you should see the form.

  7. Whenever you'd like to rollback everything run this on the console:

    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.

Edited by Marc Saleiko

Merge request reports