FIX: Unscoped plugin config page actions outlet (#29026)

In 61c1d35f17 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.
This commit is contained in:
Martin Brennan 2024-09-30 14:35:23 +10:00 committed by GitHub
parent f6df0f8789
commit 73f42e110a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 5 deletions

View File

@ -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}}
</:tabs>
<:actions as |actions|>
<PluginOutlet
@name="admin-plugin-config-page-actions"
@outletArgs={{hash plugin=@plugin actions=actions}}
/>
<div class={{this.actionsOutletName}}>
<PluginOutlet
@name={{this.actionsOutletName}}
@outletArgs={{hash plugin=@plugin actions=actions}}
/>
</div>
</:actions>
</AdminPageHeader>

View File

@ -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:`

View File

@ -20,7 +20,7 @@ export default {
]);
api.renderInOutlet(
"admin-plugin-config-page-actions",
"admin-plugin-config-page-actions-chat",
ChatAdminPluginActions
);
});