|
|
|
@ -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) => { |
|
|
|
|