2021-11-19 06:42:26 -06:00
|
|
|
import { SafeDynamicImport } from 'app/core/components/DynamicImports/SafeDynamicImport';
|
|
|
|
import { RouteDescriptor } from 'app/core/navigation/types';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2021-11-19 06:42:26 -06:00
|
|
|
import { isGrafanaAdmin } from './permissions';
|
|
|
|
import { PluginAdminRoutes } from './types';
|
|
|
|
|
|
|
|
const DEFAULT_ROUTES = [
|
|
|
|
{
|
|
|
|
path: '/plugins',
|
2022-07-06 10:00:56 -05:00
|
|
|
navId: 'plugins',
|
2021-11-19 06:42:26 -06:00
|
|
|
routeName: PluginAdminRoutes.Home,
|
|
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './pages/Browse')),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/plugins/browse',
|
2022-07-06 10:00:56 -05:00
|
|
|
navId: 'plugins',
|
2021-11-19 06:42:26 -06:00
|
|
|
routeName: PluginAdminRoutes.Browse,
|
|
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './pages/Browse')),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/plugins/:pluginId/',
|
2022-07-06 10:00:56 -05:00
|
|
|
navId: 'plugins',
|
2021-11-19 06:42:26 -06:00
|
|
|
routeName: PluginAdminRoutes.Details,
|
|
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginPage" */ './pages/PluginDetails')),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ADMIN_ROUTES = [
|
|
|
|
{
|
|
|
|
path: '/admin/plugins',
|
2022-07-06 10:00:56 -05:00
|
|
|
navId: 'admin-plugins',
|
2021-11-19 06:42:26 -06:00
|
|
|
routeName: PluginAdminRoutes.HomeAdmin,
|
|
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './pages/Browse')),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/admin/plugins/browse',
|
2022-07-06 10:00:56 -05:00
|
|
|
navId: 'admin-plugins',
|
2021-11-19 06:42:26 -06:00
|
|
|
routeName: PluginAdminRoutes.BrowseAdmin,
|
|
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './pages/Browse')),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/admin/plugins/:pluginId/',
|
2022-07-06 10:00:56 -05:00
|
|
|
navId: 'admin-plugins',
|
2021-11-19 06:42:26 -06:00
|
|
|
routeName: PluginAdminRoutes.DetailsAdmin,
|
|
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginPage" */ './pages/PluginDetails')),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export function getRoutes(): RouteDescriptor[] {
|
|
|
|
if (isGrafanaAdmin()) {
|
|
|
|
return [...DEFAULT_ROUTES, ...ADMIN_ROUTES];
|
|
|
|
}
|
|
|
|
|
|
|
|
return DEFAULT_ROUTES;
|
|
|
|
}
|