@@ -20,20 +20,22 @@ import APEntityIdsService, {
20
20
import APAdminPortalApiProductsDisplayService , { TAPAdminPortalApiProductDisplay } from "../../displayServices/APAdminPortalApiProductsDisplayService" ;
21
21
import { E_CALL_STATE_ACTIONS } from "./ManageApiProductsCommon" ;
22
22
import APApiSpecsDisplayService , { TAPApiSpecDisplay } from "../../../displayServices/APApiSpecsDisplayService" ;
23
- import { TAPManagedAssetBusinessGroupInfo , TAPManagedAssetLifecycleInfo } from "../../../displayServices/APManagedAssetDisplayService" ;
23
+ import { TAPManagedAssetBusinessGroupInfo , TAPManagedAssetPublishDestinationInfo } from "../../../displayServices/APManagedAssetDisplayService" ;
24
24
import { APDisplayApAttributeDisplayList } from "../../../components/APDisplay/APDisplayApAttributeDisplayList" ;
25
25
import { APDisplayApControlledChannelParameters } from "../../../components/APDisplay/APDisplayApControlledChannelParameters" ;
26
26
import { Config } from "../../../Config" ;
27
27
import { APDisplayApisDetails } from "../../../components/APDisplay/APDisplayApisDetails" ;
28
28
import { Globals } from "../../../utils/Globals" ;
29
29
import APVersioningDisplayService from "../../../displayServices/APVersioningDisplayService" ;
30
30
import APMetaInfoDisplayService from "../../../displayServices/APMetaInfoDisplayService" ;
31
- import { APIProductAccessLevel } from "@solace-iot-team/apim-connector-openapi-browser" ;
31
+ import { APIProductAccessLevel , MetaEntityReference } from "@solace-iot-team/apim-connector-openapi-browser" ;
32
32
import { TAPAttributeDisplayList } from "../../../displayServices/APAttributesDisplayService/APAttributesDisplayService" ;
33
33
import { APDisplayBusinessGroupInfo } from "../../../components/APDisplay/APDisplayBusinessGroupInfo" ;
34
+ import { IAPLifecycleStageInfo } from "../../../displayServices/APLifecycleStageInfoDisplayService" ;
34
35
35
36
import '../../../components/APComponents.css' ;
36
37
import "./ManageApiProducts.css" ;
38
+ import { OrganizationContext } from "../../../components/APContextProviders/APOrganizationContextProvider" ;
37
39
38
40
export enum E_DISPLAY_ADMIN_PORTAL_API_PRODUCT_SCOPE {
39
41
REVIEW_AND_CREATE = "REVIEW_AND_CREATE" ,
@@ -61,20 +63,24 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
61
63
const [ showApiSpecRefreshCounter , setShowApiSpecRefreshCounter ] = React . useState < number > ( 0 ) ;
62
64
const [ tabActiveIndex , setTabActiveIndex ] = React . useState ( 0 ) ;
63
65
// version
64
- const [ selectedVersion , setSelectedVersion ] = React . useState < string > ( ) ;
66
+ const [ selectedRevision , setSelectedRevision ] = React . useState < string > ( ) ;
67
+
68
+ const [ organizationContext ] = React . useContext ( OrganizationContext ) ;
69
+ const IsSingleApiSelection : boolean = organizationContext . apMaxNumApis_Per_ApiProduct === 1 ;
70
+ const ApiTabHeader : string = IsSingleApiSelection ? "API" : "API(s)" ;
65
71
66
72
// * Api Calls *
67
- const apiGetManagedObject = async ( version : string ) : Promise < TApiCallState > => {
73
+ const apiGetManagedObject = async ( revision : string ) : Promise < TApiCallState > => {
68
74
const funcName = 'apiGetManagedObject' ;
69
75
const logName = `${ ComponentName } .${ funcName } ()` ;
70
- let callState : TApiCallState = ApiCallState . getInitialCallState ( E_CALL_STATE_ACTIONS . API_GET_API_PRODUCT , `retrieve details for api product: ${ props . apAdminPortalApiProductDisplay . apEntityId . displayName } , version : ${ version } ` ) ;
76
+ let callState : TApiCallState = ApiCallState . getInitialCallState ( E_CALL_STATE_ACTIONS . API_GET_API_PRODUCT , `retrieve details for api product: ${ props . apAdminPortalApiProductDisplay . apEntityId . displayName } , revision : ${ revision } ` ) ;
71
77
try {
72
78
const object : TAPAdminPortalApiProductDisplay = await APAdminPortalApiProductsDisplayService . apiGet_AdminPortalApApiProductDisplay ( {
73
79
organizationId : props . organizationId ,
74
80
apiProductId : props . apAdminPortalApiProductDisplay . apEntityId . id ,
75
81
default_ownerId : props . apAdminPortalApiProductDisplay . apOwnerInfo . id ,
76
82
fetch_revision_list : true ,
77
- revision : version ,
83
+ revision : revision ,
78
84
} ) ;
79
85
setManagedObject ( object ) ;
80
86
} catch ( e ) {
@@ -122,9 +128,9 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
122
128
setManagedObject ( props . apAdminPortalApiProductDisplay ) ;
123
129
}
124
130
125
- const doFetchVersion = async ( version : string ) => {
131
+ const doFetchRevision = async ( revision : string ) => {
126
132
props . onLoadingChange ( true ) ;
127
- await apiGetManagedObject ( version ) ;
133
+ await apiGetManagedObject ( revision ) ;
128
134
props . onLoadingChange ( false ) ;
129
135
}
130
136
@@ -136,14 +142,14 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
136
142
137
143
React . useEffect ( ( ) => {
138
144
if ( managedObject === undefined ) return ;
139
- setSelectedVersion ( managedObject . apVersionInfo . apCurrentVersion ) ;
145
+ setSelectedRevision ( managedObject . apVersionInfo . apCurrentVersion ) ;
140
146
} , [ managedObject ] ) ; /* eslint-disable-line react-hooks/exhaustive-deps */
141
147
142
148
React . useEffect ( ( ) => {
143
- if ( selectedVersion === undefined ) return ;
149
+ if ( selectedRevision === undefined ) return ;
144
150
if ( managedObject === undefined ) return ;
145
- if ( selectedVersion !== managedObject . apVersionInfo . apCurrentVersion ) doFetchVersion ( selectedVersion ) ;
146
- } , [ selectedVersion ] ) ; /* eslint-disable-line react-hooks/exhaustive-deps */
151
+ if ( selectedRevision !== managedObject . apVersionInfo . apCurrentVersion ) doFetchRevision ( selectedRevision ) ;
152
+ } , [ selectedRevision ] ) ; /* eslint-disable-line react-hooks/exhaustive-deps */
147
153
148
154
React . useEffect ( ( ) => {
149
155
if ( apiCallStatus !== null ) {
@@ -255,46 +261,46 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
255
261
return ( < > </ > ) ;
256
262
}
257
263
258
- const renderVersionSelect = ( ) : JSX . Element => {
259
- const funcName = 'renderVersionSelect ' ;
264
+ const renderRevisionSelect = ( ) : JSX . Element => {
265
+ const funcName = 'renderRevisionSelect ' ;
260
266
const logName = `${ ComponentName } .${ funcName } ()` ;
261
267
if ( managedObject === undefined ) throw new Error ( `${ logName } : managedObject is undefined` ) ;
262
268
if ( managedObject . apVersionInfo . apVersionList === undefined ) throw new Error ( `${ logName } : managedObject.apVersionInfo.apVersionList is undefined` ) ;
263
269
264
- const onVersionSelect = ( e : DropdownChangeParams ) => {
265
- setSelectedVersion ( e . value ) ;
270
+ const onRevisionSelect = ( e : DropdownChangeParams ) => {
271
+ setSelectedRevision ( e . value ) ;
266
272
}
267
273
268
274
return (
269
275
< Dropdown
270
- value = { selectedVersion }
276
+ value = { selectedRevision }
271
277
options = { APVersioningDisplayService . get_Sorted_ApVersionList ( managedObject . apVersionInfo . apVersionList ) }
272
- onChange = { onVersionSelect }
278
+ onChange = { onRevisionSelect }
273
279
/>
274
280
) ;
275
281
}
276
282
277
- const renderVersion = ( mo : TManagedObject ) : JSX . Element => {
278
- const funcName = 'renderVersion ' ;
283
+ const renderRevision = ( mo : TManagedObject ) : JSX . Element => {
284
+ const funcName = 'renderRevision ' ;
279
285
const logName = `${ ComponentName } .${ funcName } ()` ;
280
286
switch ( props . scope ) {
281
287
case E_DISPLAY_ADMIN_PORTAL_API_PRODUCT_SCOPE . VIEW_EXISTING :
282
288
return (
283
- < div > < b > Version : </ b > { renderVersionSelect ( ) } </ div >
289
+ < div > < b > Revision : </ b > { renderRevisionSelect ( ) } </ div >
284
290
) ;
285
291
case E_DISPLAY_ADMIN_PORTAL_API_PRODUCT_SCOPE . REVIEW_AND_CREATE :
286
292
return (
287
- < div > < b > New Version : { mo . apVersionInfo . apCurrentVersion } </ b > </ div >
293
+ < div > < b > New Revision : { mo . apVersionInfo . apCurrentVersion } </ b > </ div >
288
294
) ;
289
295
default :
290
296
Globals . assertNever ( logName , props . scope ) ;
291
297
}
292
298
return ( < > </ > ) ;
293
299
}
294
300
295
- const renderState = ( apManagedAssetLifecycleInfo : TAPManagedAssetLifecycleInfo ) : JSX . Element => {
301
+ const renderState = ( apLifecycleStageInfo : IAPLifecycleStageInfo ) : JSX . Element => {
296
302
return (
297
- < span > < b > State: </ b > { apManagedAssetLifecycleInfo . apLifecycleState } </ span >
303
+ < span > < b > State: </ b > { apLifecycleStageInfo . stage } </ span >
298
304
) ;
299
305
}
300
306
@@ -304,6 +310,16 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
304
310
) ;
305
311
}
306
312
313
+ const renderPublishDestinationInfo = ( apPublishDestinationInfo : TAPManagedAssetPublishDestinationInfo ) : JSX . Element => {
314
+ const renderValue = ( apExternalSystemEntityIdList : TAPEntityIdList ) : string => {
315
+ if ( apExternalSystemEntityIdList . length === 0 ) return 'Not Published.' ;
316
+ return APEntityIdsService . create_SortedDisplayNameList ( apExternalSystemEntityIdList ) . join ( ', ' ) ;
317
+ }
318
+ return (
319
+ < span > < b > Publish Destination(s): </ b > { renderValue ( apPublishDestinationInfo . apExternalSystemEntityIdList ) } </ span >
320
+ ) ;
321
+ }
322
+
307
323
const renderHeader = ( mo : TManagedObject ) : JSX . Element => {
308
324
return (
309
325
< div className = "p-col-12" >
@@ -312,15 +328,16 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
312
328
313
329
< div > { renderBusinessGroupInfo ( mo . apBusinessGroupInfo ) } </ div >
314
330
< div > { renderOwner ( mo . apOwnerInfo ) } </ div >
315
- < div > { renderState ( mo . apLifecycleInfo ) } </ div >
331
+ < div > { renderState ( mo . apLifecycleStageInfo ) } </ div >
316
332
< div > { renderAccessLevel ( mo . apAccessLevel ) } </ div >
333
+ < div > { renderPublishDestinationInfo ( mo . apPublishDestinationInfo ) } </ div >
317
334
318
335
{ /* DEBUG */ }
319
336
{ /* <div><b>DEVEL: Current Version</b>: {mo.apVersionInfo.apCurrentVersion}, Last Version: {mo.apVersionInfo.apLastVersion}</div> */ }
320
337
321
338
</ div >
322
339
< div className = "api-product-view-detail-right" >
323
- < div > { renderVersion ( mo ) } </ div >
340
+ < div > { renderRevision ( mo ) } </ div >
324
341
</ div >
325
342
</ div >
326
343
</ div >
@@ -329,12 +346,19 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
329
346
330
347
const renderMeta = ( mo : TManagedObject ) : JSX . Element => {
331
348
if ( props . scope === E_DISPLAY_ADMIN_PORTAL_API_PRODUCT_SCOPE . REVIEW_AND_CREATE ) return ( < > </ > ) ;
349
+ const renderDerivedFrom = ( derivedFrom ?: MetaEntityReference ) : JSX . Element => {
350
+ if ( derivedFrom === undefined ) return ( < > </ > ) ;
351
+ const _name : string | undefined = derivedFrom . displayName !== undefined ? derivedFrom . displayName : derivedFrom . name ;
352
+ return ( < div > Cloned from: { `${ _name } (${ derivedFrom . revision } )` } </ div > ) ;
353
+ }
332
354
return (
333
355
< React . Fragment >
334
356
< div > Created by: { mo . apMetaInfo . apCreatedBy } </ div >
335
357
< div > Created on: { APMetaInfoDisplayService . create_Timestamp_DisplayString ( mo . apMetaInfo . apCreatedOn ) } </ div >
336
358
< div > Last Modified by: { mo . apMetaInfo . apLastModifiedBy } </ div >
337
- < div > Last Modifined on: { APMetaInfoDisplayService . create_Timestamp_DisplayString ( mo . apMetaInfo . apLastModifiedOn ) } </ div >
359
+ < div > Last Modified on: { APMetaInfoDisplayService . create_Timestamp_DisplayString ( mo . apMetaInfo . apLastModifiedOn ) } </ div >
360
+ { renderDerivedFrom ( mo . apMetaInfo . apDerivedFrom ) }
361
+ { /* <div>Clones: TODO: list of id/displaynames? - needs another API call</div> */ }
338
362
</ React . Fragment >
339
363
) ;
340
364
}
@@ -395,7 +419,7 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
395
419
</ div >
396
420
</ React . Fragment >
397
421
</ TabPanel >
398
- < TabPanel header = 'APIs' >
422
+ < TabPanel header = { ApiTabHeader } >
399
423
< React . Fragment >
400
424
< div >
401
425
{ renderShowApiButtons ( ) }
@@ -481,7 +505,7 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
481
505
{ /* <div>DEBUG: selectedVersion = '{selectedVersion}'</div>
482
506
<div>DEBUG: managedObject.apVersionInfo={JSON.stringify(managedObject?.apVersionInfo)}</div> */ }
483
507
484
- { managedObject && selectedVersion !== undefined && renderManagedObject ( ) }
508
+ { managedObject && selectedRevision !== undefined && renderManagedObject ( ) }
485
509
486
510
</ div >
487
511
</ React . Fragment >
0 commit comments