DEV: Move admin sidebar out of initializer (#25396)

Having the admin sidebar code in an instance initializer is not
ideal because:

* It runs during app boot which may not even be necessary based on site settings
* It makes it hard for plugins to register additional links in time without resorting
to before/after initializer gymnastics

This PR moves the admin sidebar into a lib and creates the panel
in custom-sections.js, then the sections and links are loaded when
the main sidebar component is rendered, which leaves plugins enough
time to add additional links in an initializer.

---------

Co-authored-by: David Taylor <david@taylorhq.com>
This commit is contained in:
Martin Brennan
2024-01-25 10:45:14 +10:00
committed by GitHub
parent 6ad34a0152
commit 57ededb770
11 changed files with 83 additions and 116 deletions

View File

@ -1,4 +1,4 @@
import { ADMIN_PANEL, MAIN_PANEL } from "discourse/services/sidebar-state";
import { ADMIN_PANEL, MAIN_PANEL } from "discourse/lib/sidebar/panels";
import { getUserChatSeparateSidebarMode } from "discourse/plugins/chat/discourse/lib/get-user-chat-separate-sidebar-mode";
export const CHAT_PANEL = "chat";

View File

@ -2,9 +2,9 @@ import { tracked } from "@glimmer/tracking";
import Service, { inject as service } from "@ember/service";
import KeyValueStore from "discourse/lib/key-value-store";
import { withPluginApi } from "discourse/lib/plugin-api";
import { MAIN_PANEL } from "discourse/lib/sidebar/panels";
import { defaultHomepage } from "discourse/lib/utilities";
import Site from "discourse/models/site";
import { MAIN_PANEL } from "discourse/services/sidebar-state";
import getURL from "discourse-common/lib/get-url";
import { getUserChatSeparateSidebarMode } from "discourse/plugins/chat/discourse/lib/get-user-chat-separate-sidebar-mode";