From b9ab0acf29c766ad2f76dafd0d2c99b8e9f7f2b0 Mon Sep 17 00:00:00 2001
From: Imre Farkas <ifarkas@gitlab.com>
Date: Fri, 12 Jul 2024 16:19:53 +0200
Subject: [PATCH] Refactor the require PAT expiry app setting view

---
 .../_account_and_limit.html.haml                     |  6 +-----
 .../_require_personal_access_token_expiry.html.haml  |  6 ++++++
 locale/gitlab.pot                                    | 12 ++++++------
 3 files changed, 13 insertions(+), 11 deletions(-)
 create mode 100644 app/views/admin/application_settings/_require_personal_access_token_expiry.html.haml

diff --git a/app/views/admin/application_settings/_account_and_limit.html.haml b/app/views/admin/application_settings/_account_and_limit.html.haml
index 33137daa3c4ca..c30ea2403be7a 100644
--- a/app/views/admin/application_settings/_account_and_limit.html.haml
+++ b/app/views/admin/application_settings/_account_and_limit.html.haml
@@ -29,11 +29,7 @@
       = f.gitlab_ui_checkbox_component :remember_me_enabled, _('Allow users to extend their session'), help_text: _("Users can select 'Remember me' on sign-in to keep their session active beyond the session duration. %{link_start}Learn more%{link_end}.").html_safe % { link_start: remember_me_help_link_start, link_end: '</a>'.html_safe }
 
     = render_if_exists 'admin/application_settings/git_two_factor_session_expiry', form: f
-    %h5
-      = _('Personal/project/group access token expiration')
-    .form-group
-      = f.gitlab_ui_checkbox_component :require_personal_access_token_expiry, _('Require expiration date'),
-        help_text: _('When enabled, a user will be required to enter in an expiration date when creating an access token. Changes will not affect existing token expiration dates.')
+    = render 'admin/application_settings/require_personal_access_token_expiry', form: f
     = render_if_exists 'admin/application_settings/personal_access_token_expiration_policy', form: f
     = render_if_exists 'admin/application_settings/service_access_tokens_expiration_enforced', form: f
     = render_if_exists 'admin/application_settings/ssh_key_expiration_policy', form: f
diff --git a/app/views/admin/application_settings/_require_personal_access_token_expiry.html.haml b/app/views/admin/application_settings/_require_personal_access_token_expiry.html.haml
new file mode 100644
index 0000000000000..8670ec78d209a
--- /dev/null
+++ b/app/views/admin/application_settings/_require_personal_access_token_expiry.html.haml
@@ -0,0 +1,6 @@
+- link = link_to('', help_page_path('user/profile/personal_access_tokens', anchor: 'create-a-service-account-personal-access-token-with-no-expiry-date'), target: '_blank', rel: 'noopener noreferrer')
+- help_text = safe_format(s_('AccessTokens|When enabled, a user will be required to enter in an expiration date when creating an access token. Changes will not affect existing token expiration dates. This setting overrides the group-level %{link_start}service account token expiration%{link_end} setting.'), tag_pair(link, :link_start, :link_end))
+
+.form-group
+  = form.label :require_personal_access_token_expiry, s_('AccessTokens|Personal / project / group access token expiration'), class: 'label-light'
+  = form.gitlab_ui_checkbox_component :require_personal_access_token_expiry, _('Require expiration date'), help_text: help_text
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 797d041a30cb7..3559f045c2b37 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -2761,6 +2761,9 @@ msgstr ""
 msgid "AccessTokens|Keep this token secret. Anyone who has it can read activity and issue RSS feeds or your calendar feed as if they were you. If that happens, %{linkStart}reset this token%{linkEnd}."
 msgstr ""
 
+msgid "AccessTokens|Personal / project / group access token expiration"
+msgstr ""
+
 msgid "AccessTokens|Personal Access Tokens"
 msgstr ""
 
@@ -2785,6 +2788,9 @@ msgstr ""
 msgid "AccessTokens|Token name"
 msgstr ""
 
+msgid "AccessTokens|When enabled, a user will be required to enter in an expiration date when creating an access token. Changes will not affect existing token expiration dates. This setting overrides the group-level %{link_start}service account token expiration%{link_end} setting."
+msgstr ""
+
 msgid "AccessTokens|You can also use personal access tokens to authenticate against Git over HTTP."
 msgstr ""
 
@@ -38378,9 +38384,6 @@ msgstr ""
 msgid "Personal projects limit:"
 msgstr ""
 
-msgid "Personal/project/group access token expiration"
-msgstr ""
-
 msgid "PersonalProject|Learn to move a project to a group"
 msgstr ""
 
@@ -59814,9 +59817,6 @@ msgstr ""
 msgid "When enabled, SSH keys with no expiry date or an invalid expiration date are no longer accepted. Leave blank for no limit."
 msgstr ""
 
-msgid "When enabled, a user will be required to enter in an expiration date when creating an access token. Changes will not affect existing token expiration dates."
-msgstr ""
-
 msgid "When enabled, cleanup policies execute faster but put more load on Redis."
 msgstr ""
 
-- 
GitLab