discourse/app/assets/javascripts/admin/addon/routes/admin-revamp.js
Martin Brennan 3cc73cfd1e
FIX: Always preload admin plugin list for admin in sidebar (#25606)
When we show the links to installed plugins in the admin
sidebar (for plugins that have custom admin routes) we were
previously only doing this if you opened /admin, not if you
navigated there from the main forum. We should just always
preload this data if the user is admin.

This commit also changes `admin_sidebar_enabled_groups` to
not be sent to the client as part of ongoing efforts to
not check groups on the client, since not all a user's groups
may be serialized.
2024-02-09 12:52:22 +10:00

37 lines
990 B
JavaScript

import { inject as service } from "@ember/service";
import { ADMIN_PANEL, MAIN_PANEL } from "discourse/lib/sidebar/panels";
import DiscourseURL from "discourse/lib/url";
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "discourse-i18n";
export default class AdminRoute extends DiscourseRoute {
@service siteSettings;
@service currentUser;
@service sidebarState;
titleToken() {
return I18n.t("admin_title");
}
activate() {
if (!this.currentUser.use_admin_sidebar) {
return DiscourseURL.redirectTo("/admin");
}
this.sidebarState.setPanel(ADMIN_PANEL);
this.sidebarState.setSeparatedMode();
this.sidebarState.hideSwitchPanelButtons();
this.controllerFor("application").setProperties({
showTop: false,
});
}
deactivate(transition) {
this.controllerFor("application").set("showTop", true);
if (!transition?.to.name.startsWith("admin")) {
this.sidebarState.setPanel(MAIN_PANEL);
}
}
}