grafana/public/app/features/plugins/components/PluginPageContext.tsx
Torkel Ödegaard b4f73c9f09
PluginPages: Support plugin pages that don't belong to a section (#55904)
* Fixing pages that don't exist in navtree

* Fix test

* fix lint warning

* Fixes
2022-09-29 13:27:51 +02:00

27 lines
649 B
TypeScript

import React from 'react';
import { NavModel } from '@grafana/data';
export interface PluginPageContextType {
sectionNav: NavModel;
}
export const PluginPageContext = React.createContext(getInitialPluginPageContext());
PluginPageContext.displayName = 'PluginPageContext';
function getInitialPluginPageContext(): PluginPageContextType {
return {
sectionNav: {
main: { text: 'Plugin page' },
node: { text: 'Plugin page' },
},
};
}
export function buildPluginPageContext(sectionNav: NavModel | undefined): PluginPageContextType {
return {
sectionNav: sectionNav ?? getInitialPluginPageContext().sectionNav,
};
}