From 858577fed59dd73d8d93947ce7f5af24921cecff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannick=20B=C3=A9ot?= Date: Fri, 20 Sep 2024 23:49:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20remove=20Worfklow=20tester=20vie?= =?UTF-8?q?w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 + package.json | 5 - src/commands/constants.ts | 1 - src/commands/workflow/testWorkflow.ts | 23 -- src/extension.ts | 9 - .../WorkflowTesterWebviewViewProvider.ts | 216 ------------------ 6 files changed, 2 insertions(+), 254 deletions(-) delete mode 100644 src/commands/workflow/testWorkflow.ts delete mode 100644 src/views/WorkflowTesterWebviewViewProvider.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index e48a9e9..0dc5bb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ This changelog is following the recommended format by [keepachangelog](https://k ### Removed +- Removed Workflow Tester view due to webview-ui-toolkit deprecation (cf. https://github.com/microsoft/vscode-webview-ui-toolkit/issues/561) + ## [1.3.2] - 2024-07-03 ### Added diff --git a/package.json b/package.json index a81268e..c7978fb 100644 --- a/package.json +++ b/package.json @@ -52,11 +52,6 @@ "id": "vscode-sailpoint-identitynow.view", "name": "Identity Security Cloud Tenants", "icon": "resources/isc.svg" - }, - { - "id": "vscode-sailpoint-identitynow.workflow.test-view", - "type": "webview", - "name": "Workflow tester" } ] }, diff --git a/src/commands/constants.ts b/src/commands/constants.ts index 3bca8dc..2ee6e92 100644 --- a/src/commands/constants.ts +++ b/src/commands/constants.ts @@ -60,7 +60,6 @@ export const SORT_IDENTITY_PROFILES_BY_NAME = `${COMMAND_PREFIX}.identity-profil export const SORT_IDENTITY_PROFILES_BY_PRIORITY = `${COMMAND_PREFIX}.identity-profiles.sort.priority`; export const REFRESH_IDENTITY_PROFILE = `${COMMAND_PREFIX}.identity-profile.refresh`; export const TREE_VIEW = `${COMMAND_PREFIX}.view`; -export const WORKFLOW_TESTER_VIEW = `${COMMAND_PREFIX}.workflow.test-view`; export const LOAD_MORE = `${COMMAND_PREFIX}.load-more`; diff --git a/src/commands/workflow/testWorkflow.ts b/src/commands/workflow/testWorkflow.ts deleted file mode 100644 index aad1754..0000000 --- a/src/commands/workflow/testWorkflow.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { WorkflowTreeItem } from '../../models/ISCTreeItem'; -import { WorkflowTesterWebviewViewProvider } from '../../views/WorkflowTesterWebviewViewProvider'; - - - -/** - * Command used to open a source or a transform - */ -export class TestWorkflowCommand { - - constructor(private readonly workflowTester: WorkflowTesterWebviewViewProvider) { - } - - async execute(node: WorkflowTreeItem,): Promise { - console.log("> testWorkflow", node); - if (node === undefined || !(node instanceof WorkflowTreeItem)) { - console.log("WARNING: testWorkflow: invalid item", node); - throw new Error("testWorkflow: invalid item"); - } - this.workflowTester.showWorkflow(node.tenantName, node.id); - console.log("< testWorkflow"); - } -} \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index 5c95833..c56af83 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -44,7 +44,6 @@ import { TransformEvaluator } from './services/TransformEvaluator'; import { TreeManager } from './services/TreeManager'; import { ISCUriHandler } from './ISCUriHandler'; import { ISCDataProvider } from './views/ISCDataProvider'; -import { WorkflowTesterWebviewViewProvider } from './views/WorkflowTesterWebviewViewProvider'; import { TestConnectionCommand } from './commands/source/TestConnectionCommand'; import { PeekSourceCommand } from './commands/source/PeekSourceCommand'; import { PingClusterCommand } from './commands/source/PingClusterCommand'; @@ -338,14 +337,6 @@ export function activate(context: vscode.ExtensionContext) { vscode.commands.registerCommand(commands.NEW_SCHEMA, newSchemaCommand.execute, newSchemaCommand)); - const workflowTester = new WorkflowTesterWebviewViewProvider(context, tenantService); - workflowTester.activate(); - - const testWorkflowCommand = new TestWorkflowCommand(workflowTester); - context.subscriptions.push( - vscode.commands.registerCommand(commands.TEST_WORKFLOW, - testWorkflowCommand.execute, testWorkflowCommand)); - const newConnectorRuleCommand = new ConnectorRuleCommand(tenantService); context.subscriptions.push( diff --git a/src/views/WorkflowTesterWebviewViewProvider.ts b/src/views/WorkflowTesterWebviewViewProvider.ts deleted file mode 100644 index 890823e..0000000 --- a/src/views/WorkflowTesterWebviewViewProvider.ts +++ /dev/null @@ -1,216 +0,0 @@ -import * as vscode from 'vscode'; -import * as commands from '../commands/constants'; -import { ISCClient } from '../services/ISCClient'; -import { TenantService } from '../services/TenantService'; -import { delay } from '../utils'; -import { getWorkflowExecutionDetailUri } from '../utils/UriUtils'; -import { openPreview } from '../utils/vsCodeHelpers'; - - -export class WorkflowTesterWebviewViewProvider implements vscode.WebviewViewProvider { - - - private _view?: vscode.WebviewView; - private _extensionUri: vscode.Uri; - - constructor( - private readonly _context: vscode.ExtensionContext, - private readonly _tenantService: TenantService - ) { - this._extensionUri = this._context.extensionUri; - } - - public activate() { - - this._context.subscriptions.push( - vscode.window.registerWebviewViewProvider(commands.WORKFLOW_TESTER_VIEW, this)); - /* - context.subscriptions.push( - vscode.commands.registerCommand('calicoColors.addColor', () => { - provider.addColor(); - })); - - context.subscriptions.push( - vscode.commands.registerCommand('calicoColors.clearColors', () => { - provider.clearColors(); - })); - */ - } - - public async resolveWebviewView( - webviewView: vscode.WebviewView, - context: vscode.WebviewViewResolveContext, - token: vscode.CancellationToken, - ) { - this._view = webviewView; - - webviewView.webview.options = { - // Allow scripts in the webview - enableScripts: true, - - localResourceRoots: [ - this._extensionUri - ] - }; - - webviewView.webview.html = await this.getHtmlForWebview(webviewView.webview); - - // Sets up an event listener to listen for messages passed from the webview view context - // and executes code based on the message that is recieved - this.setWebviewMessageListener(webviewView); - - } - - private setWebviewMessageListener(webviewView: vscode.WebviewView) { - webviewView.webview.onDidReceiveMessage(async data => { - const command = data.command; - switch (command) { - case 'getWorkflows': - { - this.showWorkflow(data.tenantId); - break; - } - case 'getWorkflowTriggers': - { - const tenantInfo = this._tenantService.getTenant(data.tenantId); - const client = new ISCClient(data.tenantId, tenantInfo?.tenantName ?? ""); - const workflowTriggers = await client.getWorflowTriggers(); - - if (this._view) { - this._view.webview.postMessage({ - command: 'setWorkflowTriggers', - payload: JSON.stringify({ - workflowTriggers: workflowTriggers - }) - - }); - } - break; - } - case 'testWorkflow': - { - const tenantInfo = this._tenantService.getTenant(data.tenantId); - const client = new ISCClient(data.tenantId, tenantInfo?.tenantName ?? ""); - await vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - title: `Testing workflow ${data.workflowName}...`, - cancellable: false - }, async (task, token) => { - - const workflowExecutionId = await client.testWorkflow(data.workflowId, JSON.parse(data.payload)); - let workflowStatus; - do { - await delay(1000); - workflowStatus = await client.getWorkflowExecution(workflowExecutionId); - console.log({ workflowStatus }); - } - while (workflowStatus.status === "Running"); - if (workflowStatus.status === "Failed") { - vscode.window.showErrorMessage("Workflow test has failed"); - } - - const uri = getWorkflowExecutionDetailUri(data.tenant, workflowExecutionId); - console.log('testWorkflow: uri:', uri); - - openPreview(uri) - console.log("< testWorkflow"); - - }); - break; - } - } - }); - } - - public async showWorkflow(tenantId: string, workflowId?: string) { - - if (this._view) { - this._view.show?.(true); - const tenantInfo = this._tenantService.getTenant(tenantId); - const client = new ISCClient(tenantId, tenantInfo?.tenantName ?? ""); - - const workflows = await client.getWorflows(); - // subset of info from workflows - const workflowModels = workflows.map(w => ({ - id: w.id, - name: w.name, - triggerType: w.trigger.type, - triggerAttributes: w.trigger.attributes - })); - - const payload: any = { - tenantId: tenantId, - workflows: workflowModels - }; - if (workflowId) { - payload.selected = workflowId; - } - - this._view.webview.postMessage({ - command: 'setWorkflows', - payload: JSON.stringify(payload) - }); - } - } - - private async getHtmlForWebview(webview: vscode.Webview) { - // Get the local path to main script run in the webview, then convert it to a uri we can use in the webview. - const scriptUri = webview.asWebviewUri(vscode.Uri.joinPath(this._extensionUri, 'resources', 'views', 'workflow', 'main.js')); - const toolkitUri = webview.asWebviewUri(vscode.Uri.joinPath(this._extensionUri, - "node_modules", - "@vscode", - "webview-ui-toolkit", - "dist", - "toolkit.js", - )); - const styleMainUri = webview.asWebviewUri(vscode.Uri.joinPath(this._extensionUri, 'resources', 'views', 'workflow', 'main.css')); - - - const tenantNames = await this._tenantService.getTenants(); - - let tenantOptions = ''; - if (tenantNames.length !== 1) { - // Add default empty value, to force to choose one tenant - tenantOptions = ''; - } else { - for (const tenantName of tenantNames) { - tenantOptions += `${tenantName.name}`; - } - } - return ` - - - - - - - - Workflow tester - - -
-

Tenant

- - ${tenantOptions} - -
-
-

Workflow

- - - -
-
- Payload -
-
- Test - -
- - - `; - } -} -