# 2023年11月 - refactoring Discovery routes: 私のテーマ/プラグインへの影響は？

**URL:** https://meta.discourse.org/t/november-2023-refactoring-discovery-routes-how-will-it-affect-my-theme-plugin/282816
**Category:** Development
**Tags:** dev-news
**Created:** [2023 年 10 月 19 日午後 5:25 UTC](https://meta.discourse.org/t/november-2023-refactoring-discovery-routes-how-will-it-affect-my-theme-plugin/282816 "2023-10-19T17:25:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2023 年 10 月 19 日午後 5:25 UTC](https://meta.discourse.org/t/november-2023-refactoring-discovery-routes-how-will-it-affect-my-theme-plugin/282816/1 "2023-10-19T17:25:58Z")

</div>

Discourse を Ember の最新バージョンにアップグレードするプロジェクトの一環として、Discovery (別名「トピックリスト」) ルートの大幅なリファクタリングに取り組んでいます。

このトピックは、テーマ/プラグイン開発者を対象としており、リファクタリングの影響を受ける可能性のあるテーマ/プラグインの活動の種類をリストアップすることを目的としています。

# 背景

このリファクタリングは、最新の Ember が `{{outlet \"topics\"}}` のような「名前付きアウトレット」をサポートしなくなったために必要となりました。これらのルートでは、名前付きアウトレットを広範囲に使用していました。基本的に、以前は名前付きアウトレットにレンダリングされていたすべてのコントローラー/テンプレートがコンポーネントに変換されました。

その過程で、関連コードのモダナイズと統合の機会を得ました (例: すべてのタイプのディスカバリルートが同じコントローラーとテンプレートを共有するようになりました)。

コアでの変更の実装はまだ完了していませんが、作業中のものは[このブランチ](https://github.com/discourse/discourse/pull/22622)で見つけることができます。マージの具体的な日付は未定ですが、数週間以内になると予想しています。ご質問や懸念事項があれば、お知らせください。

 

# どのテーマ/プラグイン活動が影響を受けますか？

このリファクタリングは、主に「コントローラー」レイヤーに影響します。ルートはほとんど変更されておらず、`\u003cTopicList /\u003e` コンポーネント以下のすべては影響を受けません。

影響は、コアコードに深くアクセスしている (例: `modifyClass` やテンプレートオーバーライド経由) テーマ/プラグインに限られると予想されます。定義済みの API とアウトレットは影響を受けません。

## テンプレートオーバーライド

🤫 これらのテンプレートはコンポーネントにリファクタリングされました。既存のオーバーライドはサイレントに機能しなくなります。

- `navigation/categories`
- `navigation/category`
- `navigation/default`
- `navigation/filter`
- `discovery/topics`

💥 これらのテンプレートは大幅にリファクタリングされました。既存のテンプレートオーバーライドは、サイトで壊滅的なエラーを引き起こす可能性が高いです。

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

技術的には、この変更によって導入された新しいテンプレートをオーバーライドすることは可能ですが、テンプレートオーバーライドは推奨されておらず、[廃止されつつあります](https://meta.discourse.org/t/overriding-discourse-templates-from-a-theme-or-plugin/247487)。

したがって、すべてのテンプレートオーバーライドは削除し、より堅牢な拡張 API (例: プラグインアウトレット) に置き換える必要があります。Discourse の既存の拡張ポイントでは実現できないと思われることがあれば、お知らせください。

## `modifyClass` および `lookup()` 呼び出し

🗑 これらのクラスはもはや存在しません。`modifyClass` はサイレントに機能しなくなります。ルックアップは null を返し、エラーにつながる可能性があります。最も一般的なケースでは、後方互換性のためにシムを導入しました (脚注を参照)。

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

🧑‍💻 これらのクラスは大幅にリファクタリングされました。`modifyClass` およびルックアップ呼び出しのリファクタリングが必要になる場合があります。

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

## ルート

🛣 ルート名 (つまり `router.currentRouteName`) は変更されていません。

📋 Discovery ルートの `model()` フック (つまり `router.currentRoute.attributes`) は、ほとんど変更されていません。

## プラグインアウトレット

🔌 すべてのプラグインアウトレットとその引数は変更されていません。

## HTML / CSS

🎨 HTML 構造とクラスは、ほとんど影響を受けていません。

* * *

1. 「モデル」プロパティへの読み取り専用アクセスは、非推奨通知付きでシムされています。 

2. 「カテゴリ」プロパティへの読み取り専用アクセスは、非推奨通知付きでシムされています。 

3. 「タグ」プロパティへの読み取り専用アクセスは、非推奨通知付きでシムされています。

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2023 年 10 月 30 日午前 11:50 UTC](https://meta.discourse.org/t/november-2023-refactoring-discovery-routes-how-will-it-affect-my-theme-plugin/282816/2 "2023-10-30T11:50:25Z")

</div>

今週、この変更のテストをホスティング全体に拡大し、来週初め（11月6日）に `main`/`tests-passed` にマージすることを目指します。

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2023 年 11 月 6 日午前 10:47 UTC](https://meta.discourse.org/t/november-2023-refactoring-discovery-routes-how-will-it-affect-my-theme-plugin/282816/3 "2023-11-06T10:47:34Z")

</div>

この変更は現在 `main`/`tests-passed` でライブになっています

> <https://github.com/discourse/discourse/commit/82d6d691eec9e97c88d67182bcbc583461e3e0dc>
>
> The motivation of this PR is to remove our dependence on Ember's 'named outlets'…, which are removed in Ember 4+.
> 
> At a high-level, the changes can be summarized as:
> 
> \- The top-level \`discovery\` route is totally emptied of all logic. The HTML structure of the template is moved into the \`\<Discovery::Layout /\>\` component for use by child routes.
> 
> \- \`AbstractTopicRoute\` and \`AbstractCategoryRoute\` routes now both lean on the \`DiscoverySortableController\` and associated template. This controller is where most of the logic from the old top-level \`discovery\` controller has ended up.
> 
> \- All navigation controllers/templates have been replaced with components. \`navigation/categories\`, \`navigation/category\` and \`navigation/default\` were very similar, and so they've all been combined into \`\<Navigation::Default\>\`. \`navigation/filter\` gets its own component.
> 
> \- The \`discovery/topics\` controller/template have been moved into a new \`\<Discovery::Topics\>\` component.
> 
> Various other parts of the app have been tweaked to support these changes, but I've tried to keep that to a minimum.
> 
> Anything from \`\<TopicList\>\` down is untouched, which should hopefully mean that a large proportion of topic-list-customizing themes are unaffected.
> 
> For more information, see https://meta.discourse.org/t/282816
