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

plan-OIC-56403: RAB VSCode: Should not allow user to select more than 200 items for both Postman Collection requests and OpenAPI method:paths #49

Merged
merged 8 commits into from
Jul 1, 2024
48 changes: 40 additions & 8 deletions src/providers/copilot-webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,31 @@ function handleWebviewLifecycle() {

}

const notifyPostmanWebview = (file: vscode.Uri, entryType: SharedNs.VscodeCommandPayload["updateEntryType"]) => {
UtilsNs.notifyWebview(SharedNs.ExtensionCommandEnum.updatePostmanRawData, JSON.parse(readFileSync(file.fsPath, 'utf8')) as PostmanNs.Root);
const notifyPostmanWebview = ({
postmanFile,
addFile,
entryType
}: {
postmanFile: vscode.Uri,
addFile?: vscode.Uri,
entryType: SharedNs.VscodeCommandPayload["updateEntryType"]
}) => {

let ADD: RabAddNs.Root | undefined = undefined;
try {
if (addFile) {
ADD = JSON.parse(readFileSync(addFile.fsPath, 'utf8'));
}
} catch (error) {
log.error(`Unable to parse adapter definition document`, error);
return;
}

UtilsNs.notifyWebview(SharedNs.ExtensionCommandEnum.updatePostmanRawData, {
postman: JSON.parse(readFileSync(postmanFile.fsPath, 'utf8')) as PostmanNs.Root,
add: ADD
});

UtilsNs.notifyWebview(SharedNs.ExtensionCommandEnum.updateEntryType, entryType);
};

Expand Down Expand Up @@ -304,8 +327,17 @@ const openWebview = ({

handleWebviewRouting(SharedNs.WebviewRouteEnum.PostmanAdd),
handleWebviewLifecycle(),
notifyPostmanWebview(file, entryType),
UtilsNs.listenWebview(SharedNs.WebviewCommandEnum.postmanSelectReady, () => notifyPostmanWebview(file, entryType)),
notifyPostmanWebview({
postmanFile: file,
entryType,
addFile
}),
UtilsNs.listenWebview(SharedNs.WebviewCommandEnum.postmanSelectReady, () => notifyPostmanWebview({
postmanFile: file,
entryType,
addFile
}
)),
UtilsNs.listenWebview(SharedNs.WebviewCommandEnum.postmanSelectRequests, (data) => {

const observable = fs.checkWorkspaceInitialized().pipe(
Expand Down Expand Up @@ -412,7 +444,7 @@ const registerPostmanConvertCallback = (context: vscode.ExtensionContext, entryT
switchMap(
() => openWebview(
{
file, context, entryType,
file, context, entryType,
addFile: entryType === SharedNs.VscodeCommandPayloadEntryType.PostmanAddRequest ? getAddFile() : undefined
}
)
Expand Down Expand Up @@ -449,9 +481,9 @@ const registerOpenAPIConvertCallback = (context: vscode.ExtensionContext, entryT
.pipe(
tap(() => UtilsNs.showWebview(context)),
tap(() => showInfoMessage(
entryType === SharedNs.VscodeCommandPayloadEntryType.OpenAPIAddRequest ?
"Select the OpenAPI paths and methods to add"
: "Select the OpenAPI paths and methods to convert"
entryType === SharedNs.VscodeCommandPayloadEntryType.OpenAPIAddRequest ?
"Select the OpenAPI paths and methods to add"
: "Select the OpenAPI paths and methods to convert"
)),
switchMap(
() => openWebview({
Expand Down
5 changes: 4 additions & 1 deletion src/webview-shared-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ export namespace SharedNs {
openCopilotPostmanConvert: any;
openCopilotAssistant: any;

updatePostmanRawData: PostmanNs.Root;
updatePostmanRawData: {
postman: PostmanNs.Root,
add?: RabAddNs.Root,
};
updateOpenAPIRawData: {
openapi: OpenAPINS.Root,
add?: RabAddNs.Root,
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.c503ed20880785365d34.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.c503ed20880785365d34.js"></script><script defer="defer" src="js/libs/index.c503ed20880785365d34.js"></script><script defer="defer" src="js/main.c503ed20880785365d34.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.d7ada578f1175f12b09b.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.d7ada578f1175f12b09b.js"></script><script defer="defer" src="js/libs/index.d7ada578f1175f12b09b.js"></script><script defer="defer" src="js/main.d7ada578f1175f12b09b.js"></script></body></html>

Large diffs are not rendered by default.

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

This file was deleted.

6 changes: 6 additions & 0 deletions webview/js/main.d7ada578f1175f12b09b.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.c503ed20880785365d34.css

This file was deleted.

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

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

Loading