Skip to content

Commit 20293a0

Browse files
author
Zelin Zhou
committed
fix: circular dependency in StepFunctions extension by introducing a callback to openExecutionDetails.
1 parent bd9b1e4 commit 20293a0

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

packages/core/src/awsexplorer/activation.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { getSourceNode } from '../shared/utilities/treeNodeUtils'
3737
import { openAwsCFNConsoleCommand, openAwsConsoleCommand } from '../shared/awsConsole'
3838
import { StackNameNode } from '../awsService/appBuilder/explorer/nodes/deployedStack'
3939
import { LambdaFunctionNodeDecorationProvider } from '../lambda/explorer/lambdaFunctionNodeDecorationProvider'
40+
import { ExecutionDetailProvider } from '../stepFunctions/executionDetails/executionDetailProvider'
4041

4142
/**
4243
* Activates the AWS Explorer UI and related functionality.
@@ -192,7 +193,12 @@ async function registerAwsExplorerCommands(
192193
context.extensionContext.subscriptions.push(
193194
Commands.register(
194195
'aws.executeStateMachine',
195-
async (node: StateMachineNode) => await executeStateMachine(context, node)
196+
async (node: StateMachineNode) =>
197+
await executeStateMachine(
198+
context,
199+
node,
200+
ExecutionDetailProvider.openExecutionDetails.bind(ExecutionDetailProvider)
201+
)
196202
),
197203
Commands.register('aws.copyArn', async (node: AWSResourceNode | TreeNode) => {
198204
const sourceNode = getSourceNode<AWSResourceNode>(node)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export class ExecutionDetailProvider {
115115
loaderNotification: undefined,
116116
executionArn,
117117
startTime,
118+
openExecutionDetails: ExecutionDetailProvider.openExecutionDetails.bind(ExecutionDetailProvider),
118119
}
119120

120121
// Handle messages from the webview

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
import { parseExecutionArnForStateMachine } from '../utils'
2222
import { getLogger } from '../../shared/logger/logger'
2323
import { openWorkflowStudio } from '../stepFunctionsWorkflowStudioUtils'
24+
import { showExecuteStateMachineWebview } from '../vue/executeStateMachine/executeStateMachine'
2425

2526
/**
2627
* Handles messages received from the ExecutionDetails webview. Depending on the message type and command,
@@ -98,12 +99,11 @@ async function startExecutionMessageHandler(message: StartExecutionMessage, cont
9899

99100
const { region, stateMachineName, stateMachineArn } = parsedArn
100101

101-
const executeStateMachineUtils = await import('../vue/executeStateMachine/executeStateMachine.js')
102-
const { showExecuteStateMachineWebview } = executeStateMachineUtils
103102
await showExecuteStateMachineWebview({
104103
arn: stateMachineArn,
105104
name: stateMachineName,
106105
region: region,
106+
openExecutionDetails: context.openExecutionDetails,
107107
executionInput: message.executionInput,
108108
})
109109
} catch (error) {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ export interface WebviewContext extends BaseContext {
3535
fileId: string
3636
}
3737

38+
export type openExecutionDetailsCallBack = (
39+
executionArn: string,
40+
startTime?: string,
41+
params?: vscode.WebviewPanelOptions & vscode.WebviewOptions
42+
) => Promise<void>
43+
3844
export interface ExecutionDetailsContext extends BaseContext {
3945
executionArn: string
4046
startTime?: string
47+
openExecutionDetails: openExecutionDetailsCallBack
4148
}
4249

4350
export type LoaderNotification = {

packages/core/src/stepFunctions/vue/executeStateMachine/executeStateMachine.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ import { ExtContext } from '../../../shared/extensions'
1515
import { VueWebview } from '../../../webviews/main'
1616
import * as vscode from 'vscode'
1717
import { telemetry } from '../../../shared/telemetry/telemetry'
18-
import { ExecutionDetailProvider } from '../../executionDetails/executionDetailProvider'
1918
import globals from '../../../shared/extensionGlobals'
19+
import { openExecutionDetailsCallBack } from '../../messageHandlers/types'
2020

2121
interface StateMachine {
2222
arn: string
2323
name: string
2424
region: string
25+
openExecutionDetails: openExecutionDetailsCallBack
2526
executionInput?: string
2627
}
2728

@@ -64,7 +65,7 @@ export class ExecuteStateMachineWebview extends VueWebview {
6465
stateMachineArn: this.stateMachine.arn,
6566
input,
6667
})
67-
await ExecutionDetailProvider.openExecutionDetails(
68+
await this.stateMachine.openExecutionDetails(
6869
startExecResponse.executionArn!,
6970
startExecResponse.startDate!.toString()
7071
)
@@ -101,13 +102,15 @@ export const showExecuteStateMachineWebview = async (stateMachineData: {
101102
arn: string
102103
name: string
103104
region: string
105+
openExecutionDetails: openExecutionDetailsCallBack
104106
executionInput?: string
105107
}) => {
106108
const Panel = VueWebview.compilePanel(ExecuteStateMachineWebview)
107109
const wv = new Panel(globals.context, globals.outputChannel, {
108110
arn: stateMachineData.arn,
109111
name: stateMachineData.name,
110112
region: stateMachineData.region,
113+
openExecutionDetails: stateMachineData.openExecutionDetails,
111114
executionInput: stateMachineData.executionInput,
112115
})
113116

@@ -122,12 +125,14 @@ export const showExecuteStateMachineWebview = async (stateMachineData: {
122125
export async function executeStateMachine(
123126
context: ExtContext,
124127
node: StateMachineNode,
128+
openExecutionDetails: openExecutionDetailsCallBack,
125129
executionInput?: string
126130
): Promise<void> {
127131
await showExecuteStateMachineWebview({
128132
arn: node.details.stateMachineArn || '',
129133
name: node.details.name || '',
130134
region: node.regionCode,
135+
openExecutionDetails,
131136
executionInput,
132137
})
133138
telemetry.stepfunctions_executeStateMachineView.emit()

0 commit comments

Comments
 (0)