@@ -90,51 +90,44 @@ export default function DefinitionOutdated(props) {
9090 */
9191 function showdiff ( ) {
9292 setIsRendering ( true ) ;
93- const promisedServices = ServiceCatalog . searchServiceByKey ( api . serviceInfo . key ) ;
94- promisedServices . then ( ( data ) => {
95- return ServiceCatalog . getServiceDefinition ( data . body . list [ 0 ] . id ) . then ( ( file ) => {
96- api . getSwagger ( api . id ) . then ( ( resp ) => {
97- setOldDefinition ( JSON . stringify ( resp . obj , null , 2 ) ) ;
93+ const promisedNewServiceDef = ServiceCatalog . searchServiceByKey ( api . serviceInfo . key ) ;
94+ const promisedOldServiceDef = api . getSwagger ( api . id ) ;
95+ Promise . all ( [ promisedNewServiceDef , promisedOldServiceDef ] )
96+ . then ( ( response ) => {
97+ const newServiceDef = response [ 0 ] ;
98+ const oldServiceDef = response [ 1 ] ;
99+ return ServiceCatalog . getServiceDefinition ( newServiceDef . body . list [ 0 ] . id ) . then ( ( file ) => {
98100 setNewDefinition ( JSON . stringify ( file , null , 2 ) ) ;
101+ setOldDefinition ( JSON . stringify ( oldServiceDef . obj , null , 2 ) ) ;
99102 } ) . catch ( ( error ) => {
100103 if ( error . response ) {
101104 Alert . error ( error . response . body . description ) ;
102105 } else {
103106 Alert . error (
104107 < FormattedMessage
105- id = 'Apis.Details.APIDefinition.DefinitionOutdated.outdated .definition.error'
106- defaultMessage = 'Something went wrong while getting the outdated API definition.'
108+ id = 'Apis.Details.APIDefinition.DefinitionOutdated.new.api .definition.error'
109+ defaultMessage = 'Something went wrong while retrieving new API definition.'
107110 /> ,
108111 ) ;
109112 }
110- } ) . finally ( ( ) => {
111- setShowDiff ( true ) ;
112- setIsRendering ( false ) ;
113+ console . error ( error ) ;
113114 } ) ;
114115 } ) . catch ( ( error ) => {
115116 if ( error . response ) {
116117 Alert . error ( error . response . body . description ) ;
117118 } else {
118119 Alert . error (
119120 < FormattedMessage
120- id = 'Apis.Details.APIDefinition.DefinitionOutdated.new.api.definition .error'
121- defaultMessage = 'Something went wrong while getting the new API definition. '
121+ id = 'Apis.Details.APIDefinition.DefinitionOutdated.service.retrieve .error'
122+ defaultMessage = 'Something went wrong while rendering diff for API Definition '
122123 /> ,
123124 ) ;
124125 }
126+ console . error ( error ) ;
127+ } ) . finally ( ( ) => {
128+ setShowDiff ( true ) ;
129+ setIsRendering ( false ) ;
125130 } ) ;
126- } ) . catch ( ( error ) => {
127- if ( error . response ) {
128- Alert . error ( error . response . body . description ) ;
129- } else {
130- Alert . error (
131- < FormattedMessage
132- id = 'Apis.Details.APIDefinition.DefinitionOutdated.service.retrieve.error'
133- defaultMessage = 'Something went wrong while retrieving service information'
134- /> ,
135- ) ;
136- }
137- } ) ;
138131 }
139132
140133 const hideDiff = ( ) => {
0 commit comments