Skip to content

Commit

Permalink
Merge pull request #346 from axonivy/help-url
Browse files Browse the repository at this point in the history
XIVY-15282 Catch openUrl action and open url in internal browser
  • Loading branch information
ivy-lli authored Nov 6, 2024
2 parents ca76eac + a6ea2d1 commit e7649ed
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 52 deletions.
19 changes: 18 additions & 1 deletion extension/src/editors/config-editor/webview-communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Messenger } from 'vscode-messenger';
import { DisposableCollection } from '@eclipse-glsp/vscode-integration';
import { MessageParticipant, NotificationType } from 'vscode-messenger-common';
import { WebSocketForwarder } from '../websocket-forwarder';
import type { VariablesActionArgs } from '@axonivy/variable-editor-protocol';
import { IvyBrowserViewProvider } from '../../browser/ivy-browser-view-provider';

const WebviewReadyNotification: NotificationType<void> = { method: 'ready' };
const InitializeConnectionRequest: NotificationType<{ file: string }> = { method: 'initializeConnection' };
Expand All @@ -27,21 +29,36 @@ export const setupCommunication = (
};

class VariableEditorWebSocketForwarder extends WebSocketForwarder {
constructor(websocketUrl: URL, messenger: Messenger, messageParticipant: MessageParticipant, readonly document: vscode.TextDocument) {
constructor(
websocketUrl: URL,
messenger: Messenger,
messageParticipant: MessageParticipant,
readonly document: vscode.TextDocument
) {
super(websocketUrl, 'ivy-config-lsp', messenger, messageParticipant, ConfigWebSocketMessage);
}

protected override handleClientMessage(message: unknown) {
if (this.isSaveData(message)) {
this.writeTextDocument(message.params.data);
}
if (this.isAction(message)) {
if (message.params.actionId === 'openUrl') {
IvyBrowserViewProvider.instance.open(message.params.payload);
}
return;
}
super.handleClientMessage(message);
}

isSaveData = (obj: unknown): obj is { jsonrpc: string; id: number; method: string; params: { data: string } } => {
return typeof obj === 'object' && obj !== null && 'method' in obj && obj.method === 'saveData';
};

isAction = (obj: unknown): obj is { method: string; params: VariablesActionArgs } => {
return typeof obj === 'object' && obj !== null && 'method' in obj && obj.method === 'action';
};

writeTextDocument = (content: string) => {
const workspaceEdit = new vscode.WorkspaceEdit();
workspaceEdit.replace(
Expand Down
4 changes: 4 additions & 0 deletions extension/src/editors/form-editor/webview-communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { WebSocketForwarder } from '../websocket-forwarder';
import { DisposableCollection } from '@eclipse-glsp/vscode-integration';
import { MessageParticipant, NotificationType } from 'vscode-messenger-common';
import { FormActionArgs } from '@axonivy/form-editor-protocol';
import { IvyBrowserViewProvider } from '../../browser/ivy-browser-view-provider';

const WebviewReadyNotification: NotificationType<void> = { method: 'ready' };
const InitializeConnectionRequest: NotificationType<{ file: string }> = { method: 'initializeConnection' };
Expand Down Expand Up @@ -50,6 +51,9 @@ class FormEditorWebSocketForwarder extends WebSocketForwarder {
if (message.params.actionId === 'openDataClass') {
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(`${path}Data.d.json`));
}
if (message.params.actionId === 'openUrl') {
IvyBrowserViewProvider.instance.open(message.params.payload);
}
return;
}
super.handleClientMessage(message);
Expand Down
2 changes: 1 addition & 1 deletion extension/webviews/config-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "12.0.0",
"private": true,
"dependencies": {
"@axonivy/variable-editor": "~12.0.0-next.387",
"@axonivy/variable-editor": "~12.0.0-next.399",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"vscode-webview-common": "12.0.0"
Expand Down
4 changes: 2 additions & 2 deletions extension/webviews/form-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "VSCode extension webview for the Axon Ivy form editor",
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
"dependencies": {
"@axonivy/form-editor": "~12.0.0-next.380",
"@axonivy/form-editor-core": "~12.0.0-next.380",
"@axonivy/form-editor": "~12.0.0-next.388",
"@axonivy/form-editor-core": "~12.0.0-next.388",
"vscode-webview-common": "12.0.0"
},
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions extension/webviews/process-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"url": "https://github.com/axonivy/glsp-editor-client"
},
"dependencies": {
"@axonivy/process-editor": "~12.0.0-next.1189",
"@axonivy/process-editor-inscription": "~12.0.0-next.1189",
"@axonivy/process-editor-protocol": "~12.0.0-next.1189",
"@axonivy/process-editor": "~12.0.0-next.1191",
"@axonivy/process-editor-inscription": "~12.0.0-next.1191",
"@axonivy/process-editor-protocol": "~12.0.0-next.1191",
"@eclipse-glsp/vscode-integration-webview": "2.3.0-next.90",
"inversify": "^6.0.1",
"vscode-webview-common": "12.0.0"
Expand Down
93 changes: 50 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions playwright/tests/form-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { pageFor } from './fixtures/page';
import { prebuiltWorkspacePath, randomArtefactName } from './workspaces/workspace';
import { Page } from '@playwright/test';
import { FormEditor } from './page-objects/form-editor';
import { BrowserView } from './page-objects/browser-view';

test.describe('Form Editor', () => {
let editor: FormEditor;
Expand Down Expand Up @@ -46,4 +47,14 @@ test.describe('Form Editor', () => {
await xhtmlEditor.activeEditorHasText(`value="${newLabel}" />`);
await xhtmlEditor.revertAndCloseEditor();
});

test('Open Help', async () => {
const browserView = new BrowserView(page);
await editor.locatorFor('.block-input').dblclick();
const inscriptionView = editor.locatorFor('#properties');
await inscriptionView.getByRole('button', { name: /Help/ }).click();
expect((await browserView.input().inputValue()).toString()).toMatch(
/^https:\/\/developer\.axonivy\.com.*user-dialogs\/form-editor\.html$/
);
});
});
7 changes: 5 additions & 2 deletions playwright/tests/page-objects/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export interface ViewData {
}

export class View extends PageObject {
constructor(protected readonly data: ViewData, page: Page) {
constructor(
protected readonly data: ViewData,
page: Page
) {
super(page);
}

Expand All @@ -20,7 +23,7 @@ export class View extends PageObject {
return this.page.locator(this.data.viewSelector);
}

protected viewFrameLoactor(): FrameLocator {
viewFrameLoactor(): FrameLocator {
return this.viewLocator
.frameLocator('iFrame')
.frameLocator(`iFrame#active-frame${this.data.viewName ? `[title="${this.data.viewName}"]` : ''}`);
Expand Down
9 changes: 9 additions & 0 deletions playwright/tests/variables-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Page, expect, test } from '@playwright/test';
import { pageFor } from './fixtures/page';
import { VariablesEditor } from './page-objects/variables-editor';
import { prebuiltWorkspacePath } from './workspaces/workspace';
import { BrowserView } from './page-objects/browser-view';

test.describe('Variables Editor', () => {
let page: Page;
Expand Down Expand Up @@ -46,4 +47,12 @@ test.describe('Variables Editor', () => {
// expect(await editor.hasKey('originalKey'));
// expect(await editor.hasValue('originalValue'));
});

test('Open Help', async () => {
const browserView = new BrowserView(page);
await editor.viewFrameLoactor().getByRole('button', { name: /Help/ }).click();
expect((await browserView.input().inputValue()).toString()).toMatch(
/^https:\/\/developer\.axonivy\.com.*configuration\/variables\.html$/
);
});
});

0 comments on commit e7649ed

Please sign in to comment.