8
8
type WorkflowParameter ,
9
9
} from '@microsoft/logic-apps-designer' ;
10
10
import type { RootState } from '../state/Store' ;
11
- import { TemplatesView , TemplatesDesignerProvider } from '@microsoft/logic-apps-designer' ;
11
+ import { TemplatesView , TemplatesDesignerProvider , templateStore , resetStateOnResourceChange } from '@microsoft/logic-apps-designer' ;
12
12
import { useSelector } from 'react-redux' ;
13
13
import {
14
14
BaseGatewayService ,
@@ -157,6 +157,24 @@ export const TemplatesConsumption = () => {
157
157
158
158
const resourceDetails = new ArmParser ( workflowId ?? '' ) ;
159
159
160
+ const onReloadServices = ( ) => {
161
+ const { subscriptionId, resourceGroup, location } = templateStore . getState ( ) . workflow ;
162
+ templateStore . dispatch (
163
+ resetStateOnResourceChange (
164
+ getResourceBasedServices (
165
+ subscriptionId ,
166
+ resourceGroup ,
167
+ tenantId ,
168
+ objectId ,
169
+ WorkflowUtility . convertToCanonicalFormat ( location ?? 'westus' ) ,
170
+ language ,
171
+ queryClient ,
172
+ workflowId
173
+ )
174
+ )
175
+ ) ;
176
+ } ;
177
+
160
178
if ( ! workflowData ) {
161
179
return null ;
162
180
}
@@ -175,6 +193,7 @@ export const TemplatesConsumption = () => {
175
193
enableResourceSelection = { enableResourceSelection }
176
194
viewTemplate = { isSingleTemplateView ? { id : templatesView } : undefined }
177
195
reload = { reload }
196
+ onResourceChange = { onReloadServices }
178
197
>
179
198
< div
180
199
style = { {
@@ -249,6 +268,75 @@ const getServices = (
249
268
250
269
const defaultServiceParams = { baseUrl, httpClient, apiVersion } ;
251
270
271
+ const gatewayService = new BaseGatewayService ( {
272
+ baseUrl,
273
+ httpClient,
274
+ apiVersions : {
275
+ subscription : apiVersion ,
276
+ gateway : '2016-06-01' ,
277
+ } ,
278
+ } ) ;
279
+ const tenantService = new BaseTenantService ( {
280
+ ...defaultServiceParams ,
281
+ apiVersion : '2017-08-01' ,
282
+ } ) ;
283
+ const workflowService = {
284
+ getCallbackUrl : ( triggerName : string ) => listCallbackUrl ( workflowId , triggerName , true ) ,
285
+ getAppIdentity : ( ) => workflow ?. identity ,
286
+ isExplicitAuthRequiredForManagedIdentity : ( ) => false ,
287
+ getDefinitionSchema : ( operationInfos : { type : string ; kind ?: string } [ ] ) => {
288
+ return operationInfos . some ( ( info ) => startsWith ( info . type , 'openapiconnection' ) )
289
+ ? 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2023-01-31-preview/workflowdefinition.json#'
290
+ : undefined ;
291
+ } ,
292
+ } ;
293
+ const templateService = new ConsumptionTemplateService ( {
294
+ ...defaultServiceParams ,
295
+ endpoint : 'https://priti-cxf4h5cpcteue4az.b02.azurefd.net' ,
296
+ useEndpointForTemplates : ! ! useEndpoint ,
297
+ openBladeAfterCreate : ( _workflowName : string | undefined ) => {
298
+ window . alert ( 'Open blade after create, consumption creation is complete' ) ;
299
+ } ,
300
+ onAddBlankWorkflow : onBlankWorkflowClick ,
301
+ } ) ;
302
+ const resourceService = new BaseResourceService ( defaultServiceParams ) ;
303
+ const { connectionService, oAuthService, operationManifestService, connectorService } = getResourceBasedServices (
304
+ subscriptionId ,
305
+ resourceGroup ,
306
+ tenantId ,
307
+ objectId ,
308
+ location ,
309
+ locale ,
310
+ queryClient ,
311
+ workflowId
312
+ ) ;
313
+
314
+ return {
315
+ connectionService,
316
+ gatewayService,
317
+ tenantService,
318
+ oAuthService,
319
+ operationManifestService,
320
+ templateService,
321
+ workflowService,
322
+ connectorService,
323
+ resourceService,
324
+ } ;
325
+ } ;
326
+
327
+ const getResourceBasedServices = (
328
+ subscriptionId : string ,
329
+ resourceGroup : string ,
330
+ tenantId : string | undefined ,
331
+ objectId : string | undefined ,
332
+ location : string ,
333
+ locale : string | undefined ,
334
+ queryClient ?: any ,
335
+ workflowId ?: string
336
+ ) : any => {
337
+ const baseUrl = 'https://management.azure.com' ;
338
+ const defaultServiceParams = { baseUrl, httpClient, apiVersion } ;
339
+
252
340
const connectionService = new ConsumptionConnectionService ( {
253
341
apiVersion : '2018-07-01-preview' ,
254
342
baseUrl,
@@ -319,20 +407,7 @@ const getServices = (
319
407
} ,
320
408
} ,
321
409
apiVersion : '2018-07-01-preview' ,
322
- workflowReferenceId : workflowId ,
323
- } ) ;
324
-
325
- const gatewayService = new BaseGatewayService ( {
326
- baseUrl,
327
- httpClient,
328
- apiVersions : {
329
- subscription : apiVersion ,
330
- gateway : '2016-06-01' ,
331
- } ,
332
- } ) ;
333
- const tenantService = new BaseTenantService ( {
334
- ...defaultServiceParams ,
335
- apiVersion : '2017-08-01' ,
410
+ workflowReferenceId : workflowId ?? 'default' ,
336
411
} ) ;
337
412
const oAuthService = new StandaloneOAuthService ( {
338
413
...defaultServiceParams ,
@@ -349,39 +424,12 @@ const getServices = (
349
424
subscriptionId,
350
425
location : location || 'location' ,
351
426
} ) ;
352
- const workflowService = {
353
- getCallbackUrl : ( triggerName : string ) => listCallbackUrl ( workflowId , triggerName , true ) ,
354
- getAppIdentity : ( ) => workflow ?. identity ,
355
- isExplicitAuthRequiredForManagedIdentity : ( ) => false ,
356
- getDefinitionSchema : ( operationInfos : { type : string ; kind ?: string } [ ] ) => {
357
- return operationInfos . some ( ( info ) => startsWith ( info . type , 'openapiconnection' ) )
358
- ? 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2023-01-31-preview/workflowdefinition.json#'
359
- : undefined ;
360
- } ,
361
- } ;
362
-
363
- const templateService = new ConsumptionTemplateService ( {
364
- ...defaultServiceParams ,
365
- endpoint : 'https://priti-cxf4h5cpcteue4az.b02.azurefd.net' ,
366
- useEndpointForTemplates : ! ! useEndpoint ,
367
- openBladeAfterCreate : ( _workflowName : string | undefined ) => {
368
- window . alert ( 'Open blade after create, consumption creation is complete' ) ;
369
- } ,
370
- onAddBlankWorkflow : onBlankWorkflowClick ,
371
- } ) ;
372
-
373
- const resourceService = new BaseResourceService ( defaultServiceParams ) ;
374
427
375
428
return {
376
429
connectionService,
377
- gatewayService,
378
- tenantService,
379
430
oAuthService,
380
431
operationManifestService,
381
- templateService,
382
- workflowService,
383
432
connectorService,
384
- resourceService,
385
433
} ;
386
434
} ;
387
435
0 commit comments