Skip to content

Commit c89fd8a

Browse files
authored
feat(stepfunctions): previewStateMachine opens in Workflow Studio #6511
## Problem The preview state machine command (used in an icon button and a code lens button) consists of a read-only graph component which provides a simple graph representation of an ASL definition. It does not include any other information such as state types or resources. ## Solution Replace the graph visualization in the previewStateMachine command with the Workflow Studio graph and editor. Workflow Studio is editable and includes icons and descriptions representing the state types and resources. Users will now be able to edit the state definition in the graph visualization directly.
1 parent 27f3d82 commit c89fd8a

File tree

6 files changed

+16
-579
lines changed

6 files changed

+16
-579
lines changed

packages/core/package.nls.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@
212212
"AWS.command.s3.uploadFileToParent": "Upload to Parent...",
213213
"AWS.command.stepFunctions.createStateMachineFromTemplate": "Create a new Step Functions state machine",
214214
"AWS.command.stepFunctions.publishStateMachine": "Publish state machine to Step Functions",
215-
"AWS.command.stepFunctions.previewStateMachine": "Render state machine graph",
216215
"AWS.command.stepFunctions.openWithWorkflowStudio": "Open with Workflow Studio",
217216
"AWS.command.cdk.previewStateMachine": "Render state machine graph from CDK application",
218217
"AWS.command.copyLogResource": "Copy Log Stream or Group",

packages/core/src/stepFunctions/activation.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import * as vscode from 'vscode'
1313
import { AwsContext } from '../shared/awsContext'
1414
import { createStateMachineFromTemplate } from './commands/createStateMachineFromTemplate'
1515
import { publishStateMachine } from './commands/publishStateMachine'
16-
import { AslVisualizationManager } from './commands/visualizeStateMachine/aslVisualizationManager'
1716
import { Commands } from '../shared/vscode/commands2'
1817

1918
import { ASL_FORMATS, YAML_ASL, JSON_ASL } from './constants/aslFormats'
@@ -23,6 +22,7 @@ import { ToolkitError } from '../shared/errors'
2322
import { telemetry } from '../shared/telemetry/telemetry'
2423
import { PerfLog } from '../shared/logger/perfLogger'
2524
import { ASLLanguageClient } from './asl/client'
25+
import { WorkflowStudioEditorProvider } from './workflowStudio/workflowStudioEditorProvider'
2626

2727
/**
2828
* Activate Step Functions related functionality for the extension.
@@ -54,28 +54,22 @@ export async function activate(
5454
}
5555
}
5656

57-
/*
58-
* TODO: Determine behaviour when command is run against bad input, or
59-
* non-json files. Determine if we want to limit the command to only a
60-
* specifc subset of file types ( .json only, custom .states extension, etc...)
61-
* Ensure tests are written for this use case as well.
62-
*/
6357
export const previewStateMachineCommand = Commands.declare(
6458
'aws.previewStateMachine',
65-
(manager: AslVisualizationManager) => async (arg?: vscode.TextEditor | vscode.Uri) => {
66-
try {
59+
() => async (arg?: vscode.TextEditor | vscode.Uri) => {
60+
await telemetry.run('stepfunctions_previewstatemachine', async () => {
6761
arg ??= vscode.window.activeTextEditor
6862
const input = arg instanceof vscode.Uri ? arg : arg?.document
6963

7064
if (!input) {
7165
throw new ToolkitError('No active text editor or document found')
7266
}
7367

74-
return await manager.visualizeStateMachine(input)
75-
} finally {
76-
// TODO: Consider making the metric reflect the success/failure of the above call
77-
telemetry.stepfunctions_previewstatemachine.emit()
78-
}
68+
await vscode.commands.executeCommand('vscode.openWith', input, WorkflowStudioEditorProvider.viewType, {
69+
preserveFocus: true,
70+
viewColumn: vscode.ViewColumn.Beside,
71+
})
72+
})
7973
}
8074
)
8175

@@ -84,11 +78,10 @@ async function registerStepFunctionCommands(
8478
awsContext: AwsContext,
8579
outputChannel: vscode.OutputChannel
8680
): Promise<void> {
87-
const visualizationManager = new AslVisualizationManager(extensionContext)
8881
const cdkVisualizationManager = new AslVisualizationCDKManager(extensionContext)
8982

9083
extensionContext.subscriptions.push(
91-
previewStateMachineCommand.register(visualizationManager),
84+
previewStateMachineCommand.register(),
9285
renderCdkStateMachineGraph.register(cdkVisualizationManager),
9386
Commands.register('aws.stepfunctions.createStateMachineFromTemplate', async () => {
9487
try {
@@ -144,15 +137,8 @@ function initializeCodeLens(context: vscode.ExtensionContext) {
144137
public async provideCodeLenses(document: vscode.TextDocument): Promise<vscode.CodeLens[]> {
145138
const topOfDocument = new vscode.Range(0, 0, 0, 0)
146139

147-
const openCustomEditorCommand: vscode.Command = {
148-
command: 'aws.stepfunctions.switchToWorkflowStudio',
140+
const openCustomEditor = previewStateMachineCommand.build(document.uri).asCodeLens(topOfDocument, {
149141
title: localize('AWS.command.stepFunctions.openWithWorkflowStudio', 'Open with Workflow Studio'),
150-
arguments: [document.uri],
151-
}
152-
const openCustomEditor = new vscode.CodeLens(topOfDocument, openCustomEditorCommand)
153-
154-
const renderCodeLens = previewStateMachineCommand.build().asCodeLens(topOfDocument, {
155-
title: localize('AWS.stepFunctions.render', 'Render graph'),
156142
})
157143

158144
if (ASL_FORMATS.includes(document.languageId)) {
@@ -162,9 +148,9 @@ function initializeCodeLens(context: vscode.ExtensionContext) {
162148
}
163149
const publishCodeLens = new vscode.CodeLens(topOfDocument, publishCommand)
164150

165-
return [openCustomEditor, publishCodeLens, renderCodeLens]
151+
return [publishCodeLens, openCustomEditor]
166152
} else {
167-
return [openCustomEditor, renderCodeLens]
153+
return [openCustomEditor]
168154
}
169155
}
170156
}

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

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)