diff --git a/packages/core/package.nls.json b/packages/core/package.nls.json index 95bac7bb14b..811e56f0842 100644 --- a/packages/core/package.nls.json +++ b/packages/core/package.nls.json @@ -172,7 +172,6 @@ "AWS.command.viewSchemaItem": "View Schema", "AWS.command.searchSchema": "Search Schemas", "AWS.command.executeStateMachine": "Start Execution...", - "AWS.command.renderStateMachineGraph": "Render graph", "AWS.command.copyArn": "Copy ARN", "AWS.command.copyName": "Copy Name", "AWS.command.openAwsConsole": "Go to AWS management console", diff --git a/packages/core/src/awsexplorer/activation.ts b/packages/core/src/awsexplorer/activation.ts index 4452648019e..f904658fcaa 100644 --- a/packages/core/src/awsexplorer/activation.ts +++ b/packages/core/src/awsexplorer/activation.ts @@ -190,15 +190,6 @@ async function registerAwsExplorerCommands( 'aws.executeStateMachine', async (node: StateMachineNode) => await executeStateMachine(context, node) ), - Commands.register( - 'aws.renderStateMachineGraph', - async (node: StateMachineNode) => - await downloadStateMachineDefinition({ - stateMachineNode: node, - outputChannel: toolkitOutputChannel, - isPreviewAndRender: true, - }) - ), Commands.register('aws.copyArn', async (node: AWSResourceNode | TreeNode) => { const sourceNode = getSourceNode(node) await copyTextCommand(sourceNode, 'ARN') diff --git a/packages/core/src/stepFunctions/activation.ts b/packages/core/src/stepFunctions/activation.ts index ead11fe0822..7d8107b8119 100644 --- a/packages/core/src/stepFunctions/activation.ts +++ b/packages/core/src/stepFunctions/activation.ts @@ -23,6 +23,8 @@ import { telemetry } from '../shared/telemetry/telemetry' import { PerfLog } from '../shared/logger/perfLogger' import { ASLLanguageClient } from './asl/client' import { WorkflowStudioEditorProvider } from './workflowStudio/workflowStudioEditorProvider' +import { StateMachineNode } from './explorer/stepFunctionsNodes' +import { downloadStateMachineDefinition } from './commands/downloadStateMachineDefinition' /** * Activate Step Functions related functionality for the extension. @@ -56,16 +58,24 @@ export async function activate( export const previewStateMachineCommand = Commands.declare( 'aws.previewStateMachine', - () => async (arg?: vscode.TextEditor | vscode.Uri) => { + () => async (arg?: vscode.TextEditor | vscode.Uri | StateMachineNode) => { await telemetry.run('stepfunctions_previewstatemachine', async () => { + if (arg instanceof StateMachineNode) { + return downloadStateMachineDefinition({ + stateMachineNode: arg, + outputChannel: globals.outputChannel, + isPreviewAndRender: true, + }) + } + arg ??= vscode.window.activeTextEditor - const input = arg instanceof vscode.Uri ? arg : arg?.document + const input = arg instanceof vscode.Uri ? arg : arg?.document.uri if (!input) { throw new ToolkitError('No active text editor or document found') } - await vscode.commands.executeCommand('vscode.openWith', input, WorkflowStudioEditorProvider.viewType, { + await WorkflowStudioEditorProvider.openWithWorkflowStudio(input, { preserveFocus: true, viewColumn: vscode.ViewColumn.Beside, }) diff --git a/packages/core/src/stepFunctions/commands/downloadStateMachineDefinition.ts b/packages/core/src/stepFunctions/commands/downloadStateMachineDefinition.ts index b3fdc2edb83..f26fc8a793b 100644 --- a/packages/core/src/stepFunctions/commands/downloadStateMachineDefinition.ts +++ b/packages/core/src/stepFunctions/commands/downloadStateMachineDefinition.ts @@ -15,9 +15,9 @@ import { DefaultStepFunctionsClient, StepFunctionsClient } from '../../shared/cl import { getLogger, Logger } from '../../shared/logger/logger' import { Result } from '../../shared/telemetry/telemetry' import { StateMachineNode } from '../explorer/stepFunctionsNodes' -import { previewStateMachineCommand } from '../activation' import { telemetry } from '../../shared/telemetry/telemetry' import { fs } from '../../shared/fs/fs' +import { WorkflowStudioEditorProvider } from '../workflowStudio/workflowStudioEditorProvider' export async function downloadStateMachineDefinition(params: { outputChannel: vscode.OutputChannel @@ -40,7 +40,10 @@ export async function downloadStateMachineDefinition(params: { }) const textEditor = await vscode.window.showTextDocument(doc) - await previewStateMachineCommand.execute(textEditor) + await WorkflowStudioEditorProvider.openWithWorkflowStudio(textEditor.document.uri, { + preserveFocus: true, + viewColumn: vscode.ViewColumn.Beside, + }) } else { const wsPath = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath diff --git a/packages/core/src/stepFunctions/workflowStudio/activation.ts b/packages/core/src/stepFunctions/workflowStudio/activation.ts index d57a768a835..74bcc24e65c 100644 --- a/packages/core/src/stepFunctions/workflowStudio/activation.ts +++ b/packages/core/src/stepFunctions/workflowStudio/activation.ts @@ -17,7 +17,7 @@ export async function activate(): Promise { // Open the file with Workflow Studio editor in a new tab, or focus on the tab with WFS if it is already open globals.context.subscriptions.push( Commands.register('aws.stepfunctions.openWithWorkflowStudio', async (uri: vscode.Uri) => { - await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType) + await WorkflowStudioEditorProvider.openWithWorkflowStudio(uri) }) ) @@ -26,7 +26,7 @@ export async function activate(): Promise { globals.context.subscriptions.push( Commands.register('aws.stepfunctions.switchToWorkflowStudio', async (uri: vscode.Uri) => { await vscode.commands.executeCommand('workbench.action.closeActiveEditor') - await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType) + await WorkflowStudioEditorProvider.openWithWorkflowStudio(uri) }) ) } diff --git a/packages/core/src/stepFunctions/workflowStudio/workflowStudioEditorProvider.ts b/packages/core/src/stepFunctions/workflowStudio/workflowStudioEditorProvider.ts index ae43dd85dfa..9d8748db589 100644 --- a/packages/core/src/stepFunctions/workflowStudio/workflowStudioEditorProvider.ts +++ b/packages/core/src/stepFunctions/workflowStudio/workflowStudioEditorProvider.ts @@ -31,6 +31,13 @@ let clientId = '' export class WorkflowStudioEditorProvider implements vscode.CustomTextEditorProvider { public static readonly viewType = 'workflowStudio.asl' + public static async openWithWorkflowStudio( + uri: vscode.Uri, + params?: Parameters[2] + ) { + await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType, params) + } + /** * Registers a new custom editor provider for asl files. * @remarks This should only be called once per extension. diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index fade6a829b3..42f4b9089a9 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -1187,7 +1187,7 @@ "when": "false" }, { - "command": "aws.renderStateMachineGraph", + "command": "aws.stepfunctions.openWithWorkflowStudio", "when": "false" }, { @@ -1686,7 +1686,7 @@ "group": "0@1" }, { - "command": "aws.renderStateMachineGraph", + "command": "aws.previewStateMachine", "when": "view == aws.explorer && viewItem == awsStateMachineNode", "group": "0@2" }, @@ -3103,17 +3103,6 @@ } } }, - { - "command": "aws.renderStateMachineGraph", - "title": "%AWS.command.renderStateMachineGraph%", - "enablement": "isCloud9 || !aws.isWebExtHost", - "category": "%AWS.title%", - "cloud9": { - "cn": { - "category": "%AWS.title.cn%" - } - } - }, { "command": "aws.copyArn", "title": "%AWS.command.copyArn%", @@ -3343,7 +3332,7 @@ }, { "command": "aws.previewStateMachine", - "title": "%AWS.command.stepFunctions.previewStateMachine%", + "title": "%AWS.command.stepFunctions.openWithWorkflowStudio%", "category": "%AWS.title%", "enablement": "isCloud9 || !aws.isWebExtHost", "icon": "$(aws-stepfunctions-preview)",