Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ComponentType } from '../messageHandlers/types'
import { isLocalDev, localhost, cdn } from '../constants/webviewResources'
import { handleMessage } from './handleMessage'
import { ExecutionDetailsContext } from '../messageHandlers/types'
import { parseExecutionArnForStateMachine } from '../utils'

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

return `${htmlFileSplit[0]} <head> ${baseTag} ${localeTag} ${darkModeTag} ${componentTypeTag} ${executionArnTag} ${startTimeTag} ${htmlFileSplit[1]}`
const region = parseExecutionArnForStateMachine(executionArn)?.region
const regionTag = `<meta name="region" content="${region}" />`

return `${htmlFileSplit[0]} <head> ${baseTag} ${localeTag} ${darkModeTag} ${componentTypeTag} ${executionArnTag} ${startTimeTag} ${regionTag} ${htmlFileSplit[1]}`
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ export async function handleMessage(message: Message, context: ExecutionDetailsC
case Command.INIT:
void initMessageHandler(context)
break
case Command.API_CALL:
void apiCallMessageHandler(message as ApiCallRequestMessage, context)
case Command.API_CALL: {
const region = parseExecutionArnForStateMachine(context.executionArn)?.region || 'us-east-1'
void apiCallMessageHandler(message as ApiCallRequestMessage, context, region)
break
}
case Command.START_EXECUTION:
void startExecutionMessageHandler(context)
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Command, Message, MessageType, BaseContext, ApiCallRequestMessage, UnsupportedMessage } from './types'
import { StepFunctionApiHandler } from './stepFunctionApiHandler'
import globals from '../../shared/extensionGlobals'
import { Command, Message, MessageType, BaseContext, UnsupportedMessage, ApiCallRequestMessage } from './types'
import { getLogger } from '../../shared/logger/logger'
import { StepFunctionApiHandler } from './stepFunctionApiHandler'

/**
* Handler for managing webview stage load, which updates load notifications.
Expand All @@ -20,17 +19,6 @@ export async function loadStageMessageHandler(context: BaseContext) {
}, 100)
}

/**
* Handler for making API calls from the webview and returning the response.
* @param request The request message containing the API to call and the parameters
* @param context The webview context used for returning the API response to the webview
*/
export function apiCallMessageHandler(request: ApiCallRequestMessage, context: BaseContext) {
const logger = getLogger('stepfunctions')
const apiHandler = new StepFunctionApiHandler(globals.awsContext.getCredentialDefaultRegion(), context)
apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error))
}

/**
* Handles unsupported or unrecognized messages by sending a response to the webview. Ensures compatibility with future
* commands and message types, preventing issues if the user has an outdated extension version.
Expand All @@ -45,3 +33,15 @@ export async function handleUnsupportedMessage(context: BaseContext, originalMes
originalMessage,
} as UnsupportedMessage)
}

/**
* Handler for making API calls from the webview and returning the response.
* @param request The request message containing the API to call and the parameters
* @param context The webview context used for returning the API response to the webview
* @param region The AWS region to use for the API calls
*/
export function apiCallMessageHandler(request: ApiCallRequestMessage, context: BaseContext, region: string) {
const logger = getLogger('stepfunctions')
const apiHandler = new StepFunctionApiHandler(region, context)
apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error))
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ export async function handleMessage(message: Message, context: WebviewContext) {
case Command.OPEN_FEEDBACK:
!isReadonlyMode && void submitFeedback(placeholder, 'Workflow Studio')
break
case Command.API_CALL:
!isReadonlyMode && apiCallMessageHandler(message as ApiCallRequestMessage, context)
case Command.API_CALL: {
const region = globals.awsContext.getCredentialDefaultRegion()
!isReadonlyMode && apiCallMessageHandler(message as ApiCallRequestMessage, context, region)
break
}
default:
void handleUnsupportedMessage(context, message)
break
Expand Down
Loading