Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 0 additions & 9 deletions packages/core/src/awsexplorer/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AWSResourceNode>(node)
await copyTextCommand(sourceNode, 'ARN')
Expand Down
14 changes: 12 additions & 2 deletions packages/core/src/stepFunctions/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -56,10 +58,18 @@ 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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +40,15 @@ export async function downloadStateMachineDefinition(params: {
})

const textEditor = await vscode.window.showTextDocument(doc)
await previewStateMachineCommand.execute(textEditor)
await vscode.commands.executeCommand(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing something but why can't you use the previewStateMachienCommand.execute here still? You should be able to pass in the URI now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it may be helpful to enhance openTextDocument as needed:

export async function openTextDocument(filenameGlob: vscode.GlobPattern): Promise<vscode.TextDocument | undefined> {

instead of calling 'vscode.openWith' directly. That allows us to (potentially) instrument that or improve it in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing something but why can't you use the previewStateMachienCommand.execute here still? You should be able to pass in the URI now

I initially tried to use previewStateMachineCommand.execute directly, however since I now call downloadStateMachineDefinition directly in the previewStateMachineCommand, it creates a circular dependency which fails the build.

Also, it may be helpful to enhance openTextDocument as needed:

export async function openTextDocument(filenameGlob: vscode.GlobPattern): Promise<vscode.TextDocument | undefined> {

instead of calling 'vscode.openWith' directly. That allows us to (potentially) instrument that or improve it in the future.

I think openTextDocument is not quite the interface we want to use/overload, since it seems to primarily be used for searching for a file to open, while in this case we want to open a specific URI.

I can instead refactor out vscode.openWith(uri, WorkflowStudioEditorProvider.viewType, ...) however, since we have been repeating that pattern a few times.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can instead refactor out vscode.openWith(uri, WorkflowStudioEditorProvider.viewType, ...) however, since we have been repeating that pattern a few times.

🚀

'vscode.openWith',
textEditor.document.uri,
WorkflowStudioEditorProvider.viewType,
{
preserveFocus: true,
viewColumn: vscode.ViewColumn.Beside,
}
)
} else {
const wsPath = vscode.workspace.workspaceFolders
? vscode.workspace.workspaceFolders[0].uri.fsPath
Expand Down
17 changes: 3 additions & 14 deletions packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@
"when": "false"
},
{
"command": "aws.renderStateMachineGraph",
"command": "aws.stepfunctions.openWithWorkflowStudio",
"when": "false"
},
{
Expand Down Expand Up @@ -1686,7 +1686,7 @@
"group": "0@1"
},
{
"command": "aws.renderStateMachineGraph",
"command": "aws.previewStateMachine",
"when": "view == aws.explorer && viewItem == awsStateMachineNode",
"group": "0@2"
},
Expand Down Expand Up @@ -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%",
Expand Down Expand Up @@ -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)",
Expand Down