mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
* added missing permissions check * moved the permission check to the datasource component. * added test for checking permissions. * added tests with different permissions. * minor refactoring so the mockUserPermisson can be reused.
68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
import { SafeDynamicImport } from 'app/core/components/DynamicImports/SafeDynamicImport';
|
|
import { config } from 'app/core/config';
|
|
import { RouteDescriptor } from 'app/core/navigation/types';
|
|
import { isGrafanaAdmin } from './admin/permissions';
|
|
import { PluginAdminRoutes } from './admin/types';
|
|
|
|
const pluginAdminRoutes = [
|
|
{
|
|
path: '/plugins',
|
|
routeName: PluginAdminRoutes.Home,
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './admin/pages/Browse')),
|
|
},
|
|
{
|
|
path: '/plugins/browse',
|
|
routeName: PluginAdminRoutes.Browse,
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './admin/pages/Browse')),
|
|
},
|
|
{
|
|
path: '/plugins/:pluginId/',
|
|
routeName: PluginAdminRoutes.Details,
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginPage" */ './admin/pages/PluginDetails')),
|
|
},
|
|
];
|
|
|
|
export function getPluginsAdminRoutes(cfg = config): RouteDescriptor[] {
|
|
if (!cfg.pluginAdminEnabled) {
|
|
return [
|
|
{
|
|
path: '/plugins',
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './PluginListPage')),
|
|
},
|
|
{
|
|
path: '/plugins/browse',
|
|
component: SafeDynamicImport(
|
|
() => import(/* webpackChunkName: "PluginAdminNotEnabled" */ './admin/pages/NotEnabed')
|
|
),
|
|
},
|
|
{
|
|
path: '/plugins/:pluginId/',
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginPage" */ './PluginPage')),
|
|
},
|
|
];
|
|
}
|
|
|
|
if (isGrafanaAdmin()) {
|
|
return [
|
|
...pluginAdminRoutes,
|
|
{
|
|
path: '/admin/plugins',
|
|
routeName: PluginAdminRoutes.HomeAdmin,
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './admin/pages/Browse')),
|
|
},
|
|
{
|
|
path: '/admin/plugins/browse',
|
|
routeName: PluginAdminRoutes.BrowseAdmin,
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginListPage" */ './admin/pages/Browse')),
|
|
},
|
|
{
|
|
path: '/admin/plugins/:pluginId/',
|
|
routeName: PluginAdminRoutes.DetailsAdmin,
|
|
component: SafeDynamicImport(() => import(/* webpackChunkName: "PluginPage" */ './admin/pages/PluginDetails')),
|
|
},
|
|
];
|
|
}
|
|
|
|
return pluginAdminRoutes;
|
|
}
|