Skip to content

Commit f474f14

Browse files
authored
Merge pull request aws#6709 from aws/feature/stepfunctions-workflow
Merge feature/stepfunctions-workflow branch into master
2 parents e086fe2 + 66d7bdb commit f474f14

26 files changed

+1173
-604
lines changed

packages/core/package.nls.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"AWS.stepFunctions.executeStateMachine.error.failedToStart": "There was an error starting execution for '{0}', check AWS Toolkit logs for more information.",
3535
"AWS.stepFunctions.asl.format.enable.desc": "Enables the default formatter used with Amazon States Language files",
3636
"AWS.stepFunctions.asl.maxItemsComputed.desc": "The maximum number of outline symbols and folding regions computed (limited for performance reasons).",
37+
"AWS.stepFunctions.workflowStudio.actions.progressMessage": "Opening asl file in Workflow Studio",
38+
"AWS.stepFunctions.workflowStudio.actions.saveSuccessMessage": "{0} has been saved",
39+
"AWS.stepFunctions.workflowStudio.actions.InvalidJSONContent": "The Workflow Studio editor was not opened because the JSON in the file is invalid. To access Workflow Studio, please fix the JSON and manually reopen the integration.",
40+
"AWS.stepFunctions.workflowStudio.actions.InvalidYAMLContent": "The Workflow Studio editor was not opened because the YAML in the file is invalid. To access Workflow Studio, please fix the YAML and manually reopen the integration.",
41+
"AWS.stepFunctions.workflowStudio.actions.webviewFetchFailed": "Failed to load Workflow Studio editor. Please check your network connection and try again.",
3742
"AWS.configuration.description.awssam.debug.api": "API Gateway configuration",
3843
"AWS.configuration.description.awssam.debug.api.clientCertId": "The API Gateway client certificate ID",
3944
"AWS.configuration.description.awssam.debug.api.headers": "Additional HTTP headers",
@@ -177,7 +182,6 @@
177182
"AWS.command.viewSchemaItem": "View Schema",
178183
"AWS.command.searchSchema": "Search Schemas",
179184
"AWS.command.executeStateMachine": "Start Execution...",
180-
"AWS.command.renderStateMachineGraph": "Render graph",
181185
"AWS.command.copyArn": "Copy ARN",
182186
"AWS.command.copyName": "Copy Name",
183187
"AWS.command.openAwsConsole": "Go to AWS management console",
@@ -219,7 +223,7 @@
219223
"AWS.command.s3.uploadFileToParent": "Upload to Parent...",
220224
"AWS.command.stepFunctions.createStateMachineFromTemplate": "Create a new Step Functions state machine",
221225
"AWS.command.stepFunctions.publishStateMachine": "Publish state machine to Step Functions",
222-
"AWS.command.stepFunctions.previewStateMachine": "Render state machine graph",
226+
"AWS.command.stepFunctions.openWithWorkflowStudio": "Open with Workflow Studio",
223227
"AWS.command.cdk.previewStateMachine": "Render state machine graph from CDK application",
224228
"AWS.command.copyLogResource": "Copy Log Stream or Group",
225229
"AWS.command.saveCurrentLogDataContent": "Save Log to File",

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/extensionNode.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { activate as activateS3 } from './awsService/s3/activation'
2828
import * as filetypes from './shared/filetypes'
2929
import { activate as activateApiGateway } from './awsService/apigateway/activation'
3030
import { activate as activateStepFunctions } from './stepFunctions/activation'
31+
import { activate as activateStepFunctionsWorkflowStudio } from './stepFunctions/workflowStudio/activation'
3132
import { activate as activateSsmDocument } from './ssmDocument/activation'
3233
import { activate as activateDynamicResources } from './dynamicResources/activation'
3334
import { activate as activateEcs } from './awsService/ecs/activation'
@@ -198,6 +199,8 @@ export async function activate(context: vscode.ExtensionContext) {
198199

199200
await activateStepFunctions(context, globals.awsContext, globals.outputChannel)
200201

202+
await activateStepFunctionsWorkflowStudio()
203+
201204
await activateRedshift(extContext)
202205

203206
await activateAppBuilder(extContext)

packages/core/src/feedback/vue/submitFeedback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class FeedbackWebview extends VueWebview {
7171
}
7272
}
7373

74-
type FeedbackId = 'AWS Toolkit' | 'Amazon Q' | 'Infrastructure Composer' | 'Threat Composer'
74+
type FeedbackId = 'AWS Toolkit' | 'Amazon Q' | 'Infrastructure Composer' | 'Threat Composer' | 'Workflow Studio'
7575

7676
let _submitFeedback:
7777
| RegisteredCommand<(_: VsCodeCommandArg, id: FeedbackId, commentData?: string) => Promise<void>>

packages/core/src/shared/clients/stepFunctionsClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ export class DefaultStepFunctionsClient {
6767
return client.updateStateMachine(params).promise()
6868
}
6969

70+
public async testState(params: StepFunctions.TestStateInput): Promise<StepFunctions.TestStateOutput> {
71+
const client = await this.createSdkClient()
72+
73+
return await client.testState(params).promise()
74+
}
75+
7076
private async createSdkClient(): Promise<StepFunctions> {
7177
return await globals.sdkClientBuilder.createAwsService(StepFunctions, undefined, this.regionCode)
7278
}

packages/core/src/shared/logger/logger.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55

66
import * as vscode from 'vscode'
77

8-
export type LogTopic = 'crashMonitoring' | 'dev/beta' | 'notifications' | 'test' | 'childProcess' | 'unknown' | 'chat'
8+
export type LogTopic =
9+
| 'crashMonitoring'
10+
| 'dev/beta'
11+
| 'notifications'
12+
| 'test'
13+
| 'childProcess'
14+
| 'unknown'
15+
| 'chat'
16+
| 'stepfunctions'
917

1018
class ErrorLog {
1119
constructor(

packages/core/src/shared/telemetry/vscodeTelemetry.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"allowedValues": ["Create", "Update"],
2323
"description": "SSM Publish Document operation type"
2424
},
25+
{
26+
"name": "isInvalidJson",
27+
"type": "boolean",
28+
"description": "Indicates whether the message contains an invalid JSON definition."
29+
},
2530
{
2631
"name": "starterTemplate",
2732
"type": "string",
@@ -575,6 +580,47 @@
575580
"name": "stepfunctions_previewstatemachine",
576581
"description": ""
577582
},
583+
{
584+
"name": "stepfunctions_openWorkflowStudio",
585+
"description": "Called after opening asl file in Step Functions Workflow Studio",
586+
"metadata": [
587+
{
588+
"type": "id",
589+
"required": true
590+
}
591+
]
592+
},
593+
{
594+
"name": "stepfunctions_closeWorkflowStudio",
595+
"description": "Called after closing Step Functions Workflow Studio custom editor",
596+
"metadata": [
597+
{
598+
"type": "id",
599+
"required": true
600+
}
601+
]
602+
},
603+
{
604+
"name": "stepfunctions_saveFile",
605+
"description": "Triggered when Workflow Studio auto-syncs to the local file or when unsaved local changes are saved from Workflow Studio or VSCode.",
606+
"metadata": [
607+
{
608+
"type": "id",
609+
"required": true
610+
},
611+
{
612+
"type": "saveType",
613+
"required": true
614+
},
615+
{
616+
"type": "source",
617+
"required": true
618+
},
619+
{
620+
"type": "isInvalidJson"
621+
}
622+
]
623+
},
578624
{
579625
"name": "vscode_activeRegions",
580626
"description": "Record the number of active regions at startup and when regions are added/removed",

packages/core/src/shared/vscode/setContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type contextKey =
2525
| 'aws.explorer.showAuthView'
2626
| 'aws.toolkit.amazonq.dismissed'
2727
| 'aws.toolkit.amazonqInstall.dismissed'
28+
| 'aws.stepFunctions.isWorkflowStudioFocused'
2829
| 'aws.toolkit.notifications.show'
2930
// Deprecated/legacy names. New keys should start with "aws.".
3031
| 'codewhisperer.activeLine'

packages/core/src/stepFunctions/activation.ts

Lines changed: 24 additions & 21 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,9 @@ 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'
26+
import { StateMachineNode } from './explorer/stepFunctionsNodes'
27+
import { downloadStateMachineDefinition } from './commands/downloadStateMachineDefinition'
2628

2729
/**
2830
* Activate Step Functions related functionality for the extension.
@@ -54,28 +56,30 @@ export async function activate(
5456
}
5557
}
5658

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-
*/
6359
export const previewStateMachineCommand = Commands.declare(
6460
'aws.previewStateMachine',
65-
(manager: AslVisualizationManager) => async (arg?: vscode.TextEditor | vscode.Uri) => {
66-
try {
61+
() => async (arg?: vscode.TextEditor | vscode.Uri | StateMachineNode) => {
62+
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+
6771
arg ??= vscode.window.activeTextEditor
68-
const input = arg instanceof vscode.Uri ? arg : arg?.document
72+
const input = arg instanceof vscode.Uri ? arg : arg?.document.uri
6973

7074
if (!input) {
7175
throw new ToolkitError('No active text editor or document found')
7276
}
7377

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-
}
78+
await WorkflowStudioEditorProvider.openWithWorkflowStudio(input, {
79+
preserveFocus: true,
80+
viewColumn: vscode.ViewColumn.Beside,
81+
})
82+
})
7983
}
8084
)
8185

@@ -84,11 +88,10 @@ async function registerStepFunctionCommands(
8488
awsContext: AwsContext,
8589
outputChannel: vscode.OutputChannel
8690
): Promise<void> {
87-
const visualizationManager = new AslVisualizationManager(extensionContext)
8891
const cdkVisualizationManager = new AslVisualizationCDKManager(extensionContext)
8992

9093
extensionContext.subscriptions.push(
91-
previewStateMachineCommand.register(visualizationManager),
94+
previewStateMachineCommand.register(),
9295
renderCdkStateMachineGraph.register(cdkVisualizationManager),
9396
Commands.register('aws.stepfunctions.createStateMachineFromTemplate', async () => {
9497
try {
@@ -144,8 +147,8 @@ function initializeCodeLens(context: vscode.ExtensionContext) {
144147
public async provideCodeLenses(document: vscode.TextDocument): Promise<vscode.CodeLens[]> {
145148
const topOfDocument = new vscode.Range(0, 0, 0, 0)
146149

147-
const renderCodeLens = previewStateMachineCommand.build().asCodeLens(topOfDocument, {
148-
title: localize('AWS.stepFunctions.render', 'Render graph'),
150+
const openCustomEditor = previewStateMachineCommand.build(document.uri).asCodeLens(topOfDocument, {
151+
title: localize('AWS.command.stepFunctions.openWithWorkflowStudio', 'Open with Workflow Studio'),
149152
})
150153

151154
if (ASL_FORMATS.includes(document.languageId)) {
@@ -155,9 +158,9 @@ function initializeCodeLens(context: vscode.ExtensionContext) {
155158
}
156159
const publishCodeLens = new vscode.CodeLens(topOfDocument, publishCommand)
157160

158-
return [publishCodeLens, renderCodeLens]
161+
return [publishCodeLens, openCustomEditor]
159162
} else {
160-
return [renderCodeLens]
163+
return [openCustomEditor]
161164
}
162165
}
163166
}

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

0 commit comments

Comments
 (0)