@@ -177,9 +177,9 @@ type TreeNodeProps = {
177177 path : string
178178 expanded : string [ ]
179179 setExpanded : React . Dispatch < React . SetStateAction < string [ ] > >
180- onSetCurrentPath : ( path : string ) => void
180+ onSetCurrentNode : ( content : GenericContent ) => void
181181}
182- const TreeNode = ( { node, repository, renderIcon, path, expanded, setExpanded, onSetCurrentPath } : TreeNodeProps ) => {
182+ const TreeNode = ( { node, repository, renderIcon, path, expanded, setExpanded, onSetCurrentNode } : TreeNodeProps ) => {
183183 const classes = useStyles ( )
184184 const [ childNodes , setChildNodes ] = useState < GenericContent [ ] > ( [ ] )
185185
@@ -189,11 +189,9 @@ const TreeNode = ({ node, repository, renderIcon, path, expanded, setExpanded, o
189189 path : node . Path ,
190190 requestInit : { signal : abortController . signal } ,
191191 } )
192- const children = sortResults ( childrenResult . d . results )
193- if ( ! children || children . length === 0 ) return
194192
195- onSetCurrentPath ( node . Path )
196- setChildNodes ( childrenResult . d . results )
193+ onSetCurrentNode ( node )
194+ setChildNodes ( sortResults ( childrenResult . d . results ) )
197195
198196 setExpanded ( ( prevExpanded ) =>
199197 prevExpanded . includes ( node . Id . toString ( ) ) ? prevExpanded : [ ...prevExpanded , node . Id . toString ( ) ] ,
@@ -215,7 +213,7 @@ const TreeNode = ({ node, repository, renderIcon, path, expanded, setExpanded, o
215213 label = {
216214 < div style = { { display : 'flex' , alignItems : 'center' , gap : 6 , cursor : 'pointer' } } onClick = { handleNodeClick } >
217215 < div className = { classes . treeIcon } > { renderIcon ( node ) } </ div >
218- < div className = { classes . treeLabel } > { node . DisplayName } </ div >
216+ < div className = { classes . treeLabel } > { node . Name } </ div >
219217 </ div >
220218 }
221219 collapseIcon = { < MinusSquare /> }
@@ -230,7 +228,7 @@ const TreeNode = ({ node, repository, renderIcon, path, expanded, setExpanded, o
230228 path = { path }
231229 expanded = { expanded }
232230 setExpanded = { setExpanded }
233- onSetCurrentPath = { onSetCurrentPath }
231+ onSetCurrentNode = { onSetCurrentNode }
234232 />
235233 ) ) }
236234 </ TreeItem >
@@ -258,6 +256,11 @@ interface PickerAdvancedProps {
258256 onSubmit ?: ( selectedItems : GenericContent [ ] ) => void | undefined
259257 allowMultiple ?: boolean
260258 selectionRoots ?: string [ ]
259+ showDialogTitle ?: boolean
260+ canPick ?: boolean
261+ showSearch ?: boolean
262+ setDestinationString ?: React . Dispatch < React . SetStateAction < string | undefined > >
263+ setCurrentNode ?: React . Dispatch < React . SetStateAction < GenericContent > >
261264}
262265export const PickerAdvanced : React . FC < PickerAdvancedProps > = ( {
263266 defaultValue,
@@ -268,6 +271,11 @@ export const PickerAdvanced: React.FC<PickerAdvancedProps> = ({
268271 onSubmit,
269272 allowMultiple = true ,
270273 selectionRoots,
274+ showDialogTitle = true ,
275+ canPick = true ,
276+ showSearch = true ,
277+ setDestinationString,
278+ setCurrentNode,
271279} ) => {
272280 const classes = useStyles ( )
273281 const theme = useTheme ( )
@@ -318,8 +326,8 @@ export const PickerAdvanced: React.FC<PickerAdvancedProps> = ({
318326 cellRenderer : ( props : { data : GenericContent } ) => renderIcon ( props . data ) ,
319327 cellStyle : { padding : 0 } ,
320328 }
321- const availableCols = [ iconCol , ...baseColumns , addCol ]
322- const selectedCols = [ iconCol , ...baseColumns , removeCol ]
329+ const availableCols = [ iconCol , ...baseColumns , ... ( canPick ? [ addCol ] : [ ] ) ]
330+ const selectedCols = [ iconCol , ...baseColumns , ... ( canPick ? [ removeCol ] : [ ] ) ]
323331
324332 //Button Actions
325333 const handleAdd = ( item : GenericContent ) => {
@@ -366,8 +374,17 @@ export const PickerAdvanced: React.FC<PickerAdvancedProps> = ({
366374 } , 250 ) ,
367375 [ ] ,
368376 )
377+ const onSetCurrentNode = ( currNode : GenericContent ) => {
378+ if ( setCurrentNode ) {
379+ setCurrentNode ( currNode )
380+ }
381+ onSetCurrentPath ( currNode . Path )
382+ }
369383 const onSetCurrentPath = ( currPath : string ) => {
370384 setCurrentPath ( currPath )
385+ if ( setDestinationString ) {
386+ setDestinationString ( currPath )
387+ }
371388 if ( currPath === path ) {
372389 setIsInitPath ( true )
373390 }
@@ -446,18 +463,20 @@ export const PickerAdvanced: React.FC<PickerAdvancedProps> = ({
446463
447464 return (
448465 < div className = { classes . mainCont } >
449- < DialogTitle className = { classes . dialogTitle } > Picker</ DialogTitle >
466+ { showDialogTitle && < DialogTitle className = { classes . dialogTitle } > Picker</ DialogTitle > }
450467 < div className = { classes . header } >
451468 < div className = { classes . path } > { currentPath } </ div >
452469 < div className = { classes . search } >
453- < TextField
454- ref = { searchFieldRef }
455- fullWidth = { true }
456- placeholder = { 'Search' }
457- onChange = { ( ev ) => {
458- onSearchFieldChange ( ev . target . value )
459- } }
460- />
470+ { showSearch && (
471+ < TextField
472+ ref = { searchFieldRef }
473+ fullWidth = { true }
474+ placeholder = { 'Search' }
475+ onChange = { ( ev ) => {
476+ onSearchFieldChange ( ev . target . value )
477+ } }
478+ />
479+ ) }
461480 </ div >
462481 </ div >
463482 < div className = { classes . pickingCont } >
@@ -476,7 +495,7 @@ export const PickerAdvanced: React.FC<PickerAdvancedProps> = ({
476495 path = { path }
477496 expanded = { expanded }
478497 setExpanded = { setExpanded }
479- onSetCurrentPath = { onSetCurrentPath }
498+ onSetCurrentNode = { onSetCurrentNode }
480499 />
481500 ) }
482501 </ TreeView >
0 commit comments