mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* simplify toggle + add link to server admin * feat(catalog): org admins can configure plugin apps, cannot install/uninstall plugins * fix(catalog): dont show buttons if user doesn't have install permissions * feat(catalog): cater for accessing catalog via /plugins and /admin/plugins * feat(catalog): use location for list links and match.url to define breadcrumb links * test(catalog): mock isGrafanaAdmin for PluginDetails tests * test(catalog): preserve default bootdata in PluginDetails mock * refactor(catalog): move orgAdmin check out of state and make easier to reason with Co-authored-by: Will Browne <will.browne@grafana.com>
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/helpers';
|
|
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;
|
|
}
|