Skip to content

Commit dc5a5c9

Browse files
author
Diler Zaza
committed
supporting all region execution ARNs
1 parent 70af2bd commit dc5a5c9

File tree

4 files changed

+36
-26
lines changed

4 files changed

+36
-26
lines changed

packages/core/src/stepFunctions/executionDetails/executionDetailProvider.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { ComponentType } from '../messageHandlers/types'
1212
import { isLocalDev, localhost, cdn } from '../constants/webviewResources'
1313
import { handleMessage } from './handleMessage'
1414
import { ExecutionDetailsContext } from '../messageHandlers/types'
15+
import { parseExecutionArnForStateMachine } from '../utils'
1516

1617
/**
1718
* Provider for Execution Details panels.
@@ -89,7 +90,10 @@ export class ExecutionDetailProvider {
8990
// Only include start time tag for express executions (when startTime is provided)
9091
const startTimeTag = startTime ? `<meta name="start-time" content="${startTime}" />` : ''
9192

92-
return `${htmlFileSplit[0]} <head> ${baseTag} ${localeTag} ${darkModeTag} ${componentTypeTag} ${executionArnTag} ${startTimeTag} ${htmlFileSplit[1]}`
93+
const region = parseExecutionArnForStateMachine(executionArn)?.region
94+
const regionTag = `<meta name="region" content="${region}" />`
95+
96+
return `${htmlFileSplit[0]} <head> ${baseTag} ${localeTag} ${darkModeTag} ${componentTypeTag} ${executionArnTag} ${startTimeTag} ${regionTag} ${htmlFileSplit[1]}`
9397
}
9498

9599
/**

packages/core/src/stepFunctions/executionDetails/handleMessage.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ import {
1212
ApiCallRequestMessage,
1313
InitResponseMessage,
1414
} from '../messageHandlers/types'
15-
import {
16-
loadStageMessageHandler,
17-
handleUnsupportedMessage,
18-
apiCallMessageHandler,
19-
} from '../messageHandlers/handleMessageHelpers'
15+
import { loadStageMessageHandler, handleUnsupportedMessage } from '../messageHandlers/handleMessageHelpers'
2016
import { parseExecutionArnForStateMachine, openWorkflowStudio, showExecuteStateMachineWebview } from '../utils'
2117
import { getLogger } from '../../shared/logger/logger'
18+
import { StepFunctionApiHandler } from '../messageHandlers/stepFunctionApiHandler'
2219

2320
/**
2421
* Handles messages received from the ExecutionDetails webview. Depending on the message type and command,
@@ -104,6 +101,20 @@ async function startExecutionMessageHandler(context: ExecutionDetailsContext) {
104101
}
105102
}
106103

104+
/**
105+
* Handler for making API calls from the webview and returning the response.
106+
* @param request The request message containing the API to call and the parameters
107+
* @param context The webview context used for returning the API response to the webview
108+
*/
109+
export function apiCallMessageHandler(request: ApiCallRequestMessage, context: ExecutionDetailsContext) {
110+
const logger = getLogger('stepfunctions')
111+
const apiHandler = new StepFunctionApiHandler(
112+
parseExecutionArnForStateMachine(context.executionArn)?.region || 'us-east-1',
113+
context
114+
)
115+
apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error))
116+
}
117+
107118
async function editStateMachineMessageHandler(context: ExecutionDetailsContext) {
108119
const params = parseExecutionArnForStateMachine(context.executionArn)
109120
await openWorkflowStudio(params!.stateMachineArn, params!.region)

packages/core/src/stepFunctions/messageHandlers/handleMessageHelpers.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import { Command, Message, MessageType, BaseContext, ApiCallRequestMessage, UnsupportedMessage } from './types'
8-
import { StepFunctionApiHandler } from './stepFunctionApiHandler'
9-
import globals from '../../shared/extensionGlobals'
10-
import { getLogger } from '../../shared/logger/logger'
7+
import { Command, Message, MessageType, BaseContext, UnsupportedMessage } from './types'
118

129
/**
1310
* Handler for managing webview stage load, which updates load notifications.
@@ -20,17 +17,6 @@ export async function loadStageMessageHandler(context: BaseContext) {
2017
}, 100)
2118
}
2219

23-
/**
24-
* Handler for making API calls from the webview and returning the response.
25-
* @param request The request message containing the API to call and the parameters
26-
* @param context The webview context used for returning the API response to the webview
27-
*/
28-
export function apiCallMessageHandler(request: ApiCallRequestMessage, context: BaseContext) {
29-
const logger = getLogger('stepfunctions')
30-
const apiHandler = new StepFunctionApiHandler(globals.awsContext.getCredentialDefaultRegion(), context)
31-
apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error))
32-
}
33-
3420
/**
3521
* Handles unsupported or unrecognized messages by sending a response to the webview. Ensures compatibility with future
3622
* commands and message types, preventing issues if the user has an outdated extension version.

packages/core/src/stepFunctions/workflowStudio/handleMessage.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ import {
2828
getStateMachineDefinitionFromCfnTemplate,
2929
toUnescapedAslJsonString,
3030
} from '../commands/visualizeStateMachine/getStateMachineDefinitionFromCfnTemplate'
31-
import {
32-
loadStageMessageHandler,
33-
handleUnsupportedMessage,
34-
apiCallMessageHandler,
35-
} from '../messageHandlers/handleMessageHelpers'
31+
import { loadStageMessageHandler, handleUnsupportedMessage } from '../messageHandlers/handleMessageHelpers'
32+
import { StepFunctionApiHandler } from '../messageHandlers/stepFunctionApiHandler'
33+
import { getLogger } from '../../shared/logger/logger'
3634

3735
const localize = nls.loadMessageBundle()
3836

@@ -210,6 +208,17 @@ async function saveFileAndDeployMessageHandler(request: SaveFileRequestMessage,
210208
})
211209
}
212210

211+
/**
212+
* Handler for making API calls from the webview and returning the response.
213+
* @param request The request message containing the API to call and the parameters
214+
* @param context The webview context used for returning the API response to the webview
215+
*/
216+
export function apiCallMessageHandler(request: ApiCallRequestMessage, context: WebviewContext) {
217+
const logger = getLogger('stepfunctions')
218+
const apiHandler = new StepFunctionApiHandler(globals.awsContext.getCredentialDefaultRegion(), context)
219+
apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error))
220+
}
221+
213222
/**
214223
* Handler for auto syncing a file from the webview which updates the workspace but does not save the file.
215224
* Triggered on every code change from WFS, including invalid JSON.

0 commit comments

Comments
 (0)