Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 13 additions & 3 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,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,
})
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,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
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/stepFunctions/workflowStudio/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function activate(): Promise<void> {
// 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)
})
)

Expand All @@ -26,7 +26,7 @@ export async function activate(): Promise<void> {
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)
})
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof vscode.window.createWebviewPanel>[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.
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