Skip to content

Commit 590b319

Browse files
author
Vlad Nikolaenko
committed
feat(stepfunctions): Add a setting to opt out of WFS + minor integrations adjustments
1 parent fdc9324 commit 590b319

File tree

5 files changed

+50
-3
lines changed

5 files changed

+50
-3
lines changed

packages/core/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"AWS.stepFunctions.workflowStudio.actions.progressMessage": "Opening asl file in Workflow Studio",
2828
"AWS.stepFunctions.workflowStudio.actions.saveSuccessMessage": "{0} has been saved",
2929
"AWS.stepFunctions.workflowStudio.actions.invalidJson": "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.",
30+
"AWS.stepFunctions.workflowStudio.enable.desc": "Open Amazon States Language files in Workflow Studio by default.",
3031
"AWS.configuration.description.awssam.debug.api": "API Gateway configuration",
3132
"AWS.configuration.description.awssam.debug.api.clientCertId": "The API Gateway client certificate ID",
3233
"AWS.configuration.description.awssam.debug.api.headers": "Additional HTTP headers",

packages/core/src/shared/settings-toolkit.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const toolkitSettings = {
1919
"aws.samcli.legacyDeploy": {},
2020
"aws.telemetry": {},
2121
"aws.stepfunctions.asl.format.enable": {},
22+
"aws.stepfunctions.workflowStudio.enable": {},
2223
"aws.stepfunctions.asl.maxItemsComputed": {},
2324
"aws.ssmDocument.ssm.maxItemsComputed": {},
2425
"aws.cwl.limit": {},

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ 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 vscode.commands.executeCommand(
21+
'vscode.openWith',
22+
uri.with({ query: 'manual=true' }),
23+
WorkflowStudioEditorProvider.viewType
24+
)
2125
})
2226
)
2327

@@ -26,7 +30,11 @@ export async function activate(): Promise<void> {
2630
globals.context.subscriptions.push(
2731
Commands.register('aws.stepfunctions.switchToWorkflowStudio', async (uri: vscode.Uri) => {
2832
await vscode.commands.executeCommand('workbench.action.closeActiveEditor')
29-
await vscode.commands.executeCommand('vscode.openWith', uri, WorkflowStudioEditorProvider.viewType)
33+
await vscode.commands.executeCommand(
34+
'vscode.openWith',
35+
uri.with({ query: 'manual=true' }),
36+
WorkflowStudioEditorProvider.viewType
37+
)
3038
})
3139
)
3240
}

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { telemetry } from '../../shared/telemetry/telemetry'
1212
import globals from '../../shared/extensionGlobals'
1313
import { getRandomString, getStringHash } from '../../shared/utilities/textUtilities'
1414
import { ToolkitError } from '../../shared/errors'
15+
import { getTabSizeSetting } from '../../shared/utilities/editorUtilities'
1516
import { WorkflowStudioEditor } from './workflowStudioEditor'
1617
import { i18n } from '../../shared/i18n-helper'
1718
import { isInvalidJsonFile } from '../utils'
@@ -86,8 +87,9 @@ export class WorkflowStudioEditorProvider implements vscode.CustomTextEditorProv
8687
const localeTag = `<meta name='locale' content='${locale}'>`
8788
const theme = vscode.window.activeColorTheme.kind
8889
const isDarkMode = theme === vscode.ColorThemeKind.Dark || theme === vscode.ColorThemeKind.HighContrast
90+
const tabSizeTag = `<meta name='tab-size' content='${getTabSizeSetting()}'>`
8991
const darkModeTag = `<meta name='dark-mode' content='${isDarkMode}'>`
90-
let html = `${htmlFileSplit[0]} <head> ${baseTag} ${localeTag} ${darkModeTag} ${htmlFileSplit[1]}`
92+
let html = `${htmlFileSplit[0]} <head> ${baseTag} ${localeTag} ${darkModeTag} ${tabSizeTag} ${htmlFileSplit[1]}`
9193

9294
const nonce = getRandomString()
9395
htmlFileSplit = html.split("script-src 'self'")
@@ -115,6 +117,21 @@ export class WorkflowStudioEditorProvider implements vscode.CustomTextEditorProv
115117
_token: vscode.CancellationToken
116118
): Promise<void> {
117119
await telemetry.stepfunctions_openWorkflowStudio.run(async () => {
120+
// If the user opted out from Workflow Studio and this is not a manual open, launch default editor instead
121+
const autoOpenWFS = vscode.workspace.getConfiguration().get('aws.stepfunctions.workflowStudio.enable', true)
122+
const isManualAction = new URLSearchParams(document.uri.query).get('manual') === 'true'
123+
if (!autoOpenWFS && !isManualAction) {
124+
await vscode.commands.executeCommand('vscode.openWith', document.uri, 'default')
125+
webviewPanel.dispose()
126+
throw ToolkitError.chain(
127+
'User opted out',
128+
'The Workflow Studio editor was not opened because the user has opted out',
129+
{
130+
code: 'userOptOut',
131+
}
132+
)
133+
}
134+
118135
// For invalid JSON, open default editor and show warning message
119136
if (isInvalidJsonFile(document)) {
120137
await vscode.commands.executeCommand('vscode.openWith', document.uri, 'default')

packages/toolkit/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@
146146
"default": true,
147147
"description": "%AWS.stepFunctions.asl.format.enable.desc%"
148148
},
149+
"aws.stepfunctions.workflowStudio.enable": {
150+
"type": "boolean",
151+
"default": true,
152+
"description": "%AWS.stepFunctions.workflowStudio.enable.desc%"
153+
},
149154
"aws.stepfunctions.asl.maxItemsComputed": {
150155
"type": "number",
151156
"default": 5000,
@@ -1412,6 +1417,11 @@
14121417
"command": "aws.openInApplicationComposer",
14131418
"when": "isFileSystemResource && !(resourceFilename =~ /^.*\\.tc\\.json$/) && resourceFilename =~ /^.*\\.(json|yml|yaml|template)$/",
14141419
"group": "z_aws@1"
1420+
},
1421+
{
1422+
"command": "aws.stepfunctions.openWithWorkflowStudio",
1423+
"when": "isFileSystemResource && resourceFilename =~ /^.*\\.asl\\.(json|yml|yaml)$/",
1424+
"group": "z_aws@1"
14151425
}
14161426
],
14171427
"view/item/context": [
@@ -3838,6 +3848,16 @@
38383848
}
38393849
}
38403850
},
3851+
{
3852+
"command": "aws.stepfunctions.openWithWorkflowStudio",
3853+
"title": "%AWS.command.stepFunctions.openWithWorkflowStudio%",
3854+
"category": "%AWS.title%",
3855+
"cloud9": {
3856+
"cn": {
3857+
"category": "%AWS.title.cn%"
3858+
}
3859+
}
3860+
},
38413861
{
38423862
"command": "aws.createNewThreatComposer",
38433863
"title": "%AWS.command.threatComposer.createNew%",

0 commit comments

Comments
 (0)