@@ -12,6 +12,7 @@ import {
1212 DiscoveryServicesData ,
1313 DiscoveryServiceData ,
1414 LibraryData ,
15+ LibraryDataWithStatus ,
1516 LibraryRegistrationsData ,
1617} from "../interfaces" ;
1718import ServiceWithRegistrationsEditForm from "./ServiceWithRegistrationsEditForm" ;
@@ -73,6 +74,45 @@ export class DiscoveryServices extends GenericEditableConfigList<
7374 } ;
7475 }
7576
77+ private registeredLibraries (
78+ item : DiscoveryServiceData
79+ ) : LibraryDataWithStatus [ ] | undefined {
80+ const registrations = this . props . data ?. libraryRegistrations ;
81+ if ( ! registrations ) return undefined ;
82+ const serviceReg = registrations . find ( ( r ) => r . id === item . id ) ;
83+ return ( serviceReg ?. libraries ?? [ ] ) . filter ( ( l ) => l . status === "success" ) ;
84+ }
85+
86+ protected getAssociatedItems (
87+ item : DiscoveryServiceData
88+ ) : Array < any > | undefined {
89+ return this . registeredLibraries ( item ) ;
90+ }
91+
92+ protected formatAssociatedCount ( count : number ) : string {
93+ return count === 0
94+ ? "no registered libraries"
95+ : count === 1
96+ ? "1 registered library"
97+ : `${ count } registered libraries` ;
98+ }
99+
100+ protected getAssociatedEntries (
101+ item : DiscoveryServiceData
102+ ) : Array < { label : string ; suffix ?: string ; href ?: string } > {
103+ const registered = this . registeredLibraries ( item ) ?? [ ] ;
104+ const allLibraries = this . props . data ?. allLibraries ?? [ ] ;
105+ return registered . map ( ( lib ) => {
106+ const meta = allLibraries . find ( ( l ) => l . short_name === lib . short_name ) ;
107+ const uuid = meta ?. uuid ?? lib . uuid ;
108+ return {
109+ label : meta ?. name ?? lib . name ?? lib . short_name ,
110+ suffix : lib . stage ? ` - registered - ${ lib . stage } ` : " - registered" ,
111+ href : uuid ? `/admin/web/config/libraries/edit/${ uuid } ` : undefined ,
112+ } ;
113+ } ) ;
114+ }
115+
76116 UNSAFE_componentWillMount ( ) {
77117 super . UNSAFE_componentWillMount ( ) ;
78118 if ( this . props . fetchLibraryRegistrations ) {
0 commit comments