diff --git a/public/app/core/components/NestedFolderPicker/NestedFolderPicker.tsx b/public/app/core/components/NestedFolderPicker/NestedFolderPicker.tsx index a08ccf7f096..c98d12ce8c5 100644 --- a/public/app/core/components/NestedFolderPicker/NestedFolderPicker.tsx +++ b/public/app/core/components/NestedFolderPicker/NestedFolderPicker.tsx @@ -33,11 +33,12 @@ interface NestedFolderPickerProps { // TODO: think properly (and pragmatically) about how to communicate moving to general folder, // vs removing selection (if possible?) onChange?: (folder: FolderChange) => void; + excludeUIDs?: string[]; } const EXCLUDED_KINDS = ['empty-folder' as const, 'dashboard' as const]; -export function NestedFolderPicker({ value, onChange }: NestedFolderPickerProps) { +export function NestedFolderPicker({ value, onChange, excludeUIDs = [] }: NestedFolderPickerProps) { const styles = useStyles2(getStyles); const dispatch = useDispatch(); const selectedFolder = useGetFolderQuery(value || skipToken); @@ -136,10 +137,18 @@ export function NestedFolderPicker({ value, onChange }: NestedFolderPickerProps) items: searchResults.items ?? [], }; - return createFlatTree(undefined, searchCollection, childrenCollections, {}, 0, EXCLUDED_KINDS); + return createFlatTree(undefined, searchCollection, childrenCollections, {}, 0, EXCLUDED_KINDS, excludeUIDs); } - let flatTree = createFlatTree(undefined, rootCollection, childrenCollections, folderOpenState, 0, EXCLUDED_KINDS); + let flatTree = createFlatTree( + undefined, + rootCollection, + childrenCollections, + folderOpenState, + 0, + EXCLUDED_KINDS, + excludeUIDs + ); // Increase the level of each item to 'make way' for the fake root Dashboards item for (const item of flatTree) { @@ -162,7 +171,7 @@ export function NestedFolderPicker({ value, onChange }: NestedFolderPickerProps) } return flatTree; - }, [search, searchState.value, rootCollection, childrenCollections, folderOpenState]); + }, [search, searchState.value, rootCollection, childrenCollections, folderOpenState, excludeUIDs]); const isItemLoaded = useCallback( (itemIndex: number) => { diff --git a/public/app/features/browse-dashboards/components/BrowseActions/MoveModal.tsx b/public/app/features/browse-dashboards/components/BrowseActions/MoveModal.tsx index cc174458707..9b9ae28c82d 100644 --- a/public/app/features/browse-dashboards/components/BrowseActions/MoveModal.tsx +++ b/public/app/features/browse-dashboards/components/BrowseActions/MoveModal.tsx @@ -61,7 +61,7 @@ export const MoveModal = ({ onConfirm, onDismiss, selectedItems, ...props }: Pro {config.featureToggles.nestedFolderPicker ? ( - + ) : ( )} diff --git a/public/app/features/browse-dashboards/state/hooks.ts b/public/app/features/browse-dashboards/state/hooks.ts index 30ff91e4685..9d040810919 100644 --- a/public/app/features/browse-dashboards/state/hooks.ts +++ b/public/app/features/browse-dashboards/state/hooks.ts @@ -144,10 +144,11 @@ export function createFlatTree( childrenByUID: BrowseDashboardsState['childrenByParentUID'], openFolders: Record, level = 0, - excludeKinds: Array = [] + excludeKinds: Array = [], + 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]);