mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
NestedFolderPicker: Allow for excluding certain uids (#72019)
* exclude some uids from nested folder picker so you can't move a folder to itself * rename excludedUids to excludeUIDs
This commit is contained in:
@@ -61,7 +61,7 @@ export const MoveModal = ({ onConfirm, onDismiss, selectedItems, ...props }: Pro
|
||||
|
||||
<Field label={t('browse-dashboards.action.move-modal-field-label', 'Folder name')}>
|
||||
{config.featureToggles.nestedFolderPicker ? (
|
||||
<NestedFolderPicker value={moveTarget} onChange={handleFolderChange} />
|
||||
<NestedFolderPicker value={moveTarget} onChange={handleFolderChange} excludeUIDs={selectedFolders} />
|
||||
) : (
|
||||
<FolderPicker allowEmpty onChange={handleFolderChange} />
|
||||
)}
|
||||
|
||||
@@ -144,10 +144,11 @@ export function createFlatTree(
|
||||
childrenByUID: BrowseDashboardsState['childrenByParentUID'],
|
||||
openFolders: Record<string, boolean>,
|
||||
level = 0,
|
||||
excludeKinds: Array<DashboardViewItemWithUIItems['kind'] | UIDashboardViewItem['uiKind']> = []
|
||||
excludeKinds: Array<DashboardViewItemWithUIItems['kind'] | UIDashboardViewItem['uiKind']> = [],
|
||||
excludeUIDs: string[] = []
|
||||
): DashboardsTreeItem[] {
|
||||
function mapItem(item: DashboardViewItem, parentUID: string | undefined, level: number): DashboardsTreeItem[] {
|
||||
if (excludeKinds.includes(item.kind)) {
|
||||
if (excludeKinds.includes(item.kind) || excludeUIDs.includes(item.uid)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -157,7 +158,8 @@ export function createFlatTree(
|
||||
childrenByUID,
|
||||
openFolders,
|
||||
level + 1,
|
||||
excludeKinds
|
||||
excludeKinds,
|
||||
excludeUIDs
|
||||
);
|
||||
|
||||
const isOpen = Boolean(openFolders[item.uid]);
|
||||
|
||||
Reference in New Issue
Block a user