Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAB: VScode is not showing all operations while converting to ADD on Windows VSCode #51

Merged
merged 11 commits into from
Sep 5, 2024
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Oracle Integration Cloud Rapid Adapter Builder is a set of tools that makes it easier for you to validate, develop and deploy the next-gen RAB adapters for Oracle Integration Cloud (OIC) straight from VS Code.",
"publisher": "Oracle",
"license": "UPL",
"version": "1.3.0",
"version": "1.3.1",
"icon": "media/images/logo.png",
"engines": {
"vscode": "^1.73.0"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/add-operation-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const callApiAndShowADDDocument = <CONFIG, RESDATA, RESPONSE extends Axio
.pipe(

tap(
() => showInfoMessage(`${operationName} is in progress...`)
() => showInfoMessage(`Start ${operationName}...`)
),

switchMap(
Expand Down Expand Up @@ -83,7 +83,7 @@ export const callApiAndShowADDDocument = <CONFIG, RESDATA, RESPONSE extends Axio
}),

tap(
() => showInfoMessage(`${operationName} is done.`)
() => showInfoMessage(`Finish ${operationName}.`)
),

catchError(err => {
Expand Down
30 changes: 26 additions & 4 deletions src/providers/copilot-webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { showErrorMessage, showInfoMessage } from "../utils/ui-utils";
import { OpenAPINS, PostmanNs, RabAddNs, SharedNs } from "../webview-shared-lib";
import { getAddFile } from "../workspace-manager";


const messagePreflightRecord = new Map();
export namespace UtilsNs {

export let panel: vscode.WebviewPanel | undefined;
Expand Down Expand Up @@ -180,14 +182,19 @@ export namespace UtilsNs {
);
};

export const notifyWebview = <T extends keyof typeof SharedNs.ExtensionCommandEnum>(command: T, payload: SharedNs.VscodeCommandPayload[T]) => {
export const notifyWebview = async <T extends keyof typeof SharedNs.ExtensionCommandEnum>(command: T, payload: SharedNs.VscodeCommandPayload[T]) => {

while (!messagePreflightRecord.get(command)) {
await SharedNs.delayInSeconds(0.5);
}

if (panel) {
panel.webview.postMessage({
target: 'webview',
command: command,
payload
});
}
};
};

const registryMap: Map<keyof typeof SharedNs.ExtensionCommandEnum, vscode.Disposable[]> = new Map();
Expand Down Expand Up @@ -227,6 +234,22 @@ function handleWebviewRouting(href: SharedNs.WebviewRouteEnum) {

}

function handlePreflight() {

return UtilsNs.listenWebview(
SharedNs.WebviewCommandEnum.webviewMessagePreflight,
({ ack, isUnlisten }) => {
if (ack) {
console.log(`[webviewMessagePreflight] Got ack [${ack}]`);
messagePreflightRecord.set(ack, !isUnlisten);
} else {
console.error(`ack should be set`);
}

});

}

function handleWebviewLifecycle() {

return UtilsNs.listenWebview(SharedNs.WebviewCommandEnum.webviewLifecycle, (payload) => {
Expand Down Expand Up @@ -324,8 +347,6 @@ const openWebview = ({


const postmanEvents = () => [


handleWebviewRouting(SharedNs.WebviewRouteEnum.PostmanAdd),
handleWebviewLifecycle(),
notifyPostmanWebview({
Expand Down Expand Up @@ -417,6 +438,7 @@ const openWebview = ({
const entryEvents = isPostmanEvents ? postmanEvents() : openAPIEvents();

return from([
handlePreflight(),
...entryEvents,
]);
};
Expand Down
8 changes: 2 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import * as _fs from 'fs';

import { createServer } from 'http';
import * as path from 'path';
import { EMPTY, Observable, bindNodeCallback, firstValueFrom, from, iif, of, range } from 'rxjs';
import { catchError, defaultIfEmpty, delay, filter, map, skipWhile, switchMap, take, takeWhile, tap } from 'rxjs/operators';
import { EMPTY, Observable, bindNodeCallback, from, iif, of, range } from 'rxjs';
import { catchError, defaultIfEmpty, filter, map, skipWhile, switchMap, take, takeWhile, tap } from 'rxjs/operators';
import * as vscode from 'vscode';
import { log } from './logger';
import { initWorkspace } from './workspace-manager';
Expand All @@ -21,10 +21,6 @@ import { isWorkSpaceInitialized } from './workspace-manager';

const defaultApiCallTimeoutInSeconds = 120;

export namespace helpers {
export const delayInSeconds = (timeInSeconds: number) => firstValueFrom(of(null).pipe(delay(timeInSeconds * 1000)));
}

export namespace constants {
export const commands = {
'orabConvertPostmanDocument': 'orab.convert.postman.document'
Expand Down
19 changes: 19 additions & 0 deletions src/webview-shared-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export namespace SharedNs {
export const WebviewCommandEnum = {
webviewRouterReady: 'webviewRouterReady' as 'webviewRouterReady',
webviewLifecycle: 'webviewLifecycle' as 'webviewLifecycle',
webviewMessagePreflight: 'webviewMessagePreflight' as 'webviewMessagePreflight',

postmanSelectRequests: 'postmanSelectRequests' as 'postmanSelectRequests',
postmanDoneConvertDocument: 'postmanDoneConvertDocument' as 'postmanDoneConvertDocument',
Expand All @@ -22,7 +23,11 @@ export namespace SharedNs {
rabAddSave: 'rabAddSave' as 'rabAddSave',

}

export type WebviewCommandEnumKey = keyof typeof WebviewCommandEnum;

export const ExtensionCommandEnum = {

openCopilotPostmanConvert: 'orab.webview.copilot.open.postman.convert' as 'openCopilotPostmanConvert',
openPostmanConvertConverDocument: 'orab.convert.postman.document' as 'openPostmanConvertConverDocument',
openADDCompress: 'orab.add.compress' as 'openADDCompress',
Expand All @@ -36,6 +41,9 @@ export namespace SharedNs {
routerNavigateTo: 'routerNavigateTo' as 'routerNavigateTo',
}

export type ExtensionCommandEnumKey = keyof typeof ExtensionCommandEnum;


export enum WebviewRouteEnum {
Root = `/`,
PostmanAdd = `postman/add`,
Expand Down Expand Up @@ -65,12 +73,19 @@ export namespace SharedNs {
vsCodeEditorConfig?: VsCoderEditorConfig;
}

export type MessagePreflightPayload = {
ack?: (typeof ExtensionCommandEnum)[ExtensionCommandEnumKey] | (typeof WebviewCommandEnum)[WebviewCommandEnumKey]
isUnlisten?: boolean
};

export type WebviewCommandPayload = {
webviewRouterReady: WebviewCommandPayloadWebviewRouterReady;
webviewLifecycle: {
type: 'close'
};

webviewMessagePreflight: MessagePreflightPayload;

postmanSelectRequests: Omit<WebviewCommandPayloadPostmanSelectRequests, "selectedItemForTestConnection">;
postmanDoneConvertDocument: WebviewCommandPayloadPostmanSelectRequests;
postmanSelectReady: any;
Expand All @@ -92,6 +107,7 @@ export namespace SharedNs {
}

export type VscodeCommandPayload = {

openCopilotPostmanConvert: any;
openCopilotAssistant: any;

Expand Down Expand Up @@ -127,6 +143,9 @@ export namespace SharedNs {
endOffset?: number
}


export const delayInSeconds = async (timeInSeconds: number) => new Promise(resolve => setTimeout(() => resolve(true), timeInSeconds * 1000));

}

export namespace RabAddUtilNs {
Expand Down
2 changes: 1 addition & 1 deletion webview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<!doctype html><html lang="en-us"><head><title>Oracle JET VDOM Starter Template - Basic</title><meta charset="UTF-8"/><meta name="viewport" content="viewport-fit=cover,width=device-width,initial-scale=1"/><link rel="icon" href="styles/images/JET-Favicon-Red-32x32.png" type="image/x-icon"/><base href="/"/><link rel="stylesheet" type="text/css" href="styles/redwood/15.1.0/web/redwood.min.css">
<link rel="stylesheet" type="text/css" href="styles/theme-redwood/15.1.0/web/theme.css">

<link rel="stylesheet" type="text/css" href="styles/app.css"><link rel="stylesheet" id="uxiconFont" href="https://static.oracle.com/cdn/fnd/gallery/2310.0.1/images/iconfont/ojuxIconFont.min.css"/><link href="styles/main.10bc759fb9c69762cf12.css" rel="stylesheet"></head><body class="oj-web-applayout-body" data-oj-binding-provider="none"><app-root></app-root><script defer="defer" src="js/runtime.10bc759fb9c69762cf12.js"></script><script defer="defer" src="js/libs/index.10bc759fb9c69762cf12.js"></script><script defer="defer" src="js/main.10bc759fb9c69762cf12.js"></script></body></html>
<link rel="stylesheet" type="text/css" href="styles/app.css"><link rel="stylesheet" id="uxiconFont" href="https://static.oracle.com/cdn/fnd/gallery/2310.0.1/images/iconfont/ojuxIconFont.min.css"/><link href="styles/main.9a1f4b564144583acee0.css" rel="stylesheet"></head><body class="oj-web-applayout-body" data-oj-binding-provider="none"><app-root></app-root><script defer="defer" src="js/runtime.9a1f4b564144583acee0.js"></script><script defer="defer" src="js/libs/index.9a1f4b564144583acee0.js"></script><script defer="defer" src="js/main.9a1f4b564144583acee0.js"></script></body></html>

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions webview/js/main.10bc759fb9c69762cf12.js

This file was deleted.

6 changes: 6 additions & 0 deletions webview/js/main.9a1f4b564144583acee0.js

Large diffs are not rendered by default.

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

3 changes: 0 additions & 3 deletions webview/styles/main.10bc759fb9c69762cf12.css

This file was deleted.

3 changes: 3 additions & 0 deletions webview/styles/main.9a1f4b564144583acee0.css

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

Loading