From 9919046c1c0450fb3422752ea3442199b90c4e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= <1108771+megothss@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:00:00 -0300 Subject: [PATCH] DEV: Improve discovery components plugin-outlets compatibility with existing customizations This commit changes some plugin outlets in ``, `` and `Discovery::Topics` to improve compatibility with existing customization, simplifying the migration process to the new discovery routes. In these components, the standard plugin outlets will receive by default at least the arguments: `category` and `tag`. Furthermore, two new wrapping plugin outlets were added to enable the conversion of existing template overrides to the new pattern: `discovery-list-area` and `topic-list-bottom`. The new template overrides will receive a `model` argument containing the full model handled by the route. --------- Co-authored-by: David Taylor --- .../app/components/discovery/layout.hbs | 50 ++++++++--- .../app/components/discovery/navigation.hbs | 4 +- .../app/components/discovery/topics.hbs | 88 +++++++++++-------- .../app/templates/discovery/categories.hbs | 2 +- .../app/templates/discovery/filter.hbs | 2 +- .../app/templates/discovery/list.hbs | 2 +- 6 files changed, 92 insertions(+), 56 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/discovery/layout.hbs b/app/assets/javascripts/discourse/app/components/discovery/layout.hbs index ab8d10777a4..d48ab8294c8 100644 --- a/app/assets/javascripts/discourse/app/components/discovery/layout.hbs +++ b/app/assets/javascripts/discourse/app/components/discovery/layout.hbs @@ -1,28 +1,37 @@
- {{#if @category}} + {{#if @model.category}} {{/if}}
- +
{{yield to="navigation"}}
- +
@@ -31,26 +40,43 @@ {{yield to="header"}}
- +
- {{yield to="list"}} + @name="discovery-list-area" + @outletArgs={{hash + category=@model.category + tag=@model.tag + model=@model + }} + @defaultGlimmer={{true}} + > + + {{yield to="list"}} +
- + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/discovery/navigation.hbs b/app/assets/javascripts/discourse/app/components/discovery/navigation.hbs index b85fe2e9a9b..9535ebd0390 100644 --- a/app/assets/javascripts/discourse/app/components/discovery/navigation.hbs +++ b/app/assets/javascripts/discourse/app/components/discovery/navigation.hbs @@ -3,7 +3,7 @@ {{#if @category}}
@@ -18,7 +18,7 @@
diff --git a/app/assets/javascripts/discourse/app/components/discovery/topics.hbs b/app/assets/javascripts/discourse/app/components/discovery/topics.hbs index 4144978714d..4b73aab621e 100644 --- a/app/assets/javascripts/discourse/app/components/discovery/topics.hbs +++ b/app/assets/javascripts/discourse/app/components/discovery/topics.hbs @@ -114,46 +114,56 @@
{{#if this.allLoaded}} - - - - {{#if @tag}} - {{html-safe - (i18n "topic.browse_all_tags_or_latest" basePath=(base-path)) - }} - {{else if this.latest}} - {{#if @category.canCreateTopic}} - + + + + {{#if @tag}} + {{html-safe + (i18n "topic.browse_all_tags_or_latest" basePath=(base-path)) + }} + {{else if this.latest}} + {{#if @category.canCreateTopic}} + + {{/if}} + {{else if this.top}} + {{html-safe + (i18n + "topic.browse_all_categories_latest_or_top" basePath=(base-path) + ) + }} + + {{else}} + {{html-safe + (i18n "topic.browse_all_categories_latest" basePath=(base-path)) + }} {{/if}} - {{else if this.top}} - {{html-safe - (i18n - "topic.browse_all_categories_latest_or_top" basePath=(base-path) - ) - }} - - {{else}} - {{html-safe - (i18n "topic.browse_all_categories_latest" basePath=(base-path)) - }} - {{/if}} - + + {{/if}}
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/discovery/categories.hbs b/app/assets/javascripts/discourse/app/templates/discovery/categories.hbs index 5104e9c4cd6..bc77a36ffc2 100644 --- a/app/assets/javascripts/discourse/app/templates/discovery/categories.hbs +++ b/app/assets/javascripts/discourse/app/templates/discovery/categories.hbs @@ -1,4 +1,4 @@ - + <:navigation> + <:navigation> <:navigation>