DEV: uses private API for currentPath (#7911)

* DEV: uses with private API for currentPath

router.currentRouteName as a slightly different API and application.currentPath is deprecated

* another fix
This commit is contained in:
Joffrey JAFFEUX 2019-07-18 23:00:39 +02:00 committed by Robin Ward
parent e8a14a3a65
commit 8dfd0e0374
12 changed files with 19 additions and 20 deletions

View File

@ -13,7 +13,7 @@ export default Ember.Controller.extend({
return this.currentUser.get("admin") && enableBadges;
},
@computed("router.currentRouteName")
@computed("router._router.currentPath")
adminContentsClassName(currentPath) {
let cssClasses = currentPath
.split(".")
@ -22,16 +22,15 @@ export default Ember.Controller.extend({
segment !== "index" &&
segment !== "loading" &&
segment !== "show" &&
segment !== "admin" &&
segment !== "dashboard"
segment !== "admin"
);
})
.map(Ember.String.dasherize)
.join(" ");
// this is done to avoid breaking css customizations
if (currentPath.indexOf("admin.dashboard") > -1) {
cssClasses = `${cssClasses} dashboard dashboard-next`;
if (cssClasses.includes("dashboard")) {
cssClasses = `${cssClasses} dashboard-next`;
}
return cssClasses;

View File

@ -9,7 +9,7 @@ export default Ember.Controller.extend({
pmView: false,
viewingSelf: Ember.computed.alias("user.viewingSelf"),
isGroup: Ember.computed.equal("pmView", "groups"),
currentPath: Ember.computed.alias("router.currentRouteName"),
currentPath: Ember.computed.alias("router._router.currentPath"),
selected: Ember.computed.alias("userTopicsList.selected"),
bulkSelectEnabled: Ember.computed.alias("userTopicsList.bulkSelectEnabled"),
showToggleBulkSelect: true,

View File

@ -7,7 +7,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
indexStream: false,
router: Ember.inject.service(),
userNotifications: Ember.inject.controller("user-notifications"),
currentPath: Ember.computed.alias("router.currentRouteName"),
currentPath: Ember.computed.alias("router._router.currentPath"),
adminTools: optionalService(),
@computed("model.username")

View File

@ -56,7 +56,7 @@
<div class="user-content-wrapper">
<section class="user-primary-navigation">
<div class="container">
{{group-navigation group=model currentPath=router.currentRouteName tabs=tabs}}
{{group-navigation group=model currentPath=router._router.currentPath tabs=tabs}}
</div>
</section>

View File

@ -1,5 +1,5 @@
<section class="user-secondary-navigation">
{{#mobile-nav class='activity-nav' desktopClass='action-list activity-list nav-stacked' currentPath=router.currentRouteName}}
{{#mobile-nav class='activity-nav' desktopClass='action-list activity-list nav-stacked' currentPath=router._router.currentPath}}
{{group-activity-filter filter="posts" categoryId=category_id}}
{{group-activity-filter filter="topics" categoryId=category_id}}
{{#if siteSettings.enable_mentions}}

View File

@ -1,5 +1,5 @@
<section class='user-secondary-navigation'>
{{#mobile-nav class='activity-nav' desktopClass='action-list activity-list nav-stacked' currentPath=router.currentRouteName}}
{{#mobile-nav class='activity-nav' desktopClass='action-list activity-list nav-stacked' currentPath=router._router.currentPath}}
{{#each tabs as |tab|}}
<li>
{{#link-to tab.route model.name}}

View File

@ -1,5 +1,5 @@
<section class="user-secondary-navigation">
{{#mobile-nav class='messages-nav' desktopClass='nav-stacked action-list' currentPath=router.currentRouteName}}
{{#mobile-nav class='messages-nav' desktopClass='nav-stacked action-list' currentPath=router._router.currentPath}}
<li>
{{#link-to 'group.messages.inbox' model.name}}

View File

@ -1,5 +1,5 @@
{{#d-section pageClass="user-preferences" class="user-secondary-navigation"}}
{{#mobile-nav class='preferences-nav' desktopClass='preferences-list action-list nav-stacked' currentPath=router.currentRouteName}}
{{#mobile-nav class='preferences-nav' desktopClass='preferences-list action-list nav-stacked' currentPath=router._router.currentPath}}
<li class='nav-account'>
{{#link-to 'preferences.account'}}
{{i18n 'user.preferences_nav.account'}}

View File

@ -3,14 +3,14 @@
{{/if}}
{{user-card-contents
currentPath=router.currentRouteName
currentPath=router._router.currentPath
topic=topic.model
showUser=(action "showUser")
togglePosts=(action "togglePosts")
createNewMessageViaParams=(route-action "createNewMessageViaParams")}}
{{group-card-contents
currentPath=router.currentRouteName
currentPath=router._router.currentPath
topic=topic.model
showUser=(action "showUser")
showGroup=(action "showGroup")

View File

@ -1,5 +1,5 @@
{{#d-section pageClass="user-activity" class="user-secondary-navigation" scrollTop="false"}}
{{#mobile-nav class='activity-nav' desktopClass='action-list activity-list nav-stacked' currentPath=router.currentRouteName}}
{{#mobile-nav class='activity-nav' desktopClass='action-list activity-list nav-stacked' currentPath=router._router.currentPath}}
<li>
{{#link-to 'userActivity.index'}}{{i18n 'user.filters.all'}}{{/link-to}}
</li>

View File

@ -1,5 +1,5 @@
{{#d-section pageClass="user-notifications" class="user-secondary-navigation"}}
{{#mobile-nav class='notifications-nav' desktopClass='notification-list action-list nav-stacked' currentPath=router.currentRouteName}}
{{#mobile-nav class='notifications-nav' desktopClass='notification-list action-list nav-stacked' currentPath=router._router.currentPath}}
<li>
{{#link-to 'userNotifications.index'}}
{{i18n 'user.filters.all'}}

View File

@ -403,8 +403,8 @@ export default createWidget("header", {
}
const currentPath = this.register
.lookup("controller:application")
.get("currentPath");
.lookup("service:router")
.get("router._router.currentPath");
if (currentPath === "full-page-search") {
scrollTop();
@ -479,8 +479,8 @@ export default createWidget("header", {
state.contextEnabled = false;
const currentPath = this.register
.lookup("controller:application")
.get("currentPath");
.lookup("service:router")
.get("router._router.currentPath");
const blacklist = [/^discovery\.categories/];
const whitelist = [/^topic\./];
const check = function(regex) {