Skip to content

Commit 21c1d28

Browse files
committed
feat(stepfunctions): Change previewStateMachine command to open with Workflow Studio
1 parent 5322be0 commit 21c1d28

File tree

6 files changed

+17
-580
lines changed

6 files changed

+17
-580
lines changed

packages/core/package.nls.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"AWS.configuration.description.suppressPrompts": "Prompts which ask for confirmation. Checking an item suppresses the prompt.",
2121
"AWS.configuration.enableCodeLenses": "Enable SAM hints in source code and template.yaml files",
2222
"AWS.configuration.description.resources.enabledResources": "AWS resources to display in the 'Resources' portion of the explorer.",
23-
"AWS.configuration.description.featureDevelopment.allowRunningCodeAndTests": "Allow /dev to run code and test commands",
23+
"AWS.configuration.description.featureDevelopment.allowRunningCodeAndTests": "Allow /dev to run code and test commands",
2424
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.",
2525
"AWS.stepFunctions.asl.format.enable.desc": "Enables the default formatter used with Amazon States Language files",
2626
"AWS.stepFunctions.asl.maxItemsComputed.desc": "The maximum number of outline symbols and folding regions computed (limited for performance reasons).",
@@ -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)