DEV: Remove use of redesigned_user_page_nav_enabled prop client side (#20387)

Since 359dc1c532, support for the old user
profile navigation menu has been dropped. This commit seeks to remove
code from the client side that still relies on the `currentUser.redesigned_user_page_nav_enabled` prop.
This commit is contained in:
Alan Guo Xiang Tan 2023-02-21 14:09:48 +08:00 committed by GitHub
parent c1486790d6
commit 452539bf5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 80 deletions

View File

@ -194,11 +194,8 @@ export default Controller.extend(CanCheckEmails, {
if (!this.currentUser?.staff) { if (!this.currentUser?.staff) {
return false; return false;
} }
if (this.currentUser?.redesigned_user_page_nav_enabled) {
return this.site.desktopView; return this.site.desktopView;
} else {
return true;
}
}, },
@action @action

View File

@ -431,81 +431,22 @@
</div> </div>
</section> </section>
{{#if this.currentUser.redesigned_user_page_nav_enabled}} <div class="new-user-wrapper">
<div class="new-user-wrapper"> <UserNav
<UserNav @user={{this.model}}
@user={{this.model}} @showNotificationsTab={{this.showNotificationsTab}}
@showNotificationsTab={{this.showNotificationsTab}} @showPrivateMessages={{this.showPrivateMessages}}
@showPrivateMessages={{this.showPrivateMessages}} @canInviteToForum={{this.canInviteToForum}}
@canInviteToForum={{this.canInviteToForum}} @showBadges={{this.showBadges}}
@showBadges={{this.showBadges}} @currentParentRoute={{this.currentParentRoute}}
@currentParentRoute={{this.currentParentRoute}} @showRead={{this.showRead}}
@showRead={{this.showRead}} @showDrafts={{this.showDrafts}}
@showDrafts={{this.showDrafts}} @showBookmarks={{this.showBookmarks}}
@showBookmarks={{this.showBookmarks}} />
/>
<div class="new-user-content-wrapper">
{{outlet}}
</div>
</div>
{{else}}
<div class="user-content-wrapper">
<section class="user-primary-navigation">
<MobileNav @class="main-nav" @desktopClass="nav nav-pills user-nav">
{{#unless this.model.profile_hidden}}
<li class="summary"><LinkTo @route="user.summary">{{i18n
"user.summary.title"
}}</LinkTo></li>
<li class="activity"><LinkTo @route="userActivity">{{i18n
"user.activity_stream"
}}</LinkTo></li>
{{/unless}}
{{#if this.showNotificationsTab}}
<li class="user-notifications">
<LinkTo @route="userNotifications">
{{d-icon "bell" class="glyph"}}{{i18n "user.notifications"}}
</LinkTo>
</li>
{{/if}}
{{#if this.showPrivateMessages}}
<li class="private-messages"><LinkTo
@route="userPrivateMessages"
>{{d-icon "envelope"}}{{i18n
"user.private_messages"
}}</LinkTo></li>
{{/if}}
{{#if this.canInviteToForum}}
<li class="invited"><LinkTo @route="userInvited">{{d-icon
"user-plus"
}}{{i18n "user.invited.title"}}</LinkTo></li>
{{/if}}
{{#if this.showBadges}}
<li class="badges"><LinkTo @route="user.badges">{{d-icon
"certificate"
}}{{i18n "badges.title"}}</LinkTo></li>
{{/if}}
<PluginOutlet
@name="user-main-nav"
@connectorTagName="li"
@outletArgs={{hash model=this.model}}
/>
{{#if this.model.can_edit}}
<li class="preferences"><LinkTo @route="preferences">{{d-icon
"cog"
}}{{i18n "user.preferences"}}</LinkTo></li>
{{/if}}
</MobileNav>
</section>
<div class="new-user-content-wrapper">
{{outlet}} {{outlet}}
</div> </div>
{{/if}} </div>
</DSection> </DSection>
</div> </div>

View File

@ -24,6 +24,7 @@ acceptance("User Routes", function (needs) {
helper.response(400, {}) helper.response(400, {})
); );
}); });
test("Invalid usernames", async function (assert) { test("Invalid usernames", async function (assert) {
try { try {
await visit("/u/eviltrout%2F..%2F..%2F/summary"); await visit("/u/eviltrout%2F..%2F..%2F/summary");
@ -52,6 +53,7 @@ acceptance("User Routes", function (needs) {
test("Notifications", async function (assert) { test("Notifications", async function (assert) {
await visit("/u/eviltrout/notifications"); await visit("/u/eviltrout/notifications");
assert.ok( assert.ok(
document.body.classList.contains("user-notifications-page"), document.body.classList.contains("user-notifications-page"),
"has the body class" "has the body class"
@ -66,16 +68,20 @@ acceptance("User Routes", function (needs) {
); );
updateCurrentUser({ moderator: true, admin: false }); updateCurrentUser({ moderator: true, admin: false });
await visit("/u/charlie/summary"); await visit("/u/charlie/summary");
assert.notOk( assert.notOk(
exists(".user-nav > .user-notifications"), exists(".user-nav > .user-nav__notifications"),
"does not have the notifications tab" "does not have the notifications tab"
); );
updateCurrentUser({ moderator: false, admin: true }); updateCurrentUser({ moderator: false, admin: true });
await visit("/u/charlie/summary"); await visit("/u/charlie/summary");
assert.ok( assert.ok(
exists(".user-nav > .user-notifications"), exists(".user-nav > .user-nav__notifications"),
"has the notifications tab" "has the notifications tab"
); );
}); });