From ee050e5063213eda195ffd4f9331e700bf1cbbf9 Mon Sep 17 00:00:00 2001 From: janzenisaac <50783505+janzenisaac@users.noreply.github.com> Date: Mon, 14 Feb 2022 11:25:41 -0600 Subject: [PATCH] DEV: Make user card non-clickable for anon users: (#15938) Make name / avatar non-clickable for anon users --- app/assets/javascripts/discourse/app/widgets/post.js | 4 +++- app/assets/javascripts/discourse/app/widgets/poster-name.js | 6 ++++++ app/assets/stylesheets/common/foundation/helpers.scss | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/widgets/post.js b/app/assets/javascripts/discourse/app/widgets/post.js index ca41e8eabed..a32d87d7309 100644 --- a/app/assets/javascripts/discourse/app/widgets/post.js +++ b/app/assets/javascripts/discourse/app/widgets/post.js @@ -173,6 +173,8 @@ createWidget("post-avatar", { html(attrs) { let body; + let hideFromAnonUser = + this.siteSettings.hide_user_profiles_from_public && !this.currentUser; if (!attrs.user_id) { body = iconNode("far-trash-alt", { class: "deleted-user-avatar" }); } else { @@ -181,7 +183,7 @@ createWidget("post-avatar", { username: attrs.username, name: attrs.name, url: attrs.usernameUrl, - className: "main-avatar", + className: `main-avatar ${hideFromAnonUser ? "non-clickable" : ""}`, hideTitle: true, }); } diff --git a/app/assets/javascripts/discourse/app/widgets/poster-name.js b/app/assets/javascripts/discourse/app/widgets/poster-name.js index 441fda53fdf..2308b77155a 100644 --- a/app/assets/javascripts/discourse/app/widgets/poster-name.js +++ b/app/assets/javascripts/discourse/app/widgets/poster-name.js @@ -58,6 +58,12 @@ export default createWidget("poster-name", { attributes: { href: attrs.usernameUrl, "data-user-card": attrs.username, + class: `${ + this.siteSettings.hide_user_profiles_from_public && + !this.currentUser + ? "non-clickable" + : "" + }`, }, }, formatUsername(text) diff --git a/app/assets/stylesheets/common/foundation/helpers.scss b/app/assets/stylesheets/common/foundation/helpers.scss index e06dda77a0b..2fc2324e27c 100644 --- a/app/assets/stylesheets/common/foundation/helpers.scss +++ b/app/assets/stylesheets/common/foundation/helpers.scss @@ -76,3 +76,7 @@ .clickable { cursor: pointer; } + +.non-clickable { + cursor: default; +}