mirror of
https://github.com/discourse/discourse.git
synced 2025-03-05 18:05:24 +08:00

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.
94 lines
2.7 KiB
Plaintext
94 lines
2.7 KiB
Plaintext
import Component from "@glimmer/component";
|
|
import { hash } from "@ember/helper";
|
|
import { service } from "@ember/service";
|
|
import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item";
|
|
import NavItem from "discourse/components/nav-item";
|
|
import PluginOutlet from "discourse/components/plugin-outlet";
|
|
import i18n from "discourse-common/helpers/i18n";
|
|
import AdminPageHeader from "./admin-page-header";
|
|
import AdminPluginConfigArea from "./admin-plugin-config-area";
|
|
|
|
export default class AdminPluginConfigPage extends Component {
|
|
@service currentUser;
|
|
@service adminPluginNavManager;
|
|
|
|
get mainAreaClasses() {
|
|
let classes = ["admin-plugin-config-page__main-area"];
|
|
|
|
if (this.adminPluginNavManager.isSidebarMode) {
|
|
classes.push("-with-inner-sidebar");
|
|
} else {
|
|
classes.push("-without-inner-sidebar");
|
|
}
|
|
|
|
return classes.join(" ");
|
|
}
|
|
|
|
get actionsOutletName() {
|
|
return `admin-plugin-config-page-actions-${this.args.plugin.kebabCaseName}`;
|
|
}
|
|
|
|
linkText(navLink) {
|
|
if (navLink.label) {
|
|
return i18n(navLink.label);
|
|
} else {
|
|
return navLink.text;
|
|
}
|
|
}
|
|
|
|
<template>
|
|
<div class="admin-plugin-config-page">
|
|
<AdminPageHeader
|
|
@titleLabelTranslated={{@plugin.nameTitleized}}
|
|
@descriptionLabelTranslated={{@plugin.about}}
|
|
@learnMoreUrl={{@plugin.linkUrl}}
|
|
>
|
|
<:breadcrumbs>
|
|
|
|
<DBreadcrumbsItem
|
|
@path="/admin/plugins"
|
|
@label={{i18n "admin.plugins.title"}}
|
|
/>
|
|
<DBreadcrumbsItem
|
|
@path="/admin/plugins/{{@plugin.name}}"
|
|
@label={{@plugin.nameTitleized}}
|
|
/>
|
|
</:breadcrumbs>
|
|
<:tabs>
|
|
{{#if this.adminPluginNavManager.isTopMode}}
|
|
{{#each
|
|
this.adminPluginNavManager.currentConfigNav.links
|
|
as |navLink|
|
|
}}
|
|
<NavItem
|
|
@route={{navLink.route}}
|
|
@i18nLabel={{this.linkText navLink}}
|
|
title={{this.linkText navLink}}
|
|
class="admin-plugin-config-page__top-nav-item"
|
|
>
|
|
{{this.linkText navLink}}
|
|
</NavItem>
|
|
{{/each}}
|
|
{{/if}}
|
|
</:tabs>
|
|
<:actions as |actions|>
|
|
<div class={{this.actionsOutletName}}>
|
|
<PluginOutlet
|
|
@name={{this.actionsOutletName}}
|
|
@outletArgs={{hash plugin=@plugin actions=actions}}
|
|
/>
|
|
</div>
|
|
</:actions>
|
|
</AdminPageHeader>
|
|
|
|
<div class="admin-plugin-config-page__content">
|
|
<div class={{this.mainAreaClasses}}>
|
|
<AdminPluginConfigArea>
|
|
{{yield}}
|
|
</AdminPluginConfigArea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
}
|