@@ -216,7 +216,7 @@ export class ReactAvailableViewsWidget extends React.Component<ReactAvailableVie
216216 }
217217
218218 private entryToTreeNode ( entry : OutputDescriptor , idStringToNodeId : { [ key : string ] : number } ) : TreeNode {
219- let id = idStringToNodeId [ entry . id ] ?? ( idStringToNodeId [ entry . id ] = this . _idGenerator ++ ) ;
219+ const id = idStringToNodeId [ entry . id ] ?? ( idStringToNodeId [ entry . id ] = this . _idGenerator ++ ) ;
220220
221221 let parentId = - 1 ;
222222 if ( entry . parentId ) {
@@ -241,6 +241,7 @@ export class ReactAvailableViewsWidget extends React.Component<ReactAvailableVie
241241 const isCustomizable = entry . capabilities ?. canCreate === true ;
242242 const isDeletable = entry . capabilities ?. canDelete === true ;
243243
244+ // Return undefined if no relevant capabilities
244245 if ( ! isCustomizable && ! isDeletable ) {
245246 return undefined ;
246247 }
@@ -253,30 +254,36 @@ export class ReactAvailableViewsWidget extends React.Component<ReactAvailableVie
253254 flexShrink : 1
254255 } ;
255256
256- if ( isCustomizable ) {
257- return ( ) : JSX . Element => (
258- < >
259- < span style = { nameSpanStyle } > { entry . name } </ span >
260- < div className = "remove-output-button-container" title = { `Add custom analysis to ${ entry . name } ` } >
261- < button className = "remove-output-button" onClick = { e => this . handleCustomizeClick ( entry , e ) } >
262- < FontAwesomeIcon icon = { faPlus } />
263- </ button >
264- </ div >
265- </ >
266- ) ;
267- } else {
268- // Must be deletable based on our conditions
269- return ( ) : JSX . Element => (
257+ const useCustomizableUI = isCustomizable ;
258+
259+ const EnrichedContent = ( ) : JSX . Element => {
260+ const displayName = useCustomizableUI
261+ ? entry . name
262+ : entry . configuration ?. name ;
263+
264+ const buttonTitle = useCustomizableUI
265+ ? `Add custom analysis to ${ displayName } `
266+ : `Remove "${ displayName } "` ;
267+
268+ const icon = useCustomizableUI ? faPlus : faTimes ;
269+
270+ const handleClick = useCustomizableUI ?
271+ ( e : React . MouseEvent ) => this . handleCustomizeClick ( entry , e ) :
272+ ( e : React . MouseEvent ) => this . handleDeleteClick ( entry , e ) ;
273+
274+ return (
270275 < >
271- < span style = { nameSpanStyle } > { entry . configuration ?. name } </ span >
272- < div className = "remove -output-button-container" title = { `Remove " ${ entry . configuration ?. name } "` } >
273- < button className = "remove -output-button" onClick = { e => this . handleDeleteClick ( entry , e ) } >
274- < FontAwesomeIcon icon = { faTimes } />
276+ < span style = { nameSpanStyle } > { displayName } </ span >
277+ < div className = { 'enriched -output-button-container' } title = { buttonTitle } >
278+ < button className = { 'enriched -output-button' } onClick = { handleClick } >
279+ < FontAwesomeIcon icon = { icon } />
275280 </ button >
276281 </ div >
277282 </ >
278283 ) ;
279- }
284+ } ;
285+
286+ return EnrichedContent ;
280287 }
281288
282289 private handleCustomizeClick = async ( entry : OutputDescriptor , e : React . MouseEvent ) => {
0 commit comments