@@ -242,8 +242,42 @@ export abstract class GenericEditableConfigList<
242242 : `${ count } libraries` ;
243243 }
244244
245+ protected getAssociatedEntries (
246+ item : any
247+ ) : Array < { label : string ; suffix ?: string ; href ?: string } > {
248+ const libraries : Array < { short_name : string } > = item ?. libraries || [ ] ;
249+ const allLibraries : Array < {
250+ short_name : string ;
251+ name ?: string ;
252+ uuid ?: string ;
253+ } > = ( this . props . data as any ) ?. allLibraries || [ ] ;
254+ return libraries . map ( ( lib ) => {
255+ const libraryData = allLibraries . find (
256+ ( l ) => l . short_name === lib . short_name
257+ ) ;
258+ return {
259+ label : libraryData ?. name || lib . short_name ,
260+ href : libraryData ?. uuid
261+ ? `/admin/web/config/libraries/edit/${ libraryData . uuid } `
262+ : undefined ,
263+ } ;
264+ } ) ;
265+ }
266+
245267 protected renderAssociatedSection ( item : any ) : JSX . Element {
246- return this . renderAssociatedLibraries ( item ) ;
268+ const entries = this . getAssociatedEntries ( item ) . sort ( ( a , b ) =>
269+ a . label . localeCompare ( b . label )
270+ ) ;
271+ return (
272+ < ul className = "associated-libraries" >
273+ { entries . map ( ( entry , i ) => (
274+ < li key = { i } >
275+ { entry . href ? < a href = { entry . href } > { entry . label } </ a > : entry . label }
276+ { entry . suffix }
277+ </ li >
278+ ) ) }
279+ </ ul >
280+ ) ;
247281 }
248282
249283 renderLi ( item , index ) : JSX . Element {
@@ -355,34 +389,6 @@ export abstract class GenericEditableConfigList<
355389 this . setState ( { expandedItems : newExpandedItems } ) ;
356390 }
357391
358- renderAssociatedLibraries ( item : any ) : JSX . Element {
359- const libraries : Array < { short_name : string } > = item . libraries ;
360- const allLibraries : Array < {
361- short_name : string ;
362- name ?: string ;
363- uuid ?: string ;
364- } > = ( this . props . data as any ) ?. allLibraries || [ ] ;
365-
366- return (
367- < ul className = "associated-libraries" >
368- { libraries . map ( ( lib ) => {
369- const libraryData = allLibraries . find (
370- ( l ) => l . short_name === lib . short_name
371- ) ;
372- const name = libraryData ?. name || lib . short_name ;
373- const href = libraryData ?. uuid
374- ? `/admin/web/config/libraries/edit/${ libraryData . uuid } `
375- : null ;
376- return (
377- < li key = { lib . short_name } >
378- { href ? < a href = { href } > { name } </ a > : name }
379- </ li >
380- ) ;
381- } ) }
382- </ ul >
383- ) ;
384- }
385-
386392 label ( item ) : string {
387393 return item [ this . labelKey ] ;
388394 }
0 commit comments