mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TopNav: Plugin page layouts / information architecture (#53174)
* Change nav structure when topnav is enable to do initial tests with new information architecture * Support for nested sections * Updated * sentance case * Progress on plugin challange * Rewrite to functional component * Progress * Updates * Progress * Progress on things * missing file * Fixing issue with runtime, need to use setter way to set component exposed via runtime * Move PageLayoutType to grafana/data * Fixing breadcrumb issue, adding more tests * reverted backend change * fix recursive issue with cleanup
This commit is contained in:
52
public/app/features/plugins/utils.test.ts
Normal file
52
public/app/features/plugins/utils.test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Location as HistoryLocation } from 'history';
|
||||
|
||||
import { config } from '@grafana/runtime';
|
||||
|
||||
import { buildPluginSectionNav } from './utils';
|
||||
|
||||
describe('buildPluginSectionNav', () => {
|
||||
const pluginNav = { main: { text: 'Plugin nav' }, node: { text: 'Plugin nav' } };
|
||||
const appsSection = {
|
||||
text: 'apps',
|
||||
id: 'apps',
|
||||
children: [
|
||||
{
|
||||
text: 'App1',
|
||||
children: [
|
||||
{
|
||||
text: 'page1',
|
||||
url: '/a/plugin1/page1',
|
||||
},
|
||||
{
|
||||
text: 'page2',
|
||||
url: '/a/plugin1/page2',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const navIndex = { apps: appsSection };
|
||||
|
||||
it('Should return pluginNav if topnav is disabled', () => {
|
||||
config.featureToggles.topnav = false;
|
||||
const result = buildPluginSectionNav({} as HistoryLocation, pluginNav, {});
|
||||
expect(result).toBe(pluginNav);
|
||||
});
|
||||
|
||||
it('Should return return section nav if topnav is enabled', () => {
|
||||
config.featureToggles.topnav = true;
|
||||
const result = buildPluginSectionNav({} as HistoryLocation, pluginNav, navIndex);
|
||||
expect(result?.main.text).toBe('apps');
|
||||
});
|
||||
|
||||
it('Should set active page', () => {
|
||||
config.featureToggles.topnav = true;
|
||||
const result = buildPluginSectionNav(
|
||||
{ pathname: '/a/plugin1/page2', search: '' } as HistoryLocation,
|
||||
null,
|
||||
navIndex
|
||||
);
|
||||
expect(result?.main.children![0].children![1].active).toBe(true);
|
||||
expect(result?.node.text).toBe('page2');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user