mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-23 06:30:50 +08:00
Old no sidebar admin panel is deprecated and admin sidebar is not experimental anymore. Therefore, old setting should be deleted.
63 lines
1.6 KiB
JavaScript
Vendored
63 lines
1.6 KiB
JavaScript
Vendored
import { tracked } from "@glimmer/tracking";
|
|
import { service } from "@ember/service";
|
|
import KeyboardShortcuts, {
|
|
PLATFORM_KEY_MODIFIER,
|
|
} from "discourse/lib/keyboard-shortcuts";
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
import { i18n } from "discourse-i18n";
|
|
import AdminSearchModal from "admin/components/modal/admin-search";
|
|
|
|
export default class AdminRoute extends DiscourseRoute {
|
|
@service sidebarState;
|
|
@service siteSettings;
|
|
@service store;
|
|
@service currentUser;
|
|
@service adminSidebarStateManager;
|
|
@service modal;
|
|
|
|
@tracked initialSidebarState;
|
|
|
|
titleToken() {
|
|
return i18n("admin_title");
|
|
}
|
|
|
|
activate() {
|
|
if (this.currentUser.use_experimental_admin_search) {
|
|
KeyboardShortcuts.addShortcut(
|
|
`${PLATFORM_KEY_MODIFIER}+/`,
|
|
(event) => this.showAdminSearchModal(event),
|
|
{
|
|
global: true,
|
|
}
|
|
);
|
|
}
|
|
|
|
this.adminSidebarStateManager.maybeForceAdminSidebar({
|
|
onlyIfAlreadyActive: false,
|
|
});
|
|
|
|
this.controllerFor("application").setProperties({
|
|
showTop: false,
|
|
});
|
|
}
|
|
|
|
deactivate(transition) {
|
|
this.controllerFor("application").set("showTop", true);
|
|
|
|
if (this.currentUser.use_experimental_admin_search) {
|
|
KeyboardShortcuts.unbind({
|
|
[`${PLATFORM_KEY_MODIFIER}+/`]: this.showAdminSearchModal,
|
|
});
|
|
}
|
|
|
|
if (!transition?.to.name.startsWith("admin")) {
|
|
this.adminSidebarStateManager.stopForcingAdminSidebar();
|
|
}
|
|
}
|
|
|
|
showAdminSearchModal(event) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
this.modal.show(AdminSearchModal);
|
|
}
|
|
}
|