mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 10:24:49 +08:00
70f7c0ee6f
This commit changes the API for registering the plugin config page nav configuration from a server-side to a JS one; there is no need for it to be server-side. It also makes some changes to allow for 2 different ways of displaying navigation for plugin pages, depending on complexity: * TOP - This is the best mode for simple plugins without a lot of different custom configuration pages, and it reuses the grey horizontal nav bar already used for admins. * SIDEBAR - This is better for more complex plugins; likely this won't be used in the near future, but it's readily available if needed There is a new AdminPluginConfigNavManager service too to manage which plugin the admin is actively viewing, otherwise we would have trouble hiding the main plugin nav for admins when viewing a single plugin.
49 lines
1.3 KiB
Plaintext
49 lines
1.3 KiB
Plaintext
import Component from "@glimmer/component";
|
|
import { LinkTo } from "@ember/routing";
|
|
import { inject as service } from "@ember/service";
|
|
import concatClass from "discourse/helpers/concat-class";
|
|
import I18n from "discourse-i18n";
|
|
|
|
export default class AdminPluginConfigArea extends Component {
|
|
@service adminPluginNavManager;
|
|
|
|
linkText(navLink) {
|
|
if (navLink.label) {
|
|
return I18n.t(navLink.label);
|
|
} else {
|
|
return navLink.text;
|
|
}
|
|
}
|
|
|
|
<template>
|
|
{{#if this.adminPluginNavManager.isSidebarMode}}
|
|
<nav class="admin-nav admin-plugin-inner-sidebar-nav pull-left">
|
|
<ul class="nav nav-stacked">
|
|
{{#each
|
|
this.adminPluginNavManager.currentConfigNav.links
|
|
as |navLink|
|
|
}}
|
|
<li
|
|
class={{concatClass
|
|
"admin-plugin-inner-sidebar-nav__item"
|
|
navLink.route
|
|
}}
|
|
>
|
|
<LinkTo
|
|
@route={{navLink.route}}
|
|
@model={{navLink.model}}
|
|
title={{this.linkText navLink}}
|
|
>
|
|
{{this.linkText navLink}}
|
|
</LinkTo>
|
|
</li>
|
|
{{/each}}
|
|
</ul>
|
|
</nav>
|
|
{{/if}}
|
|
<section class="admin-plugin-config-area">
|
|
{{yield}}
|
|
</section>
|
|
</template>
|
|
}
|