DEV: Remove use of deprecated prop from user preferences templates (#20403)

The `redesigned_user_page_nav_enabled` property has been deprecated and will be dropped from Discourse core soon.
This commit is contained in:
Alan Guo Xiang Tan 2023-02-22 13:23:56 +08:00 committed by GitHub
parent a3712781e1
commit 2fc2d7d828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 113 additions and 217 deletions

View File

@ -1,95 +0,0 @@
<DNavigationItem
@route="preferences.account"
@class="user-nav__preferences-account"
@ariaCurrentContext={{@ariaCurrentContext}}
>
{{d-icon "user"}}
<span>{{i18n "user.preferences_nav.account"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.security"
@class="user-nav__preferences-security"
@ariaCurrentContext={{@ariaCurrentContext}}
>
{{d-icon "lock"}}
<span>{{i18n "user.preferences_nav.security"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.profile"
@class="user-nav__preferences-profile"
@ariaCurrentContext={{@ariaCurrentContext}}
>
{{d-icon "user"}}
<span>{{i18n "user.preferences_nav.profile"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.emails"
@class="user-nav__preferences-emails"
@ariaCurrentContext={{@ariaCurrentContext}}
>
{{d-icon "envelope"}}
<span>{{i18n "user.preferences_nav.emails"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.notifications"
@class="user-nav__preferences-notifications"
@ariaCurrentContext={{@ariaCurrentContext}}
>
{{d-icon "bell"}}
<span>{{i18n "user.preferences_nav.notifications"}}</span>
</DNavigationItem>
{{#if @model.can_change_tracking_preferences}}
<DNavigationItem
@route="preferences.tracking"
@class="user-nav__preferences-tracking"
@ariaCurrentContext={{@ariaCurrentContext}}
>
{{d-icon "plus"}}
<span>{{i18n "user.preferences_nav.tracking"}}</span>
</DNavigationItem>
{{/if}}
<DNavigationItem
@route="preferences.users"
@class="user-nav__preferences-users"
@ariaCurrentContext={{@ariaCurrentContext}}
>
{{d-icon "users"}}
<span>{{i18n "user.preferences_nav.users"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.interface"
@class="user-nav__preferences-interface"
@ariaCurrentContext={{@ariaCurrentContext}}
>
{{d-icon "desktop"}}
<span>{{i18n "user.preferences_nav.interface"}}</span>
</DNavigationItem>
{{#if (not (eq @siteSettings.navigation_menu "legacy"))}}
<DNavigationItem
@route="preferences.sidebar"
@class="user-nav__preferences-sidebar"
@ariaCurrentContext={{@ariaCurrentContext}}
>
{{d-icon "bars"}}
<span>{{i18n "user.preferences_nav.sidebar"}}</span>
</DNavigationItem>
{{/if}}
<PluginOutlet
@name="user-preferences-nav-under-interface"
@connectorTagName="div"
@outletArgs={{hash model=@model}}
/>
<PluginOutlet
@name="user-preferences-nav"
@connectorTagName="li"
@outletArgs={{hash model=@model}}
/>

View File

@ -1,110 +1,104 @@
{{#if this.currentUser.redesigned_user_page_nav_enabled}}
<DSection @pageClass="user-preferences" />
<div class="user-navigation user-navigation-secondary">
<HorizontalOverflowNav @ariaLabel="User secondary - preferences">
<UserNav::PreferencesNav
@currentUser={{this.currentUser}}
@model={{this.model}}
@siteSettings={{this.siteSettings}}
<DNavigationItem
@route="preferences.account"
@class="user-nav__preferences-account"
@ariaCurrentContext="subNav"
/>
</HorizontalOverflowNav>
</div>
{{else}}
<DSection @pageClass="user-preferences" @class="user-secondary-navigation">
<MobileNav
@class="preferences-nav"
@desktopClass="preferences-list action-list nav-stacked"
>
<li class="nav-account">
<LinkTo @route="preferences.account">
{{i18n "user.preferences_nav.account"}}
</LinkTo>
</li>
<li class="nav-security">
<LinkTo @route="preferences.security">
{{i18n "user.preferences_nav.security"}}
</LinkTo>
</li>
<li class="nav-profile">
<LinkTo @route="preferences.profile">
{{i18n "user.preferences_nav.profile"}}
</LinkTo>
</li>
<li class="nav-emails">
<LinkTo @route="preferences.emails">
{{i18n "user.preferences_nav.emails"}}
</LinkTo>
</li>
<li class="nav-notifications">
<LinkTo @route="preferences.notifications">
{{i18n "user.preferences_nav.notifications"}}
</LinkTo>
</li>
{{d-icon "user"}}
<span>{{i18n "user.preferences_nav.account"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.security"
@class="user-nav__preferences-security"
@ariaCurrentContext="subNav"
>
{{d-icon "lock"}}
<span>{{i18n "user.preferences_nav.security"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.profile"
@class="user-nav__preferences-profile"
@ariaCurrentContext="subNav"
>
{{d-icon "user"}}
<span>{{i18n "user.preferences_nav.profile"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.emails"
@class="user-nav__preferences-emails"
@ariaCurrentContext="subNav"
>
{{d-icon "envelope"}}
<span>{{i18n "user.preferences_nav.emails"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.notifications"
@class="user-nav__preferences-notifications"
@ariaCurrentContext="subNav"
>
{{d-icon "bell"}}
<span>{{i18n "user.preferences_nav.notifications"}}</span>
</DNavigationItem>
{{#if this.model.can_change_tracking_preferences}}
<li class="indent nav-categories">
<LinkTo @route="preferences.categories">
{{i18n "user.preferences_nav.categories"}}
</LinkTo>
</li>
<DNavigationItem
@route="preferences.tracking"
@class="user-nav__preferences-tracking"
@ariaCurrentContext="subNav"
>
{{d-icon "plus"}}
<span>{{i18n "user.preferences_nav.tracking"}}</span>
</DNavigationItem>
{{/if}}
<li class="indent nav-users">
<LinkTo @route="preferences.users">
{{i18n "user.preferences_nav.users"}}
</LinkTo>
</li>
{{#if
(and
this.model.can_change_tracking_preferences
this.siteSettings.tagging_enabled
)
}}
<li class="indent nav-tags">
<LinkTo @route="preferences.tags">
{{i18n "user.preferences_nav.tags"}}
</LinkTo>
</li>
{{/if}}
<li class="nav-interface">
<LinkTo @route="preferences.interface">
{{i18n "user.preferences_nav.interface"}}
</LinkTo>
</li>
<DNavigationItem
@route="preferences.users"
@class="user-nav__preferences-users"
@ariaCurrentContext="subNav"
>
{{d-icon "users"}}
<span>{{i18n "user.preferences_nav.users"}}</span>
</DNavigationItem>
<DNavigationItem
@route="preferences.interface"
@class="user-nav__preferences-interface"
@ariaCurrentContext="subNav"
>
{{d-icon "desktop"}}
<span>{{i18n "user.preferences_nav.interface"}}</span>
</DNavigationItem>
{{#if (not (eq this.siteSettings.navigation_menu "legacy"))}}
<li class="indent nav-sidebar">
<LinkTo @route="preferences.sidebar">
{{i18n "user.preferences_nav.sidebar"}}
</LinkTo>
</li>
<DNavigationItem
@route="preferences.sidebar"
@class="user-nav__preferences-sidebar"
@ariaCurrentContext="subNav"
>
{{d-icon "bars"}}
<span>{{i18n "user.preferences_nav.sidebar"}}</span>
</DNavigationItem>
{{/if}}
<span>
<PluginOutlet
@name="user-preferences-nav-under-interface"
@connectorTagName="div"
@outletArgs={{hash model=this.model}}
/>
</span>
{{#if this.model.userApiKeys}}
<li class="nav-apps">
<LinkTo @route="preferences.apps">
{{i18n "user.preferences_nav.apps"}}
</LinkTo>
</li>
{{/if}}
<span>
<PluginOutlet
@name="user-preferences-nav"
@connectorTagName="li"
@outletArgs={{hash model=this.model}}
/>
</span>
</MobileNav>
</DSection>
{{/if}}
</HorizontalOverflowNav>
</div>
<section class="user-content user-preferences" id="user-content">
<span>

View File

@ -100,9 +100,7 @@
</div>
{{/if}}
{{#if this.currentUser.redesigned_user_page_nav_enabled}}
<UserPreferences::UserApiKeys @model={{@model}} />
{{/if}}
<span>
<PluginOutlet

View File

@ -44,6 +44,7 @@ acceptance("User Preferences", function (needs) {
document.body.classList.contains("user-preferences-page"),
"has the body class"
);
assert.strictEqual(
currentURL(),
"/u/eviltrout/preferences/account",
@ -62,15 +63,15 @@ acceptance("User Preferences", function (needs) {
await fillIn(".pref-name input[type=text]", "Jon Snow");
await savePreferences();
await click(".preferences-nav .nav-profile a");
await click(".user-nav__preferences-profile a");
await fillIn("#edit-location", "Westeros");
await savePreferences();
await click(".preferences-nav .nav-emails a");
await click(".user-nav__preferences-emails a");
await click(".pref-activity-summary input[type=checkbox]");
await savePreferences();
await click(".preferences-nav .nav-notifications a");
await click(".user-nav__preferences-notifications a");
await selectKit(
".control-group.notifications .combo-box.duration"
@ -82,7 +83,7 @@ acceptance("User Preferences", function (needs) {
await savePreferences();
await click(".preferences-nav .nav-categories a");
await click(".user-nav__preferences-tracking a");
const categorySelector = selectKit(
".tracking-controls .category-selector "
@ -90,26 +91,25 @@ acceptance("User Preferences", function (needs) {
await categorySelector.expand();
await categorySelector.fillInFilter("faq");
const tagSelector = selectKit(".tracking-controls .tag-chooser");
await tagSelector.expand();
await tagSelector.fillInFilter("monkey");
await savePreferences();
this.siteSettings.tagging_enabled = false;
await visit("/");
await visit("/u/eviltrout/preferences");
await visit("/u/eviltrout/preferences/tracking");
assert.ok(
!exists(".preferences-nav .nav-tags a"),
"tags tab isn't there when tags are disabled"
assert.notOk(
exists(".tag-notifications"),
"updating tags tracking preferences isn't visible when tags are disabled"
);
await click(".preferences-nav .nav-interface a");
await click(".user-nav__preferences-interface a");
await click(".control-group.other input[type=checkbox]:nth-of-type(1)");
await savePreferences();
assert.ok(
!exists(".preferences-nav .nav-apps a"),
"apps tab isn't there when you have no authorized apps"
);
});
});

View File

@ -64,9 +64,8 @@ acceptance("User Preferences - Security", function (needs) {
);
});
test("Viewing user api keys when user has redesign user page navigation enabled", async function (assert) {
test("Viewing user api keys", async function (assert) {
updateCurrentUser({
redesigned_user_page_nav_enabled: true,
user_api_keys: [
{
id: 1,