From ff90c87c878b03e7beabac5f19396e0db2c25a1e Mon Sep 17 00:00:00 2001
From: "Panagiotis \"Ivory\" Vasilopoulos" <git@n0toose.net>
Date: Thu, 22 Jun 2023 08:58:16 +0000
Subject: [PATCH] Improve 'Privacy' section in profile settings (#25309)

- Improve "Hide the activity from the profile page" label
- E-Mail privacy icon in user profile now redirects to Privacy section
- E-Mail privacy settings moved to Privacy section

Previously, the user was redirected to the setting itself, however,
that is not a good design choice because the setting itself would
be at the very top of the user's browser window. This fix doesn't
fix the problem entirely, but it is definitely an improvement
compared to its previous iteration.
---
 options/locale/locale_en-US.ini      |  2 +-
 templates/user/profile.tmpl          |  2 +-
 templates/user/settings/profile.tmpl | 15 ++++++++-------
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 70802fc4ca..7845b1d521 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -662,7 +662,7 @@ comment_type_group_project = Project
 comment_type_group_issue_ref = Issue reference
 saved_successfully = Your settings were saved successfully.
 privacy = Privacy
-keep_activity_private = Hide the activity from the profile page
+keep_activity_private = Hide Activity from profile page
 keep_activity_private_popup = Makes the activity visible only for you and the admins
 
 lookup_avatar_by_mail = Look Up Avatar by Email Address
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl
index 51d4a46a92..7c37de2bc9 100644
--- a/templates/user/profile.tmpl
+++ b/templates/user/profile.tmpl
@@ -35,7 +35,7 @@
 								<li>
 									{{svg "octicon-mail"}}
 									<a href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
-									<a href="{{AppSubUrl}}/user/settings#keep-email-private">
+									<a href="{{AppSubUrl}}/user/settings#privacy-user-settings">
 										{{if .ShowUserEmail}}
 											<i class="ui right" data-tooltip-content="{{.locale.Tr "user.email_visibility.limited"}}">
 												{{svg "octicon-unlock"}}
diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl
index 350f8a0275..385a2ea205 100644
--- a/templates/user/settings/profile.tmpl
+++ b/templates/user/settings/profile.tmpl
@@ -25,12 +25,6 @@
 					<label for="email">{{.locale.Tr "email"}}</label>
 					<p>{{.SignedUser.Email}}</p>
 				</div>
-				<div class="inline field">
-					<div class="ui checkbox" id="keep-email-private">
-						<label data-tooltip-content="{{.locale.Tr "settings.keep_email_private_popup"}}"><strong>{{.locale.Tr "settings.keep_email_private"}}</strong></label>
-						<input name="keep_email_private" type="checkbox" {{if .SignedUser.KeepEmailPrivate}}checked{{end}}>
-					</div>
-				</div>
 				<div class="field {{if .Err_Description}}error{{end}}">
 					<label for="description">{{$.locale.Tr "user.user_bio"}}</label>
 					<textarea id="description" name="description" rows="2" placeholder="{{.locale.Tr "settings.biography_placeholder"}}" maxlength="255">{{.SignedUser.Description}}</textarea>
@@ -47,7 +41,7 @@
 				<div class="ui divider"></div>
 				<!-- private block -->
 
-				<div class="field">
+				<div class="field" id="privacy-user-settings">
 					<label for="security-private"><strong>{{.locale.Tr "settings.privacy"}}</strong></label>
 				</div>
 
@@ -77,6 +71,13 @@
 					</div>
 				</div>
 
+				<div class="field">
+					<div class="ui checkbox">
+						<label data-tooltip-content="{{.locale.Tr "settings.keep_email_private_popup"}}"><strong>{{.locale.Tr "settings.keep_email_private"}}</strong></label>
+						<input name="keep_email_private" type="checkbox" {{if .SignedUser.KeepEmailPrivate}}checked{{end}}>
+					</div>
+				</div>
+
 				<div class="field">
 					<div class="ui checkbox" id="keep-activity-private">
 						<label data-tooltip-content="{{.locale.Tr "settings.keep_activity_private_popup"}}"><strong>{{.locale.Tr "settings.keep_activity_private"}}</strong></label>