From da3c3b4da3d44b82d37a1373fbc913acb640ed89 Mon Sep 17 00:00:00 2001
From: Justin Ho Tuan Duong <hduong@gitlab.com>
Date: Thu, 29 Aug 2024 08:15:23 +0000
Subject: [PATCH] Add lazy loading to placeholders tab

Prevents app from initializing immediately after page load of
"Group > Members" page, causing the "Placeholders" tab
to be active.

This changes reverts to the old behaviour of showing the
"Members" tab on load.
---
 .../javascripts/members/components/members_tabs.vue |  1 +
 .../members/placeholders/components/app.vue         |  2 ++
 app/assets/javascripts/members/tabs_metadata.js     |  1 +
 .../import/source_users/_accept_invite.html.haml    |  4 +++-
 .../import/source_users/_cancel_invite.html.haml    |  4 +++-
 .../import/source_users/_reject_invite.html.haml    |  4 +++-
 app/views/import/source_users/show.html.haml        | 13 +++++++------
 .../notify/import_source_user_reassign.html.haml    |  2 +-
 .../notify/import_source_user_reassign.text.erb     |  2 +-
 locale/gitlab.pot                                   |  4 ++--
 10 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/app/assets/javascripts/members/components/members_tabs.vue b/app/assets/javascripts/members/components/members_tabs.vue
index b0f3a5ffffcfb..83ac12424db37 100644
--- a/app/assets/javascripts/members/components/members_tabs.vue
+++ b/app/assets/javascripts/members/components/members_tabs.vue
@@ -96,6 +96,7 @@ export default {
       :key="tab.namespace"
       :title-link-attributes="tab.attrs"
       :query-param-value="tab.queryParamValue"
+      :lazy="tab.lazy"
     >
       <template #title>
         <span>{{ tab.title }}</span>
diff --git a/app/assets/javascripts/members/placeholders/components/app.vue b/app/assets/javascripts/members/placeholders/components/app.vue
index a2d2eb84e3cc5..d8ac1f4fcd04e 100644
--- a/app/assets/javascripts/members/placeholders/components/app.vue
+++ b/app/assets/javascripts/members/placeholders/components/app.vue
@@ -173,6 +173,7 @@ export default {
           :initial-filter-value="initialFilterValue"
           :tokens="filteredSearchTokens"
           :search-input-placeholder="s__('UserMapping|Search placeholder users')"
+          terms-as-tokens
           class="row-content-block gl-grow gl-border-t-0 sm:gl-flex"
           @onFilter="onFilter"
         />
@@ -196,6 +197,7 @@ export default {
           :initial-filter-value="initialFilterValue"
           :tokens="filteredSearchTokens"
           :search-input-placeholder="s__('UserMapping|Search placeholder users')"
+          terms-as-tokens
           class="row-content-block gl-grow gl-border-t-0 sm:gl-flex"
           @onFilter="onFilter"
         />
diff --git a/app/assets/javascripts/members/tabs_metadata.js b/app/assets/javascripts/members/tabs_metadata.js
index b6272b75178ab..83e646731a56b 100644
--- a/app/assets/javascripts/members/tabs_metadata.js
+++ b/app/assets/javascripts/members/tabs_metadata.js
@@ -31,5 +31,6 @@ export const TABS = [
     title: s__('UserMapping|Placeholders'),
     queryParamValue: TAB_QUERY_PARAM_VALUES.placeholder,
     component: PlaceholdersTabApp,
+    lazy: true,
   },
 ];
diff --git a/app/views/import/source_users/_accept_invite.html.haml b/app/views/import/source_users/_accept_invite.html.haml
index 48026f05ae2b9..2421ec85ceaae 100644
--- a/app/views/import/source_users/_accept_invite.html.haml
+++ b/app/views/import/source_users/_accept_invite.html.haml
@@ -7,5 +7,7 @@
     source_hostname: source_user.source_hostname,
     destination_group: source_user.namespace.name)
   - c.with_actions do
-    = render Pajamas::ButtonComponent.new(variant: :default, href: help_page_path('user/group/import/index'), button_options: { class: 'deferred-link gl-alert-action', rel: 'noreferrer noopener' }, target: '_blank') do
+    = render Pajamas::ButtonComponent.new(variant: :default,
+      href: help_page_path('user/project/import/index', anchor: 'accept-contribution-reassignment'),
+      button_options: { class: 'deferred-link gl-alert-action', rel: 'noreferrer noopener' }, target: '_blank') do
       = _('Learn more')
diff --git a/app/views/import/source_users/_cancel_invite.html.haml b/app/views/import/source_users/_cancel_invite.html.haml
index 40335551765d5..cd67b2f559d23 100644
--- a/app/views/import/source_users/_cancel_invite.html.haml
+++ b/app/views/import/source_users/_cancel_invite.html.haml
@@ -2,5 +2,7 @@
   - c.with_body do
     = s_('UserMapping|The reassignment has been cancelled by the group owner.')
   - c.with_actions do
-    = render Pajamas::ButtonComponent.new(variant: :default, href: help_page_path('user/group/import/index'), button_options: { class: 'deferred-link gl-alert-action', rel: 'noreferrer noopener' }, target: '_blank') do
+    = render Pajamas::ButtonComponent.new(variant: :default,
+      href: help_page_path('user/project/import/index', anchor: 'accept-contribution-reassignment'),
+      button_options: { class: 'deferred-link gl-alert-action', rel: 'noreferrer noopener' }, target: '_blank') do
       = _('Learn more')
diff --git a/app/views/import/source_users/_reject_invite.html.haml b/app/views/import/source_users/_reject_invite.html.haml
index 968c9760f2b9c..34eef3870327c 100644
--- a/app/views/import/source_users/_reject_invite.html.haml
+++ b/app/views/import/source_users/_reject_invite.html.haml
@@ -7,5 +7,7 @@
     source_hostname: source_user.source_hostname,
     destination_group: source_user.namespace.name)
   - c.with_actions do
-    = render Pajamas::ButtonComponent.new(variant: :default, href: help_page_path('user/group/import/index'), button_options: { class: 'deferred-link gl-alert-action', rel: 'noreferrer noopener' }, target: '_blank') do
+    = render Pajamas::ButtonComponent.new(variant: :default,
+      href: help_page_path('user/project/import/index', anchor: 'accept-contribution-reassignment'),
+      button_options: { class: 'deferred-link gl-alert-action', rel: 'noreferrer noopener' }, target: '_blank') do
       = _('Learn more')
diff --git a/app/views/import/source_users/show.html.haml b/app/views/import/source_users/show.html.haml
index 61bef8b99f1da..430466d1493fc 100644
--- a/app/views/import/source_users/show.html.haml
+++ b/app/views/import/source_users/show.html.haml
@@ -27,7 +27,7 @@
           source_hostname: source_hostname,
           destination_group: destination_group)
         = succeed '.' do
-          = link_to s_('UserMapping|Learn more about reassignments'), help_page_path('user/project/import/index', anchor: 'reassign-contributions-and-memberships')
+          = link_to s_('UserMapping|Learn more about reassignments'), help_page_path('user/project/import/index', anchor: 'accept-contribution-reassignment')
       %h5
         = s_('UserMapping|Import details:')
       %p.gl-mb-5
@@ -44,10 +44,11 @@
         = safe_format(s_('UserMapping|Reassigned by: %{reassigned_by_name} (%{reassigned_by_username})'), reassigned_by_name: reassigned_by_name, reassigned_by_username: reassigned_by_username)
       %p.gl-mb-0
         %strong
-          = s_('UserMapping|Accept reassignments only from users that you trust. Reassignment of contributions is permanent. Accepting these reassignments might cause contributions to be incorrectly attributed to you.')
+          = s_('UserMapping|Approve reassignments only from users that you trust. After approval, contributions will be assigned to you. The assignment is permanent.')
 
     - c.with_footer do
-      = render Pajamas::ButtonComponent.new(variant: :danger, method: :post, href: accept_import_source_user_path(@source_user)) do
-        = s_('UserMapping|Approve reassignment')
-      = render Pajamas::ButtonComponent.new(method: :post, href: decline_import_source_user_path(@source_user)) do
-        = s_('UserMapping|Reject')
+      .gl-flex.gl-gap-3
+        = render Pajamas::ButtonComponent.new(variant: :danger, method: :post, href: accept_import_source_user_path(@source_user)) do
+          = s_('UserMapping|Approve reassignment')
+        = render Pajamas::ButtonComponent.new(method: :post, href: decline_import_source_user_path(@source_user)) do
+          = s_('UserMapping|Reject')
diff --git a/app/views/notify/import_source_user_reassign.html.haml b/app/views/notify/import_source_user_reassign.html.haml
index c8307ffe340f4..7caab1ddf5349 100644
--- a/app/views/notify/import_source_user_reassign.html.haml
+++ b/app/views/notify/import_source_user_reassign.html.haml
@@ -14,7 +14,7 @@
 - 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)
-- help_link_tag_pair = tag_pair(link_to('', help_page_url('user/project/import/index', anchor: 'reassign-contributions-and-memberships'), target: '_blank', rel: 'noopener noreferrer'), :link_start, :link_end)
+- help_link_tag_pair = tag_pair(link_to('', help_page_url('user/project/import/index', anchor: 'accept-contribution-reassignment'), target: '_blank', rel: 'noopener noreferrer'), :link_start, :link_end)
 - report_link_tag_pair = tag_pair(link_to('', help_page_url('user/report_abuse'), target: '_blank', rel: 'noopener noreferrer'), :report_link_start, :report_link_end)
 
 %p{ style: text_style }
diff --git a/app/views/notify/import_source_user_reassign.text.erb b/app/views/notify/import_source_user_reassign.text.erb
index c9581c8dc9fb6..06b90a607716b 100644
--- a/app/views/notify/import_source_user_reassign.text.erb
+++ b/app/views/notify/import_source_user_reassign.text.erb
@@ -7,7 +7,7 @@
 <% reassigned_by_name = reassigned_by.name %>
 <% reassigned_by_username = "#{reassigned_by.to_reference} - #{user_url(reassigned_by)}" %>
 <% destination_group = "#{@source_user.namespace.name} (/#{@source_user.namespace.full_path})" %>
-<% help_link = help_page_url('user/group/import/index', anchor: 'memberships') %>
+<% help_link = help_page_url('user/project/import/index', anchor: 'accept-contribution-reassignment') %>
 <% report_link = help_page_url('user/report_abuse') %>
 <%= s_('UserMapping|%{reassigned_by_name} (%{reassigned_by_username}) wants to reassign contributions made by %{source_name} (%{source_username}) on %{source_hostname} to you in %{destination_group}.') % { reassigned_by_name: reassigned_by_name,
     reassigned_by_username: reassigned_by_username,
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 50877b4534ffc..3c71a630e32ba 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -58514,10 +58514,10 @@ msgstr ""
 msgid "UserMapping|%{reassigned_by_name} (%{reassigned_by_username}) wants to reassign contributions made by %{source_name} (%{source_username}) on %{source_hostname} to you in %{destination_group}."
 msgstr ""
 
-msgid "UserMapping|Accept reassignments only from users that you trust. Reassignment of contributions is permanent. Accepting these reassignments might cause contributions to be incorrectly attributed to you."
+msgid "UserMapping|Approve reassignment"
 msgstr ""
 
-msgid "UserMapping|Approve reassignment"
+msgid "UserMapping|Approve reassignments only from users that you trust. After approval, contributions will be assigned to you. The assignment is permanent."
 msgstr ""
 
 msgid "UserMapping|Awaiting reassignment"
-- 
GitLab