From 848de49029934d840c047657fc00f79b51b979a0 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 17 Apr 2023 21:09:07 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/mailers/emails/service_desk.rb | 12 +++++ app/mailers/previews/notify_preview.rb | 40 +++++++++++++++ ...ervice_desk_verification_result_email.html.haml | 58 ++++++++++++++++++++++ ...service_desk_verification_result_email.text.erb | 38 ++++++++++++++ doc/user/admin_area/settings/help_page.md | 15 ++---- locale/gitlab.pot | 57 +++++++++++++++++++++ spec/mailers/emails/service_desk_spec.rb | 30 +++++++++++ 7 files changed, 240 insertions(+), 10 deletions(-) create mode 100644 app/views/notify/service_desk_verification_result_email.html.haml create mode 100644 app/views/notify/service_desk_verification_result_email.text.erb diff --git a/app/mailers/emails/service_desk.rb b/app/mailers/emails/service_desk.rb index f2327239699..e75882073f2 100644 --- a/app/mailers/emails/service_desk.rb +++ b/app/mailers/emails/service_desk.rb @@ -86,6 +86,18 @@ module Emails email_with_layout(to: recipient, subject: subject) end + def service_desk_verification_result_email(service_desk_setting, recipient) + @service_desk_setting = service_desk_setting + @verification = @service_desk_setting.custom_email_verification + + subject = format(s_("Notify|Verification result for custom email %{email} for %{project_name}"), + email: @service_desk_setting.custom_email, + project_name: @service_desk_setting.project.name + ) + + email_with_layout(to: recipient, subject: subject) + end + private def setup_service_desk_mail(issue_id) diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb index f6c4b05ab39..510f35ee0d2 100644 --- a/app/mailers/previews/notify_preview.rb +++ b/app/mailers/previews/notify_preview.rb @@ -229,6 +229,36 @@ class NotifyPreview < ActionMailer::Preview end end + def service_desk_verification_result_email_for_verified_state + cleanup do + setup_service_desk_custom_email_objects + + custom_email_verification.update!(state: 1) + + Notify.service_desk_verification_result_email(service_desk_setting, 'owner@example.com').message + end + end + + def service_desk_verification_result_email_for_incorrect_token_error + service_desk_verification_result_email_for_error_state(error: :incorrect_token) + end + + def service_desk_verification_result_email_for_incorrect_from_error + service_desk_verification_result_email_for_error_state(error: :incorrect_from) + end + + def service_desk_verification_result_email_for_mail_not_received_within_timeframe_error + service_desk_verification_result_email_for_error_state(error: :mail_not_received_within_timeframe) + end + + def service_desk_verification_result_email_for_invalid_credentials_error + service_desk_verification_result_email_for_error_state(error: :invalid_credentials) + end + + def service_desk_verification_result_email_for_smtp_host_issue_error + service_desk_verification_result_email_for_error_state(error: :smtp_host_issue) + end + def merge_when_pipeline_succeeds_email Notify.merge_when_pipeline_succeeds_email(user.id, merge_request.id, user.id).message end @@ -263,6 +293,16 @@ class NotifyPreview < ActionMailer::Preview @project ||= Project.first end + def service_desk_verification_result_email_for_error_state(error:) + cleanup do + setup_service_desk_custom_email_objects + + custom_email_verification.update!(state: 2, error: error) + + Notify.service_desk_verification_result_email(service_desk_setting, 'owner@example.com').message + end + end + def setup_service_desk_custom_email_objects # Call accessors to ensure objects have been created custom_email_credential diff --git a/app/views/notify/service_desk_verification_result_email.html.haml b/app/views/notify/service_desk_verification_result_email.html.haml new file mode 100644 index 00000000000..d63177e4a42 --- /dev/null +++ b/app/views/notify/service_desk_verification_result_email.html.haml @@ -0,0 +1,58 @@ +- project_link = @service_desk_setting.project.web_url +- project_link_start = ''.html_safe % { project_link: project_link } +- project_name = @service_desk_setting.project.human_name +- project_link_end = ''.html_safe +- settings_link = edit_project_url(@service_desk_setting.project, anchor: 'js-service-desk') +- settings_link_start = ''.html_safe % { settings_link: settings_link } +- settings_link_end = ''.html_safe +- strong_open = ''.html_safe +- strong_close = ''.html_safe +- email_address = @service_desk_setting.custom_email +- verify_email_address = @service_desk_setting.custom_email_address_for_verification +- code_open = ''.html_safe +- code_end = ''.html_safe + +%tr + %td.text-content + - if @verification.verified? + %h1{ :style => "margin-top:0;" } + = s_("Notify|Email successfully verified") + %p + = html_escape(s_('Notify|Your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end} was verified successfully.')) % { email_address: email_address, project_link_start: project_link_start, project_name: project_name, project_link_end: project_link_end, strong_open: strong_open, strong_close: strong_close } + %p + = html_escape(s_('Notify|To enable the custom email address, go to your %{settings_link_start}project\'s Service Desk settings page%{settings_link_end}.')) % { settings_link_start: settings_link_start, settings_link_end: settings_link_end } + - else + %h1{ :style => "margin-top:0;" } + = s_("Notify|Email could not be verified") + %p + = html_escape(s_('Notify|We could not verify your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end}.')) % { email_address: email_address, project_link_start: project_link_start, project_name: project_name, project_link_end: project_link_end, strong_open: strong_open, strong_close: strong_close } + - if @verification.smtp_host_issue? + %p + %b + = s_('Notify|SMTP host issue:') + = s_('Notify|We were not able to make a connection to the specified host or there was an SSL issue.') + - if @verification.invalid_credentials? + %p + %b + = s_('Notify|Invalid credentials:') + = s_('Notify|The given credentials (username and password) were rejected by the SMTP server.') + - if @verification.mail_not_received_within_timeframe? + %p + %b + = s_('Notify|Verification email not received within timeframe:') + = html_escape(s_('Notify|We did not receive the verification email we sent out to %{strong_open}%{email_address}%{strong_close} in time.')) % { email_address: verify_email_address, strong_open: strong_open, strong_close: strong_close } + %p + = s_('Notify|We wait for 30 minutes for messages to appear in your instance\'s Service Desk inbox.') + = s_('Notify|Please check that your service provider supports email subaddressing and that you have set up email forwarding correctly.') + - if @verification.incorrect_from? + %p + %b + = html_escape(s_('Notify|Incorrect %{code_open}From%{code_end} header:')) % { code_open: code_open, code_end: code_end } + = html_escape(s_('Notify|Check your forwarding settings and make sure the original email sender remains in the %{code_open}From%{code_end} header.')) % { code_open: code_open, code_end: code_end } + - if @verification.incorrect_token? + %p + %b + = s_('Notify|Incorrect verification token:') + = s_('Notify|We could not verify that we received the email we sent to your email inbox.') + %p + = html_escape(s_('Notify|To restart the verification process, go to your %{settings_link_start}project\'s Service Desk settings page%{settings_link_end}.')) % { settings_link_start: settings_link_start, settings_link_end: settings_link_end } diff --git a/app/views/notify/service_desk_verification_result_email.text.erb b/app/views/notify/service_desk_verification_result_email.text.erb new file mode 100644 index 00000000000..a78e3b19d1e --- /dev/null +++ b/app/views/notify/service_desk_verification_result_email.text.erb @@ -0,0 +1,38 @@ +<% project_name = @service_desk_setting.project.human_name %> +<% email_address = @service_desk_setting.custom_email %> +<% verify_email_address = @service_desk_setting.custom_email_address_for_verification %> + +<% if @verification.verified? %> + <%= s_("Notify|Email successfully verified") %> + + <%= s_('Notify|Your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end} was verified successfully.') % { email_address: email_address, project_link_start: '', project_name: project_name, project_link_end: '', strong_open: '', strong_close: '' } %> + + <%= s_('Notify|To enable the custom email address, go to your %{settings_link_start}project\'s Service Desk settings page%{settings_link_end}.') % { settings_link_start: '', settings_link_end: '' } %> +<% else %> + <%= s_("Notify|Email could not be verified") %> + + <%= s_('Notify|We could not verify your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end}.') % { email_address: email_address, project_link_start: '', project_name: project_name, project_link_end: '', strong_open: '', strong_close: '' } %> + + <% if @verification.smtp_host_issue? %> + <%= s_('Notify|SMTP host issue:') %> + <%= s_('Notify|We were not able to make a connection to the specified host or there was an SSL issue.') %> + <% elsif @verification.invalid_credentials? %> + <%= s_('Notify|Invalid credentials:') %> + <%= s_('Notify|The given credentials (username and password) were rejected by the SMTP server.') %> + <% elsif @verification.mail_not_received_within_timeframe? %> + <%= s_('Notify|Verification email not received within timeframe:') %> + <%= s_('Notify|We did not receive the verification email we sent out to %{strong_open}%{email_address}%{strong_close} in time.') % { email_address: verify_email_address, strong_open: '', strong_close: '' } %> + + <%= s_('Notify|We wait for 30 minutes for messages to appear in your instance\'s Service Desk inbox.') %> + + <%= s_('Notify|Please check that your service provider supports email subaddressing and that you have set up email forwarding correctly.') %> + <% elsif @verification.incorrect_from? %> + <%= s_('Notify|Incorrect %{code_open}From%{code_end} header:') % { code_open: '', code_end: '' } %> + <%= s_('Notify|Check your forwarding settings and make sure the original email sender remains in the %{code_open}From%{code_end} header.') % { code_open: '', code_end: '' } %> + <% elsif @verification.incorrect_token? %> + <%= s_('Notify|Incorrect verification token:') %> + <%= s_('Notify|We could not verify that we received the email we sent to your email inbox.') %> + <% end %> + + <%= s_('Notify|To restart the verification process, go to your %{settings_link_start}project\'s Service Desk settings page%{settings_link_end}.') % { settings_link_start: '', settings_link_end: '' } %> +<% end %> diff --git a/doc/user/admin_area/settings/help_page.md b/doc/user/admin_area/settings/help_page.md index 07d3ae83d74..5d9fc23aaff 100644 --- a/doc/user/admin_area/settings/help_page.md +++ b/doc/user/admin_area/settings/help_page.md @@ -71,14 +71,7 @@ You can specify a custom URL to which users are directed when they: > - [Feature flag `help_page_documentation_redirect`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71737) removed in GitLab 14.4. > - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71737) in GitLab 14.4. -The `/help` URL of a GitLab instance displays a basic version of the documentation sourced from the -[`doc` directory](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc) of GitLab. `/help` links -are often used for contextual help. - -You can redirect these `/help` links to either: - -- The more navigable and searchable version published at [`docs.gitlab.com`](https://docs.gitlab.com). -- A destination that meets [necessary requirements](#destination-requirements). +You can redirect all `/help` links to a destination that meets the [necessary requirements](#destination-requirements). 1. On the top bar, select **Main menu > Admin**. 1. On the left sidebar, select **Settings > Preferences**. @@ -86,17 +79,19 @@ You can redirect these `/help` links to either: 1. In the **Documentation pages URL** field, enter the URL. 1. Select **Save changes**. +If the "Documentation pages URL" field is empty, the GitLab instance displays a basic version of the documentation sourced from the [`doc` directory](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc) of GitLab. + ### Destination requirements When redirecting `/help`, GitLab: - Redirects requests to the specified URL. -- Appends `ee` and the documentation path to the URL. +- Appends `ee` and the documentation path, which includes the version number, to the URL. - Appends `.html` to the URL, and removes `.md` if necessary. For example, if the URL is set to `https://docs.gitlab.com`, requests for `/help/user/admin_area/settings/help_page.md` redirect to: -`https://docs.gitlab.com/ee/user/admin_area/settings/help_page.html`. +`https://docs.gitlab.com/${VERSION}/ee/user/admin_area/settings/help_page.html`.