navModel: Hide Panels tab when a folder is provisioned (#113250)
This commit is contained in:
@@ -3,6 +3,7 @@ import { t } from '@grafana/i18n';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
import { getNavSubTitle } from 'app/core/utils/navBarItem-translations';
|
||||
import { ManagerKind } from 'app/features/apiserver/types';
|
||||
import { AccessControlAction } from 'app/types/accessControl';
|
||||
import { FolderDTO, FolderParent } from 'app/types/folders';
|
||||
|
||||
@@ -16,6 +17,7 @@ export const getSettingsTabID = (folderUID: string) => `folder-settings-${folder
|
||||
|
||||
export function buildNavModel(folder: FolderDTO | FolderParent, parentsArg?: FolderParent[]): NavModelItem {
|
||||
const parents = parentsArg ?? ('parents' in folder ? folder.parents : undefined);
|
||||
const isProvisioned = 'managedBy' in folder ? folder.managedBy === ManagerKind.Repo : false;
|
||||
|
||||
const model: NavModelItem = {
|
||||
icon: 'folder',
|
||||
@@ -40,13 +42,15 @@ export function buildNavModel(folder: FolderDTO | FolderParent, parentsArg?: Fol
|
||||
model.parentItem = buildNavModel(parent, remainingParents);
|
||||
}
|
||||
|
||||
model.children!.push({
|
||||
active: false,
|
||||
icon: 'library-panel',
|
||||
id: getLibraryPanelsTabID(folder.uid),
|
||||
text: t('browse-dashboards.manage-folder-nav.panels', 'Panels'),
|
||||
url: `${folder.url}/library-panels`,
|
||||
});
|
||||
if (!isProvisioned) {
|
||||
model.children!.push({
|
||||
active: false,
|
||||
icon: 'library-panel',
|
||||
id: getLibraryPanelsTabID(folder.uid),
|
||||
text: t('browse-dashboards.manage-folder-nav.panels', 'Panels'),
|
||||
url: `${folder.url}/library-panels`,
|
||||
});
|
||||
}
|
||||
|
||||
if (contextSrv.hasPermission(AccessControlAction.AlertingRuleRead) && config.unifiedAlertingEnabled) {
|
||||
model.children!.push({
|
||||
|
||||
Reference in New Issue
Block a user