From 35ecd0335c70e4f008ae86ec5804dc60dbf41101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 6 Dec 2024 15:43:03 +0100 Subject: [PATCH] UX: only show automatic group tooltip to admins (#30155) Follow up to #28630 which added the tooltip on automatic group. It was missing a check to ensure the current user is an admin, since only admins can manage automatic groups. Reported in https://meta.discourse.org/t/324215 by @moin-Jana --- .../discourse/app/templates/group.hbs | 2 +- .../acceptance/group-manage-membership-test.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/templates/group.hbs b/app/assets/javascripts/discourse/app/templates/group.hbs index da39f6abb57..b988499c80c 100644 --- a/app/assets/javascripts/discourse/app/templates/group.hbs +++ b/app/assets/javascripts/discourse/app/templates/group.hbs @@ -41,7 +41,7 @@ {{/if}} - {{#if this.model.automatic}} + {{#if (and this.currentUser.admin this.model.automatic)}} <:trigger> {{d-icon "gear"}} diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js index f6c9abb88fe..4cffab3f43b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js @@ -24,6 +24,24 @@ acceptance("Managing Group Membership", function (needs) { ); }); + test("As an admin on an automatic group", async function (assert) { + await visit("/g/moderators"); + + assert + .dom(".admin-group-automatic-tooltip") + .exists("displays automatic tooltip"); + }); + + test("As a non-admin user on an automatic group", async function (assert) { + updateCurrentUser({ admin: false }); + + await visit("/g/moderators"); + + assert + .dom(".admin-group-automatic-tooltip") + .doesNotExist("does not display automatic tooltip"); + }); + test("As an admin", async function (assert) { updateCurrentUser({ can_create_group: true });