mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 05:08:36 +08:00
NavTree: Make it possible to configure where in nav tree plugins live (#55484)
* NewIA: Plugin nav config * progress * Progress * Things are working * Add monitoring node * Add alerts and incidents * added experiment with standalone page * Refactoring by adding a type for navtree root * First test working * More tests * more tests * Progress on richer config and sorting * Sort weight working * Path config * Improving logic for not including admin or cfg nodes, making it the last step so that enterprise can add admin nodes without having to worry about the section not existing * fixed index routes * removed file * Fixes * Fixing tests * Fixing more tests and adding support for weight config * Updates * Remove unused fake * More fixes * Minor tweak * Minor fix * Can now control position using sortweight even when existing items have no sortweight * Added tests for frontend standalone page logic * more tests * Remove unused fake and fixed lint issue * Moving reading settings to navtree impl package * remove nav_id setting prefix * Remove old test file * Fix trailing newline * Fixed bug with adding nil node * fixing lint issue * remove some code we have to rethink * move read settings to PrivideService and switch to util.SplitString
This commit is contained in:
@ -39,7 +39,9 @@ export function AppRootPage({ match, queryParams, location }: Props) {
|
||||
const portalNode = useMemo(() => createHtmlPortalNode(), []);
|
||||
const { plugin, loading, pluginNav } = state;
|
||||
const sectionNav = useSelector(
|
||||
createSelector(getNavIndex, (navIndex) => buildPluginSectionNav(location, pluginNav, navIndex))
|
||||
createSelector(getNavIndex, (navIndex) =>
|
||||
buildPluginSectionNav(location, pluginNav, navIndex, match.params.pluginId)
|
||||
)
|
||||
);
|
||||
const context = useMemo(() => buildPluginPageContext(sectionNav), [sectionNav]);
|
||||
|
||||
@ -53,12 +55,12 @@ export function AppRootPage({ match, queryParams, location }: Props) {
|
||||
);
|
||||
|
||||
if (!plugin || match.params.pluginId !== plugin.meta.id) {
|
||||
return <Page {...getLoadingPageProps()}>{loading && <PageLoader />}</Page>;
|
||||
return <Page {...getLoadingPageProps(sectionNav)}>{loading && <PageLoader />}</Page>;
|
||||
}
|
||||
|
||||
if (!plugin.root) {
|
||||
return (
|
||||
<Page navModel={getWarningNav('Plugin load error')}>
|
||||
<Page navModel={sectionNav ?? getWarningNav('Plugin load error')}>
|
||||
<div>No root app page component found</div>;
|
||||
</Page>
|
||||
);
|
||||
@ -120,9 +122,9 @@ const stateSlice = createSlice({
|
||||
},
|
||||
});
|
||||
|
||||
function getLoadingPageProps(): Partial<PageProps> {
|
||||
if (config.featureToggles.topnav) {
|
||||
return { navId: 'apps' };
|
||||
function getLoadingPageProps(sectionNav: NavModel | null): Partial<PageProps> {
|
||||
if (config.featureToggles.topnav && sectionNav) {
|
||||
return { navModel: sectionNav };
|
||||
}
|
||||
|
||||
const loading = { text: 'Loading plugin' };
|
||||
|
Reference in New Issue
Block a user