@@ -73,7 +73,9 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
73
73
74
74
const [ organizationContext ] = React . useContext ( OrganizationContext ) ;
75
75
const IsSingleApiSelection : boolean = organizationContext . apMaxNumApis_Per_ApiProduct === 1 ;
76
+ const IsSingleEnvSelection : boolean = organizationContext . apMaxNumEnvs_Per_ApiProduct === 1 ;
76
77
const ApiTabHeader : string = IsSingleApiSelection ? "API" : "API(s)" ;
78
+ const EnvTabHeader : string = IsSingleEnvSelection ? "Environment" : "Environment(s)" ;
77
79
const viewAppReferenceHistory = useHistory < TAPPageNavigationInfo > ( ) ;
78
80
const ReferencedByTabIndex : number = 5 ;
79
81
@@ -134,6 +136,40 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
134
136
return callState ;
135
137
}
136
138
139
+ const apiGetApiZipContents = async ( apiId : string , apiDisplayName : string ) : Promise < Blob | undefined > => {
140
+ const funcName = 'apiGetApiZipContents' ;
141
+ const logName = `${ ComponentName } .${ funcName } ()` ;
142
+ if ( managedObject === undefined ) throw new Error ( `${ logName } : managedObject === undefined` ) ;
143
+ let callState : TApiCallState = ApiCallState . getInitialCallState ( E_CALL_STATE_ACTIONS . API_GET_API_SPEC , `retrieve zip contents for api: ${ apiDisplayName } ` ) ;
144
+ let zipContents : Blob | undefined = undefined ;
145
+ try {
146
+ switch ( props . scope ) {
147
+ case E_DISPLAY_ADMIN_PORTAL_API_PRODUCT_SCOPE . VIEW_EXISTING :
148
+ case E_DISPLAY_ADMIN_PORTAL_API_PRODUCT_SCOPE . VIEW_REFEREMCED_BY :
149
+ case E_DISPLAY_ADMIN_PORTAL_API_PRODUCT_SCOPE . VIEW_EXISTING_MAINTAIN :
150
+ zipContents = await APApiSpecsDisplayService . apiGet_ApiProduct_ApiSpec_ZipContents ( {
151
+ organizationId : props . organizationId ,
152
+ apiProductId : managedObject . apEntityId . id ,
153
+ apiEntityId : { id : apiId , displayName : apiDisplayName }
154
+ } ) ;
155
+ break ;
156
+ case E_DISPLAY_ADMIN_PORTAL_API_PRODUCT_SCOPE . REVIEW_AND_CREATE :
157
+ zipContents = await APApiSpecsDisplayService . apiGet_Api_ApiSpec_ZipContents ( {
158
+ organizationId : props . organizationId ,
159
+ apiEntityId : { id : apiId , displayName : apiDisplayName }
160
+ } ) ;
161
+ break ;
162
+ default :
163
+ Globals . assertNever ( logName , props . scope ) ;
164
+ }
165
+ } catch ( e ) {
166
+ APClientConnectorOpenApi . logError ( logName , e ) ;
167
+ callState = ApiCallState . addErrorToApiCallState ( e , callState ) ;
168
+ }
169
+ setApiCallStatus ( callState ) ;
170
+ return zipContents ;
171
+ }
172
+
137
173
const doInitialize = async ( ) => {
138
174
setManagedObject ( props . apAdminPortalApiProductDisplay ) ;
139
175
}
@@ -182,6 +218,16 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
182
218
props . onLoadingChange ( false ) ;
183
219
}
184
220
221
+ const doFetchZipContents = async ( ) : Promise < Blob | undefined > => {
222
+ const funcName = 'doFetchZipContents' ;
223
+ const logName = `${ ComponentName } .${ funcName } ()` ;
224
+ if ( showApiId === undefined ) throw new Error ( `${ logName } : showApiId === undefined` ) ;
225
+ props . onLoadingChange ( true ) ;
226
+ const zipContents : Blob | undefined = await apiGetApiZipContents ( showApiId , showApiId ) ;
227
+ props . onLoadingChange ( false ) ;
228
+ if ( zipContents !== undefined ) return zipContents ;
229
+ }
230
+
185
231
React . useEffect ( ( ) => {
186
232
if ( showApiId === undefined ) return ;
187
233
doFetchApiSpec ( showApiId ) ;
@@ -417,6 +463,7 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
417
463
schemaId = { showApiId }
418
464
onDownloadSuccess = { props . onSuccess }
419
465
onDownloadError = { props . onError }
466
+ fetchZipContentsFunc = { doFetchZipContents }
420
467
/>
421
468
</ React . Fragment >
422
469
}
@@ -436,9 +483,9 @@ export const DisplayAdminPortalApiProduct: React.FC<IDisplayAdminPortalApiProduc
436
483
</ TabPanel >
437
484
) ;
438
485
tabPanels . push (
439
- < TabPanel header = 'Environments' >
486
+ < TabPanel header = { EnvTabHeader } >
440
487
< React . Fragment >
441
- < div className = "p-text-bold" > Environments :</ div >
488
+ < div className = "p-text-bold" > { EnvTabHeader } :</ div >
442
489
< div className = "p-ml-2" >
443
490
{ APEntityIdsService . create_SortedDisplayNameList_From_ApDisplayObjectList ( managedObject . apEnvironmentDisplayList ) . join ( ', ' ) }
444
491
</ div >
0 commit comments