November 2023 - refactoring Discovery routes: how will it affect my theme/plugin?

As part of our project to upgrade Discourse to the latest version of Ember, we’ve been working on a significant refactoring of the Discovery (a.k.a. the ‘topic list’) routes.

This topic is targeted at theme/plugin developers, and aims to list the kinds of theme/plugin activities which may be affected by the refactoring.

Background

This refactoring is necessary because modern Ember no longer supports ‘named outlets’ like {{outlet "topics"}}, which we were using extensively on these routes. Essentially, all the controllers/templates which were previously rendered into named outlets have been converted into Components.

Along the way, we’ve taken the opportunity to modernize and consolidate the relevant code (e.g. all types of discovery route now share the same controller and template)

The implementation of the change in core isn’t finalised yet, but a work-in-progress can be found on this branch. We don’t have a specific date for merging, but we expect it to be within the next few weeks. If you have any questions or concerns, please let us know!

Which theme/plugin activities are affected?

This refactoring predominantly affects the ‘controller’ layer. Routes are largely unchanged, and everything from the <TopicList /> component downwards is also unaffected.

We expect the only impact will to themes/plugins which are reaching deep into core code (e.g. via modifyClass and template overrides). Defined APIs and outlets are unaffected.

Template Overrides

:shushing_face: These templates have been refactored into components. Any existing overrides will stop working silently

  • navigation/categories
  • navigation/category
  • navigation/default
  • navigation/filter
  • discovery/topics

:boom: These templates have been heavily refactored. Any existing template overrides are likely to cause catastophic errors on the site.

  • discovery
  • tag/show
  • user-topics-list
  • user/messages
  • discovery/categories
  • components/basic-topic-list
  • components/d-navigation

Technically, it is possible to override the new templates introduced by this change. However, template overrides are not recommended and are on the way out.

Therefore, all template overrides should be removed and replaced with more robust extension APIs (e.g. plugin outlets). If there’s anything you’re doing which doesn’t seem possible with Discourse’s existing extension points, please let us know!

modifyClass and lookup() calls

:wastebasket: These classes no longer exist. modifyClass will stop working silently. Lookups will return null (and therefore might lead to errors). In the most popular cases, we have introduced shims for backwards-compatibility (see footnotes)

  • controller:discovery
  • controller:discovery/topics[1]
  • controller:discovery-sortable ( → controller:discovery/list)
  • controller:discovery-filter ( → controller:discovery/filter)
  • controller:navigation/categories
  • controller:navigation/category [2]
  • controller:navigation/default
  • controller:tag/show [3]
  • controller:discovery.* ( → controller:discovery/list)

:technologist: These classes have undergone significant refactoring. modifyClass and lookup calls may require refactoring:

  • route/discovery
  • route/discovery.*
  • route/tag-show

Routes

:motorway: Route names (i.e. router.currentRouteName) are unchanged

:clipboard: Discovery route model() hooks (i.e. router.currentRoute.attributes) are mostly unchanged

Plugin Outlets

:electric_plug: All plugin outlets and their arguments are unchanged.

HTML / CSS

:art: HTML structure and classes are largely unaffected


  1. Read-only access to the ‘model’ property has been shimmed with a deprecation notice ↩︎

  2. Read-only access to the ‘category’ property has been shimmed with a deprecation notice ↩︎

  3. Read-only access to the ‘tag’ property has been shimmed with a deprecation notice ↩︎

16 Likes

We’ll be expanding testing of this change across our hosting this week, with the aim of merging into main/tests-passed early next week (6th November).

6 Likes

This change is now live in main/tests-passed

3 Likes