From 73f42e110af3eaf5dc453c11bf27145e406270c0 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Mon, 30 Sep 2024 14:35:23 +1000 Subject: [PATCH] FIX: Unscoped plugin config page actions outlet (#29026) In 61c1d35f17468b3666c966839da911d9f96dad19 I added a PluginOutlet to AdminPluginConfigPage. This was intended to be used as a way to render actions buttons inside the header of a plugin that has a custom admin UI page. This worked, but since the outlet was generically named, as soon as one plugin used it the button would show on all plugins. This fixes the immediate issue by naming the outlet based on the plugin, then having each plugin specify their own outlet to render into. There may be a nicer way to do this, but for now this stops the bleeding. --- .../addon/components/admin-plugin-config-page.gjs | 14 ++++++++++---- .../javascripts/admin/addon/models/admin-plugin.js | 4 ++++ .../chat-admin-plugin-configuration-nav.js | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/admin/addon/components/admin-plugin-config-page.gjs b/app/assets/javascripts/admin/addon/components/admin-plugin-config-page.gjs index 262101958d5..17f9b477587 100644 --- a/app/assets/javascripts/admin/addon/components/admin-plugin-config-page.gjs +++ b/app/assets/javascripts/admin/addon/components/admin-plugin-config-page.gjs @@ -24,6 +24,10 @@ export default class AdminPluginConfigPage extends Component { return classes.join(" "); } + get actionsOutletName() { + return `admin-plugin-config-page-actions-${this.args.plugin.kebabCaseName}`; + } + linkText(navLink) { if (navLink.label) { return i18n(navLink.label); @@ -68,10 +72,12 @@ export default class AdminPluginConfigPage extends Component { {{/if}} <:actions as |actions|> - +
+ +
diff --git a/app/assets/javascripts/admin/addon/models/admin-plugin.js b/app/assets/javascripts/admin/addon/models/admin-plugin.js index 33730888da8..02d940d9470 100644 --- a/app/assets/javascripts/admin/addon/models/admin-plugin.js +++ b/app/assets/javascripts/admin/addon/models/admin-plugin.js @@ -24,6 +24,10 @@ export default class AdminPlugin { return this.name.replaceAll("-", "_"); } + get kebabCaseName() { + return this.name.replaceAll(" ", "-").replaceAll("_", "-"); + } + get translatedCategoryName() { // We do this because the site setting list is grouped by category, // with plugins that have their root site setting key defined as `plugins:` diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-admin-plugin-configuration-nav.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-admin-plugin-configuration-nav.js index 68df5e41c61..2fbc231a7c7 100644 --- a/plugins/chat/assets/javascripts/discourse/initializers/chat-admin-plugin-configuration-nav.js +++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-admin-plugin-configuration-nav.js @@ -20,7 +20,7 @@ export default { ]); api.renderInOutlet( - "admin-plugin-config-page-actions", + "admin-plugin-config-page-actions-chat", ChatAdminPluginActions ); });