SupportBundles: Feature flag + access control navtree item (#62337)

* SupportBundles: Feature flag + access control navtree item

* remove translation
This commit is contained in:
Josh Hunt
2023-01-27 20:04:04 +00:00
committed by GitHub
parent 07dc994765
commit 6c990b461e
8 changed files with 34 additions and 43 deletions

View File

@@ -4,11 +4,10 @@ import { locationUtil, NavModelItem, NavSection } from '@grafana/data';
import { config, reportInteraction } from '@grafana/runtime';
import { t } from 'app/core/internationalization';
import { contextSrv } from 'app/core/services/context_srv';
import { AccessControlAction } from 'app/types';
import { ShowModalReactEvent } from '../../../types/events';
import appEvents from '../../app_events';
import { FooterLink, getFooterLinks } from '../Footer/Footer';
import { getFooterLinks } from '../Footer/Footer';
import { OrgSwitcher } from '../OrgSwitcher';
import { HelpModal } from '../help/HelpModal';
@@ -53,8 +52,8 @@ export const enrichConfigItems = (items: NavModelItem[], location: Location<unkn
if (link.id === 'help') {
link.children = [
...menuItems,
...getFooterLinks(),
...getSupportBundleFooterLinks(),
{
id: 'keyboard-shortcuts',
text: t('nav.help/keyboard-shortcuts', 'Keyboard shortcuts'),
@@ -79,26 +78,6 @@ export const enrichConfigItems = (items: NavModelItem[], location: Location<unkn
return items;
};
export let getSupportBundleFooterLinks = (cfg = config): FooterLink[] => {
const hasAccess =
contextSrv.hasAccess(AccessControlAction.ActionSupportBundlesCreate, contextSrv.isGrafanaAdmin) ||
contextSrv.hasAccess(AccessControlAction.ActionSupportBundlesRead, contextSrv.isGrafanaAdmin);
if (!cfg.supportBundlesEnabled || !hasAccess) {
return [];
}
return [
{
target: '_self',
id: 'support-bundle',
text: t('nav.help/support-bundle', 'Support Bundles'),
icon: 'question-circle',
url: '/support-bundles',
},
];
};
export const enrichWithInteractionTracking = (item: NavModelItem, expandedState: boolean) => {
const onClick = item.onClick;
item.onClick = () => {