DEV: uses private API for currentPath (#7911)

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
diff --git a/app/assets/javascripts/admin/controllers/admin.js.es6 b/app/assets/javascripts/admin/controllers/admin.js.es6
index 2bca382..a79cf81 100644
--- a/app/assets/javascripts/admin/controllers/admin.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin.js.es6
@@ -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;
diff --git a/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 b/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6
index 9a9cba1..0d08726 100644
--- a/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6
+++ b/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6
@@ -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,
diff --git a/app/assets/javascripts/discourse/controllers/user.js.es6 b/app/assets/javascripts/discourse/controllers/user.js.es6
index 661be19..5045cf5 100644
--- a/app/assets/javascripts/discourse/controllers/user.js.es6
+++ b/app/assets/javascripts/discourse/controllers/user.js.es6
@@ -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")
diff --git a/app/assets/javascripts/discourse/templates/group.hbs b/app/assets/javascripts/discourse/templates/group.hbs
index 7e88c92..6a7d2e0 100644
--- a/app/assets/javascripts/discourse/templates/group.hbs
+++ b/app/assets/javascripts/discourse/templates/group.hbs
@@ -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>
 
diff --git a/app/assets/javascripts/discourse/templates/group/activity.hbs b/app/assets/javascripts/discourse/templates/group/activity.hbs
index b6ca303..24c06e2 100644
--- a/app/assets/javascripts/discourse/templates/group/activity.hbs
+++ b/app/assets/javascripts/discourse/templates/group/activity.hbs
@@ -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}}
diff --git a/app/assets/javascripts/discourse/templates/group/manage.hbs b/app/assets/javascripts/discourse/templates/group/manage.hbs
index ff43273..5ee0f85 100644
--- a/app/assets/javascripts/discourse/templates/group/manage.hbs
+++ b/app/assets/javascripts/discourse/templates/group/manage.hbs
@@ -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}}
diff --git a/app/assets/javascripts/discourse/templates/group/messages.hbs b/app/assets/javascripts/discourse/templates/group/messages.hbs
index b567f2d..1d3edaa 100644
--- a/app/assets/javascripts/discourse/templates/group/messages.hbs
+++ b/app/assets/javascripts/discourse/templates/group/messages.hbs
@@ -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}}
diff --git a/app/assets/javascripts/discourse/templates/preferences.hbs b/app/assets/javascripts/discourse/templates/preferences.hbs
index 4a78a98..3abd833 100644
--- a/app/assets/javascripts/discourse/templates/preferences.hbs
+++ b/app/assets/javascripts/discourse/templates/preferences.hbs
@@ -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'}}
diff --git a/app/assets/javascripts/discourse/templates/user-card.hbs b/app/assets/javascripts/discourse/templates/user-card.hbs
index 3c23451..d06bb8a 100644
--- a/app/assets/javascripts/discourse/templates/user-card.hbs
+++ b/app/assets/javascripts/discourse/templates/user-card.hbs
@@ -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")
diff --git a/app/assets/javascripts/discourse/templates/user/activity.hbs b/app/assets/javascripts/discourse/templates/user/activity.hbs
index 2b1ea95..6c39cc4 100644
--- a/app/assets/javascripts/discourse/templates/user/activity.hbs
+++ b/app/assets/javascripts/discourse/templates/user/activity.hbs
@@ -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>
diff --git a/app/assets/javascripts/discourse/templates/user/notifications.hbs b/app/assets/javascripts/discourse/templates/user/notifications.hbs
index c968b42..fa74e92 100644

[... diff too long, it was truncated ...]

GitHub sha: 8dfd0e03

1 Like