Skip to content

Commit 624740f

Browse files
fix(stepfunctions): Remove and replace legacy render graph commands with workflow studio (aws#6649)
## Problem After [this PR](aws#6511) removing the legacy graph, there were still some components of the old graph which were not removed/replaced properly causing some bugs: 1. `aws.previewStateMachine` command in command palette has an invalid translation. 2. `aws.previewStateMachine` command throws an error when used from the command palette. 3. `aws.stepfunctions.openWithWorkflowStudio` command (which is used for opening WFS with the context menu) throws an error when used from the command palette. 4. Render graph option `aws.renderStateMachineGraph` in the AWS explorer for state machines throws an error. ## Solution 1. Replace `previewStateMachine` translation with `openWithWorkflowStudio`. 2. Use the document URI instead of the document in the `previewStateMachine` command when passing to `vscode.openWith`. 3. Disable `aws.stepfunctions.openWithWorkflowStudio` in the command palette (The `aws.previewStateMachine` command already works). 4. Remove `aws.renderStateMachineGraph`, and just re-use `previewStateMachine` for the explorer nodes as well. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Anthony Ting <[email protected]>
2 parents aa66793 + bbeefae commit 624740f

File tree

7 files changed

+30
-31
lines changed

7 files changed

+30
-31
lines changed

packages/core/package.nls.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@
172172
"AWS.command.viewSchemaItem": "View Schema",
173173
"AWS.command.searchSchema": "Search Schemas",
174174
"AWS.command.executeStateMachine": "Start Execution...",
175-
"AWS.command.renderStateMachineGraph": "Render graph",
176175
"AWS.command.copyArn": "Copy ARN",
177176
"AWS.command.copyName": "Copy Name",
178177
"AWS.command.openAwsConsole": "Go to AWS management console",

packages/core/src/awsexplorer/activation.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,6 @@ async function registerAwsExplorerCommands(
190190
'aws.executeStateMachine',
191191
async (node: StateMachineNode) => await executeStateMachine(context, node)
192192
),
193-
Commands.register(
194-
'aws.renderStateMachineGraph',
195-
async (node: StateMachineNode) =>
196-
await downloadStateMachineDefinition({
197-
stateMachineNode: node,
198-
outputChannel: toolkitOutputChannel,
199-
isPreviewAndRender: true,
200-
})
201-
),
202193
Commands.register('aws.copyArn', async (node: AWSResourceNode | TreeNode) => {
203194
const sourceNode = getSourceNode<AWSResourceNode>(node)
204195
await copyTextCommand(sourceNode, 'ARN')

packages/core/src/stepFunctions/activation.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { telemetry } from '../shared/telemetry/telemetry'
2323
import { PerfLog } from '../shared/logger/perfLogger'
2424
import { ASLLanguageClient } from './asl/client'
2525
import { WorkflowStudioEditorProvider } from './workflowStudio/workflowStudioEditorProvider'
26+
import { StateMachineNode } from './explorer/stepFunctionsNodes'
27+
import { downloadStateMachineDefinition } from './commands/downloadStateMachineDefinition'
2628

2729
/**
2830
* Activate Step Functions related functionality for the extension.
@@ -56,16 +58,24 @@ export async function activate(
5658

5759
export const previewStateMachineCommand = Commands.declare(
5860
'aws.previewStateMachine',
59-
() => async (arg?: vscode.TextEditor | vscode.Uri) => {
61+
() => async (arg?: vscode.TextEditor | vscode.Uri | StateMachineNode) => {
6062
await telemetry.run('stepfunctions_previewstatemachine', async () => {
63+
if (arg instanceof StateMachineNode) {
64+
return downloadStateMachineDefinition({
65+
stateMachineNode: arg,
66+
outputChannel: globals.outputChannel,
67+
isPreviewAndRender: true,
68+
})
69+
}
70+
6171
arg ??= vscode.window.activeTextEditor
62-
const input = arg instanceof vscode.Uri ? arg : arg?.document
72+
const input = arg instanceof vscode.Uri ? arg : arg?.document.uri
6373

6474
if (!input) {
6575
throw new ToolkitError('No active text editor or document found')
6676
}
6777

68-
await vscode.commands.executeCommand('vscode.openWith', input, WorkflowStudioEditorProvider.viewType, {
78+
await WorkflowStudioEditorProvider.openWithWorkflowStudio(input, {
6979
preserveFocus: true,
7080
viewColumn: vscode.ViewColumn.Beside,
7181
})

packages/core/src/stepFunctions/commands/downloadStateMachineDefinition.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import { DefaultStepFunctionsClient, StepFunctionsClient } from '../../shared/cl
1515
import { getLogger, Logger } from '../../shared/logger/logger'
1616
import { Result } from '../../shared/telemetry/telemetry'
1717
import { StateMachineNode } from '../explorer/stepFunctionsNodes'
18-
import { previewStateMachineCommand } from '../activation'
1918
import { telemetry } from '../../shared/telemetry/telemetry'
2019
import { fs } from '../../shared/fs/fs'
20+
import { WorkflowStudioEditorProvider } from '../workflowStudio/workflowStudioEditorProvider'
2121

2222
export async function downloadStateMachineDefinition(params: {
2323
outputChannel: vscode.OutputChannel
@@ -40,7 +40,10 @@ export async function downloadStateMachineDefinition(params: {
4040
})
4141

4242
const textEditor = await vscode.window.showTextDocument(doc)
43-
await previewStateMachineCommand.execute(textEditor)
43+
await WorkflowStudioEditorProvider.openWithWorkflowStudio(textEditor.document.uri, {
44+
preserveFocus: true,
45+
viewColumn: vscode.ViewColumn.Beside,
46+
})
4447
} else {
4548
const wsPath = vscode.workspace.workspaceFolders
4649
? vscode.workspace.workspaceFolders[0].uri.fsPath

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function activate(): Promise<void> {
1717
// Open the file with Workflow Studio editor in a new tab, or focus on the tab with WFS if it is already open
1818
globals.context.subscriptions.push(
1919
Commands.register('aws.stepfunctions.openWithWorkflowStudio', async (uri: vscode.Uri) => {
20-
await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType)
20+
await WorkflowStudioEditorProvider.openWithWorkflowStudio(uri)
2121
})
2222
)
2323

@@ -26,7 +26,7 @@ export async function activate(): Promise<void> {
2626
globals.context.subscriptions.push(
2727
Commands.register('aws.stepfunctions.switchToWorkflowStudio', async (uri: vscode.Uri) => {
2828
await vscode.commands.executeCommand('workbench.action.closeActiveEditor')
29-
await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType)
29+
await WorkflowStudioEditorProvider.openWithWorkflowStudio(uri)
3030
})
3131
)
3232
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ let clientId = ''
3131
export class WorkflowStudioEditorProvider implements vscode.CustomTextEditorProvider {
3232
public static readonly viewType = 'workflowStudio.asl'
3333

34+
public static async openWithWorkflowStudio(
35+
uri: vscode.Uri,
36+
params?: Parameters<typeof vscode.window.createWebviewPanel>[2]
37+
) {
38+
await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType, params)
39+
}
40+
3441
/**
3542
* Registers a new custom editor provider for asl files.
3643
* @remarks This should only be called once per extension.

packages/toolkit/package.json

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@
11871187
"when": "false"
11881188
},
11891189
{
1190-
"command": "aws.renderStateMachineGraph",
1190+
"command": "aws.stepfunctions.openWithWorkflowStudio",
11911191
"when": "false"
11921192
},
11931193
{
@@ -1686,7 +1686,7 @@
16861686
"group": "0@1"
16871687
},
16881688
{
1689-
"command": "aws.renderStateMachineGraph",
1689+
"command": "aws.previewStateMachine",
16901690
"when": "view == aws.explorer && viewItem == awsStateMachineNode",
16911691
"group": "0@2"
16921692
},
@@ -3103,17 +3103,6 @@
31033103
}
31043104
}
31053105
},
3106-
{
3107-
"command": "aws.renderStateMachineGraph",
3108-
"title": "%AWS.command.renderStateMachineGraph%",
3109-
"enablement": "isCloud9 || !aws.isWebExtHost",
3110-
"category": "%AWS.title%",
3111-
"cloud9": {
3112-
"cn": {
3113-
"category": "%AWS.title.cn%"
3114-
}
3115-
}
3116-
},
31173106
{
31183107
"command": "aws.copyArn",
31193108
"title": "%AWS.command.copyArn%",
@@ -3343,7 +3332,7 @@
33433332
},
33443333
{
33453334
"command": "aws.previewStateMachine",
3346-
"title": "%AWS.command.stepFunctions.previewStateMachine%",
3335+
"title": "%AWS.command.stepFunctions.openWithWorkflowStudio%",
33473336
"category": "%AWS.title%",
33483337
"enablement": "isCloud9 || !aws.isWebExtHost",
33493338
"icon": "$(aws-stepfunctions-preview)",

0 commit comments

Comments
 (0)