Skip to content

A platform for community discussion. Free, open, simple.

FIX: ensure user admin button is present on mobile (#21366)

Kris856755a38348
diff --git a/app/assets/javascripts/discourse/app/components/user-nav.hbs b/app/assets/javascripts/discourse/app/components/user-nav.hbs
index 465a67b98e9..c894eef5847 100644
--- a/app/assets/javascripts/discourse/app/components/user-nav.hbs
+++ b/app/assets/javascripts/discourse/app/components/user-nav.hbs
@@ -76,8 +76,7 @@
<span>{{i18n "user.preferences"}}</span>
</DNavigationItem>
{{/if}}
-
- {{#if (and this.site.mobileView this.currentUser.staff)}}
+ {{#if (and @isMobileView @isStaff)}}
<li class="user-nav__admin">
<a href={{@user.adminPath}}>
{{d-icon "wrench"}}
diff --git a/app/assets/javascripts/discourse/app/templates/user.hbs b/app/assets/javascripts/discourse/app/templates/user.hbs
index 056929c85f5..5f00d3a9707 100644
--- a/app/assets/javascripts/discourse/app/templates/user.hbs
+++ b/app/assets/javascripts/discourse/app/templates/user.hbs
@@ -319,7 +319,7 @@
{{#if this.displayTopLevelAdminButton}}
<li><a
href={{this.model.adminPath}}
- class="btn btn-default"
+ class="btn btn-default user-admin"
>{{d-icon "wrench"}}<span class="d-button-label">{{i18n
"admin.user.show_admin_profile"
}}</span></a></li>
@@ -452,6 +452,8 @@
<div class="new-user-wrapper">
<UserNav
@user={{this.model}}
+ @isStaff={{this.currentUser.staff}}
+ @isMobileView={{this.site.mobileView}}
@showNotificationsTab={{this.showNotificationsTab}}
@showPrivateMessages={{this.showPrivateMessages}}
@canInviteToForum={{this.canInviteToForum}}
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-admin-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-admin-test.js
new file mode 100644
index 00000000000..2f873673d23
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-admin-test.js
@@ -0,0 +1,25 @@
+import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
+import { test } from "qunit";
+import { visit } from "@ember/test-helpers";
+
+acceptance("User Preferences Admin", function (needs) {
+ needs.user({ admin: true });
+
+ test("Desktop user admin button", async function (assert) {
+ await visit("/u/eviltrout");
+ assert.ok(exists(".user-admin"), "desktop user admin nav button exists");
+ });
+});
+
+acceptance("User Preferences Admin - Mobile", function (needs) {
+ needs.user({ admin: true });
+ needs.mobileView();
+
+ test("Mobile user admin button", async function (assert) {
+ await visit("/u/eviltrout");
+ assert.ok(
+ exists(".user-nav__admin"),
+ "mobile user admin nav button exists"
+ );
+ });
+});