From 7eca1eaafb71ca0b22494abaab6364bb91a35c80 Mon Sep 17 00:00:00 2001 From: James Nutt <jnutt@gitlab.com> Date: Mon, 17 Jun 2024 13:31:59 +0000 Subject: [PATCH] Update bulk import completion template This MR updates the post-completion email for direct transfer to remove reference to the destination namespace. This is to avoid confusion in cases where the same import contains targets multiple destination namespaces. --- app/mailers/emails/imports.rb | 7 ++----- app/views/notify/bulk_import_complete.html.haml | 10 +++------- app/views/notify/bulk_import_complete.text.erb | 4 +--- locale/gitlab.pot | 8 ++++---- spec/mailers/emails/imports_spec.rb | 10 ++++------ spec/mailers/previews_spec.rb | 1 - 6 files changed, 14 insertions(+), 26 deletions(-) diff --git a/app/mailers/emails/imports.rb b/app/mailers/emails/imports.rb index bb6262bfa3ee0..2fc777eec4ce2 100644 --- a/app/mailers/emails/imports.rb +++ b/app/mailers/emails/imports.rb @@ -15,13 +15,10 @@ def github_gists_import_errors_email(user_id, errors) def bulk_import_complete(user_id, bulk_import_id) user = User.find(user_id) @bulk_import = BulkImport.find(bulk_import_id) - @bulk_import_entity = @bulk_import.parent_group_entity @hostname = @bulk_import.configuration.url - @source_group = @bulk_import_entity.source_full_path title = safe_format( - s_('BulkImport|Import of %{source_group} from %{hostname}'), - hostname: @hostname, - source_group: @source_group + s_('BulkImport|Import from %{hostname} completed'), + hostname: @hostname ) email_with_layout( diff --git a/app/views/notify/bulk_import_complete.html.haml b/app/views/notify/bulk_import_complete.html.haml index 93543c3edd51f..68db64c235b1b 100644 --- a/app/views/notify/bulk_import_complete.html.haml +++ b/app/views/notify/bulk_import_complete.html.haml @@ -3,20 +3,16 @@ - button_style = 'border: 1px solid #694cc0; border-radius: 4px; font-size: 14px; padding: 8px 16px; background-color: #7b58cf; color: #fff; cursor: pointer;' - strong_tag_pair = tag_pair(tag.strong, :strong_open, :strong_close) -- strong_color_tag_pair = tag_pair(tag.strong(style: 'color: #7b58cf'), :strong_color_open, :strong_color_close) - -- destination_group = @bulk_import_entity.full_path_with_fallback +- start_date = l(@bulk_import.created_at.to_date, format: :long) %h1{ style: header_style } = s_('BulkImport|Import completed') %p{ style: text_style } - = safe_format(s_('BulkImport|The import of %{strong_open}%{source_group}%{strong_close} from %{strong_open}%{hostname}%{strong_close} to %{strong_color_open}%{destination_group}%{strong_color_close} is complete. You can view the results of the import.'), + = safe_format(s_('BulkImport|The import you started on %{start_date} from %{strong_open}%{hostname}%{strong_close} has completed. You can now review your import results.'), strong_tag_pair, - strong_color_tag_pair, - source_group: @source_group, hostname: @hostname, - destination_group: destination_group) + start_date: start_date) %p{ style: text_style } = link_to history_import_bulk_import_url(@bulk_import.id), target: '_blank', rel: 'noopener noreferrer' do diff --git a/app/views/notify/bulk_import_complete.text.erb b/app/views/notify/bulk_import_complete.text.erb index a23ad2dd88bff..aed0b79b6f78c 100644 --- a/app/views/notify/bulk_import_complete.text.erb +++ b/app/views/notify/bulk_import_complete.text.erb @@ -1,7 +1,5 @@ -<% destination_group = @bulk_import_entity.full_path_with_fallback %> - <%= s_('BulkImport|Import completed') %> -<%= safe_format(s_('BulkImport|The import of %{strong_open}%{source_group}%{strong_close} from %{strong_open}%{hostname}%{strong_close} to %{strong_color_open}%{destination_group}%{strong_color_close} is complete. You can view the results of the import.'), strong_open: '', strong_close: '', strong_color_open: '', strong_color_close: '', source_group: @source_group, hostname: @hostname, destination_group: destination_group) %> +<%= safe_format(s_('BulkImport|The import you started on %{start_date} from %{strong_open}%{hostname}%{strong_close} has completed. You can now review your import results.'), strong_open: '', strong_close: '', hostname: @hostname, start_date: l(@bulk_import.created_at.to_date, format: :long)) %> <%= s_('BulkImport|View import results') %>: <%= history_import_bulk_import_url(@bulk_import.id) %> diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 0aecf29d8b9d2..e362b06a034a4 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -9756,13 +9756,13 @@ msgstr "" msgid "BulkImport|Import failed: Destination cannot be a subgroup of the source group. Change the destination and try again." msgstr "" -msgid "BulkImport|Import groups by direct transfer" +msgid "BulkImport|Import from %{hostname} completed" msgstr "" -msgid "BulkImport|Import is finished. Pick another name for re-import" +msgid "BulkImport|Import groups by direct transfer" msgstr "" -msgid "BulkImport|Import of %{source_group} from %{hostname}" +msgid "BulkImport|Import is finished. Pick another name for re-import" msgstr "" msgid "BulkImport|Import with projects" @@ -9867,7 +9867,7 @@ msgstr "" msgid "BulkImport|Template / File-based import / Direct transfer" msgstr "" -msgid "BulkImport|The import of %{strong_open}%{source_group}%{strong_close} from %{strong_open}%{hostname}%{strong_close} to %{strong_color_open}%{destination_group}%{strong_color_close} is complete. You can view the results of the import." +msgid "BulkImport|The import you started on %{start_date} from %{strong_open}%{hostname}%{strong_close} has completed. You can now review your import results." msgstr "" msgid "BulkImport|This %{importable} was imported from another instance." diff --git a/spec/mailers/emails/imports_spec.rb b/spec/mailers/emails/imports_spec.rb index 770cbbc21bca8..4469b3339acd4 100644 --- a/spec/mailers/emails/imports_spec.rb +++ b/spec/mailers/emails/imports_spec.rb @@ -30,22 +30,20 @@ describe '#bulk_import_complete' do let(:bulk_import) { build_stubbed(:bulk_import, :finished, :with_configuration) } - let(:bulk_import_entity) { build_stubbed(:bulk_import_entity, :group_entity) } subject { Notify.bulk_import_complete('user_id', 'bulk_import_id') } before do allow(User).to receive(:find).and_return(user) allow(BulkImport).to receive(:find).and_return(bulk_import) - allow(bulk_import).to receive(:parent_group_entity).and_return(bulk_import_entity) end it 'sends complete email' do - is_expected.to have_subject("Import of #{bulk_import_entity.source_full_path} from " \ - "#{bulk_import.configuration.url}") + is_expected.to have_subject("Import from #{bulk_import.configuration.url} completed") is_expected.to have_content('Import completed') - is_expected.to have_content("The import of #{bulk_import_entity.source_full_path} from " \ - "#{bulk_import.configuration.url} to #{bulk_import_entity.full_path_with_fallback} is complete.") + is_expected.to have_content("The import you started on " \ + "#{I18n.l(bulk_import.created_at.to_date, format: :long)} " \ + "from #{bulk_import.configuration.url} has completed. You can now review your import results.") is_expected.to have_body_text(history_import_bulk_import_url(bulk_import.id)) end end diff --git a/spec/mailers/previews_spec.rb b/spec/mailers/previews_spec.rb index b1eef1205e279..1957d13f5eb74 100644 --- a/spec/mailers/previews_spec.rb +++ b/spec/mailers/previews_spec.rb @@ -16,7 +16,6 @@ let_it_be(:review) { create(:review, project: project, merge_request: merge_request, author: user) } let_it_be(:key) { create(:key, user: user) } let_it_be(:bulk_import) { create(:bulk_import, :finished, :with_configuration) } - let_it_be(:bulk_import_entity) { create(:bulk_import_entity, :group_entity, bulk_import: bulk_import) } Gitlab.ee do let_it_be(:epic) { create(:epic, group: group) } -- GitLab