From 8dfd0e0374c7e97f14fcb644f2b760bdf65d57be Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 18 Jul 2019 23:00:39 +0200 Subject: [PATCH] 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 --- app/assets/javascripts/admin/controllers/admin.js.es6 | 9 ++++----- .../discourse/controllers/user-private-messages.js.es6 | 2 +- app/assets/javascripts/discourse/controllers/user.js.es6 | 2 +- app/assets/javascripts/discourse/templates/group.hbs | 2 +- .../javascripts/discourse/templates/group/activity.hbs | 2 +- .../javascripts/discourse/templates/group/manage.hbs | 2 +- .../javascripts/discourse/templates/group/messages.hbs | 2 +- .../javascripts/discourse/templates/preferences.hbs | 2 +- app/assets/javascripts/discourse/templates/user-card.hbs | 4 ++-- .../javascripts/discourse/templates/user/activity.hbs | 2 +- .../discourse/templates/user/notifications.hbs | 2 +- app/assets/javascripts/discourse/widgets/header.js.es6 | 8 ++++---- 12 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin.js.es6 b/app/assets/javascripts/admin/controllers/admin.js.es6 index 2bca382439..a79cf81944 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 9a9cba115b..0d087261a1 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 661be19aaf..5045cf55c4 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 7e88c925e4..6a7d2e0b14 100644 --- a/app/assets/javascripts/discourse/templates/group.hbs +++ b/app/assets/javascripts/discourse/templates/group.hbs @@ -56,7 +56,7 @@
- {{group-navigation group=model currentPath=router.currentRouteName tabs=tabs}} + {{group-navigation group=model currentPath=router._router.currentPath tabs=tabs}}
diff --git a/app/assets/javascripts/discourse/templates/group/activity.hbs b/app/assets/javascripts/discourse/templates/group/activity.hbs index b6ca30345e..24c06e20c9 100644 --- a/app/assets/javascripts/discourse/templates/group/activity.hbs +++ b/app/assets/javascripts/discourse/templates/group/activity.hbs @@ -1,5 +1,5 @@
- {{#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 ff43273d40..5ee0f8591f 100644 --- a/app/assets/javascripts/discourse/templates/group/manage.hbs +++ b/app/assets/javascripts/discourse/templates/group/manage.hbs @@ -1,5 +1,5 @@
- {{#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|}}
  • {{#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 b567f2d031..1d3edaa440 100644 --- a/app/assets/javascripts/discourse/templates/group/messages.hbs +++ b/app/assets/javascripts/discourse/templates/group/messages.hbs @@ -1,5 +1,5 @@
    - {{#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}}
  • {{#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 4a78a98f90..3abd833348 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}}
  • {{#link-to 'userActivity.index'}}{{i18n 'user.filters.all'}}{{/link-to}}
  • diff --git a/app/assets/javascripts/discourse/templates/user/notifications.hbs b/app/assets/javascripts/discourse/templates/user/notifications.hbs index c968b42f9d..fa74e925d3 100644 --- a/app/assets/javascripts/discourse/templates/user/notifications.hbs +++ b/app/assets/javascripts/discourse/templates/user/notifications.hbs @@ -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}}
  • {{#link-to 'userNotifications.index'}} {{i18n 'user.filters.all'}} diff --git a/app/assets/javascripts/discourse/widgets/header.js.es6 b/app/assets/javascripts/discourse/widgets/header.js.es6 index b48b302bbc..3db96d0803 100644 --- a/app/assets/javascripts/discourse/widgets/header.js.es6 +++ b/app/assets/javascripts/discourse/widgets/header.js.es6 @@ -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) {