Skip to content

Commit ea965d9

Browse files
author
Diler Zaza
committed
feat(stepfunctions): enable hardcoded execution details page
1 parent 8f87b49 commit ea965d9

File tree

11 files changed

+114
-67
lines changed

11 files changed

+114
-67
lines changed

packages/core/src/shared/clients/stepFunctions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
UpdateStateMachineCommandOutput,
2727
} from '@aws-sdk/client-sfn'
2828
import { ClientWrapper } from './clientWrapper'
29+
// import { StopExecutionInput } from 'aws-sdk/clients/stepfunctions'
2930

3031
export class StepFunctionsClient extends ClientWrapper<SFNClient> {
3132
public constructor(regionCode: string) {

packages/core/src/stepFunctions/commands/visualizeStateMachine/renderStateMachineGraphCDK.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { isTreeNode } from '../../../shared/treeview/resourceTreeDataProvider'
1212
import { unboxTreeNode } from '../../../shared/treeview/utils'
1313
import { Commands } from '../../../shared/vscode/commands2'
1414
import { PreviewStateMachineCDKWizard } from '../../wizards/previewStateMachineCDKWizard'
15-
import { WorkflowMode } from '../../workflowStudio/types'
15+
import { WorkflowMode } from '../../messageHandlers/types'
1616
import { WorkflowStudioEditorProvider } from '../../workflowStudio/workflowStudioEditorProvider'
1717
import { getStateMachineDefinitionFromCfnTemplate } from './getStateMachineDefinitionFromCfnTemplate'
1818

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import { getLogger } from '../../shared/logger/logger'
88
import request from '../../shared/request'
99
import { ToolkitError } from '../../shared/errors'
1010
import { i18n } from '../../shared/i18n-helper'
11-
import { ComponentType, WorkflowMode } from '../workflowStudio/types'
11+
import { ComponentType } from '../messageHandlers/types'
1212
import { isLocalDev, localhost, cdn } from '../constants/webviewResources'
13-
import { handleMessage, ExecutionDetailsContext } from './handleMessage'
13+
import { handleMessage } from './handleMessage'
14+
import { ExecutionDetailsContext } from '../messageHandlers/types'
1415

1516
/**
1617
* Provider for Execution Details panels.
@@ -99,6 +100,13 @@ export class ExecutionDetailProvider {
99100

100101
// Set up the content
101102
panel.webview.html = await this.getWebviewContent()
103+
const context: ExecutionDetailsContext = {
104+
stateMachineName: executionArn.split(':').pop() || 'Unknown',
105+
panel,
106+
loaderNotification: undefined,
107+
fileId: executionArn,
108+
executionArn,
109+
}
102110

103111
// Create execution details context
104112
const context: ExecutionDetailsContext = {

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@ import {
88
Command,
99
Message,
1010
MessageType,
11-
WebviewContext,
11+
ExecutionDetailsContext,
1212
ApiCallRequestMessage,
13-
UnsupportedMessage,
1413
InitResponseMessage,
15-
} from '../workflowStudio/types'
16-
17-
import { WorkflowStudioApiHandler } from '../workflowStudio/workflowStudioApiHandler'
18-
import globals from '../../shared/extensionGlobals'
19-
import { getLogger } from '../../shared/logger/logger'
20-
21-
// Extended context for execution details
22-
export interface ExecutionDetailsContext extends WebviewContext {
23-
executionArn?: string
24-
}
14+
} from '../messageHandlers/types'
15+
import {
16+
loadStageMessageHandler,
17+
handleUnsupportedMessage,
18+
apiCallMessageHandler,
19+
} from '../messageHandlers/handleMessageHelpers'
2520

2621
/**
2722
* Handles messages received from the ExecutionDetails webview. Depending on the message type and command,
@@ -78,6 +73,7 @@ async function initMessageHandler(context: ExecutionDetailsContext) {
7873
} as InitResponseMessage)
7974
}
8075
}
76+
<<<<<<< HEAD
8177

8278
/**
8379
* Handler for managing webview stage load, which updates load notifications.
@@ -118,3 +114,5 @@ async function handleUnsupportedMessage(context: ExecutionDetailsContext, origin
118114
originalMessage,
119115
} as UnsupportedMessage)
120116
}
117+
=======
118+
>>>>>>> 5aa458d7d (feat(stepfunctions): enable hardcoded execution details page)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
/*!
3+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import {
8+
Command,
9+
Message,
10+
MessageType,
11+
WebviewContext,
12+
ExecutionDetailsContext,
13+
ApiCallRequestMessage,
14+
UnsupportedMessage,
15+
} from './types'
16+
import { stepFunctionApiHandler } from './stepFunctionApiHandler'
17+
import globals from '../../shared/extensionGlobals'
18+
import { getLogger } from '../../shared/logger/logger'
19+
20+
/**
21+
* Handler for managing webview stage load, which updates load notifications.
22+
* @param context The context object containing the necessary information for the webview.
23+
*/
24+
export async function loadStageMessageHandler(context: WebviewContext | ExecutionDetailsContext) {
25+
context.loaderNotification?.progress.report({ increment: 25 })
26+
setTimeout(() => {
27+
context.loaderNotification?.resolve()
28+
}, 100)
29+
}
30+
31+
/**
32+
* Handler for making API calls from the webview and returning the response.
33+
* @param request The request message containing the API to call and the parameters
34+
* @param context The webview context used for returning the API response to the webview
35+
*/
36+
export function apiCallMessageHandler(
37+
request: ApiCallRequestMessage,
38+
context: WebviewContext | ExecutionDetailsContext
39+
) {
40+
const logger = getLogger('stepfunctions')
41+
const apiHandler = new stepFunctionApiHandler(globals.awsContext.getCredentialDefaultRegion(), context)
42+
apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error))
43+
}
44+
45+
/**
46+
* Handles unsupported or unrecognized messages by sending a response to the webview. Ensures compatibility with future
47+
* commands and message types, preventing issues if the user has an outdated extension version.
48+
* @param context The context object containing information about the webview environment
49+
* @param command The command received from the webview
50+
* @param messageType The type of the message received
51+
*/
52+
export async function handleUnsupportedMessage(
53+
context: WebviewContext | ExecutionDetailsContext,
54+
originalMessage: Message
55+
) {
56+
await context.panel.webview.postMessage({
57+
messageType: MessageType.RESPONSE,
58+
command: Command.UNSUPPORTED_COMMAND,
59+
originalMessage,
60+
} as UnsupportedMessage)
61+
}

packages/core/src/stepFunctions/workflowStudio/workflowStudioApiHandler.ts renamed to packages/core/src/stepFunctions/messageHandlers/stepFunctionApiHandler.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@
66
import * as StepFunctions from '@aws-sdk/client-sfn'
77
import { IamClient, IamRole } from '../../shared/clients/iam'
88
import { StepFunctionsClient } from '../../shared/clients/stepFunctions'
9-
import { ApiAction, ApiCallRequestMessage, Command, MessageType, WebviewContext } from './types'
9+
import {
10+
ApiAction,
11+
ApiCallRequestMessage,
12+
Command,
13+
MessageType,
14+
WebviewContext,
15+
ExecutionDetailsContext,
16+
} from './types'
1017
import { telemetry } from '../../shared/telemetry/telemetry'
1118
import { ListRolesRequest } from '@aws-sdk/client-iam'
1219

13-
export class WorkflowStudioApiHandler {
20+
export class stepFunctionApiHandler {
1421
public constructor(
1522
region: string,
16-
private readonly context: WebviewContext,
23+
private readonly context: WebviewContext | ExecutionDetailsContext,
1724
private readonly clients = {
1825
sfn: new StepFunctionsClient(region),
1926
iam: new IamClient(region),

packages/core/src/stepFunctions/workflowStudio/types.ts renamed to packages/core/src/stepFunctions/messageHandlers/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ export type WebviewContext = {
3030
fileId: string
3131
}
3232

33+
export type ExecutionDetailsContext = {
34+
stateMachineName: string
35+
panel: vscode.WebviewPanel
36+
fileId: string
37+
loaderNotification: undefined | LoaderNotification
38+
executionArn: string
39+
}
40+
3341
export type LoaderNotification = {
3442
progress: vscode.Progress<{
3543
message?: string | undefined

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

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,25 @@ import {
1414
FileChangeEventTrigger,
1515
SyncFileRequestMessage,
1616
ApiCallRequestMessage,
17-
UnsupportedMessage,
1817
WorkflowMode,
19-
} from './types'
18+
} from '../messageHandlers/types'
2019
import { submitFeedback } from '../../feedback/vue/submitFeedback'
2120
import { placeholder } from '../../shared/vscode/commands2'
2221
import * as nls from 'vscode-nls'
2322
import vscode from 'vscode'
2423
import { telemetry } from '../../shared/telemetry/telemetry'
2524
import { ToolkitError } from '../../shared/errors'
26-
import { WorkflowStudioApiHandler } from './workflowStudioApiHandler'
2725
import globals from '../../shared/extensionGlobals'
28-
import { getLogger } from '../../shared/logger/logger'
2926
import { publishStateMachine } from '../commands/publishStateMachine'
3027
import {
3128
getStateMachineDefinitionFromCfnTemplate,
3229
toUnescapedAslJsonString,
3330
} from '../commands/visualizeStateMachine/getStateMachineDefinitionFromCfnTemplate'
31+
import {
32+
loadStageMessageHandler,
33+
handleUnsupportedMessage,
34+
apiCallMessageHandler,
35+
} from '../messageHandlers/handleMessageHelpers'
3436

3537
const localize = nls.loadMessageBundle()
3638

@@ -143,18 +145,6 @@ export async function broadcastFileChange(context: WebviewContext, trigger: File
143145
} as FileChangedMessage)
144146
}
145147

146-
/**
147-
* Handler for managing webview stage load, which updates load notifications.
148-
* @param message The message containing the load stage.
149-
* @param context The context object containing the necessary information for the webview.
150-
*/
151-
async function loadStageMessageHandler(context: WebviewContext) {
152-
context.loaderNotification?.progress.report({ increment: 25 })
153-
setTimeout(() => {
154-
context.loaderNotification?.resolve()
155-
}, 100)
156-
}
157-
158148
/**
159149
* Handler for closing WFS custom editor. When called, disposes webview panel and opens default VSCode editor
160150
* @param context The context object containing the necessary information for the webview.
@@ -250,29 +240,3 @@ async function autoSyncFileMessageHandler(request: SyncFileRequestMessage, conte
250240
}
251241
})
252242
}
253-
254-
/**
255-
* Handler for making API calls from the webview and returning the response.
256-
* @param request The request message containing the API to call and the parameters
257-
* @param context The webview context used for returning the API response to the webview
258-
*/
259-
function apiCallMessageHandler(request: ApiCallRequestMessage, context: WebviewContext) {
260-
const logger = getLogger('stepfunctions')
261-
const apiHandler = new WorkflowStudioApiHandler(globals.awsContext.getCredentialDefaultRegion(), context)
262-
apiHandler.performApiCall(request).catch((error) => logger.error('%s API call failed: %O', request.apiName, error))
263-
}
264-
265-
/**
266-
* Handles unsupported or unrecognized messages by sending a response to the webview. Ensures compatibility with future
267-
* commands and message types, preventing issues if the user has an outdated extension version.
268-
* @param context The context object containing information about the webview environment
269-
* @param command The command received from the webview
270-
* @param messageType The type of the message received
271-
*/
272-
async function handleUnsupportedMessage(context: WebviewContext, originalMessage: Message) {
273-
await context.panel.webview.postMessage({
274-
messageType: MessageType.RESPONSE,
275-
command: Command.UNSUPPORTED_COMMAND,
276-
originalMessage,
277-
} as UnsupportedMessage)
278-
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as vscode from 'vscode'
88
import { telemetry } from '../../shared/telemetry/telemetry'
99
import { i18n } from '../../shared/i18n-helper'
1010
import { broadcastFileChange } from './handleMessage'
11-
import { FileWatchInfo, WebviewContext, WorkflowMode } from './types'
11+
import { FileWatchInfo, WebviewContext, WorkflowMode } from '../messageHandlers/types'
1212
import { CancellationError } from '../../shared/utilities/timeoutUtils'
1313
import { handleMessage } from './handleMessage'
1414
import { isInvalidJsonFile } from '../utils'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { getTabSizeSetting } from '../../shared/utilities/editorUtilities'
1515
import { WorkflowStudioEditor } from './workflowStudioEditor'
1616
import { i18n } from '../../shared/i18n-helper'
1717
import { isInvalidJsonFile, isInvalidYamlFile } from '../utils'
18-
import { ComponentType, WorkflowMode } from './types'
18+
import { ComponentType, WorkflowMode } from '../messageHandlers/types'
1919
import { isLocalDev, localhost, cdn } from '../constants/webviewResources'
2020

2121
let clientId = ''

0 commit comments

Comments
 (0)