From 4451e75fbea6ed82c66b584c84afb9e23a2fe8bc Mon Sep 17 00:00:00 2001 From: Traxx <31518769+crowbait@users.noreply.github.com> Date: Sat, 14 Dec 2024 18:53:48 +0100 Subject: [PATCH] fix: move request handling to backend; fixes CORS-only headers --- .vscodeignore | 1 - src/Call-Temporary.ts | 2 +- src/Call.ts | 2 +- src/CallEdit.html | 11 +- src/CallEdit.ts | 4 +- src/CallRun.html | 343 +++++++++--------- src/CallRun.ts | 123 ++++++- src/TreeDataProvider.ts | 4 +- src/helpers/WebViewHelpers.ts | 6 +- .../{statusCodes.jspart => statusCodes.ts} | 4 +- 10 files changed, 304 insertions(+), 196 deletions(-) rename src/helpers/{statusCodes.jspart => statusCodes.ts} (99%) diff --git a/.vscodeignore b/.vscodeignore index 1be8d74..eaabadd 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -12,7 +12,6 @@ vsc-extension-quickstart.md src/** !src/helpers/jsontree.css !src/helpers/jsontree.js -!src/helpers/statusCodes.jspart !src/*.html node_modules diff --git a/src/Call-Temporary.ts b/src/Call-Temporary.ts index f38ad1d..37fba14 100644 --- a/src/Call-Temporary.ts +++ b/src/Call-Temporary.ts @@ -34,7 +34,7 @@ class RESTCall_Temporary { this.log.appendLine(`Running ${this.label}`); if (this.runView) { this.runView.webview.reveal(); - this.runView.run(); + this.runView.prepareRun(); return; } this.runView = new CallRun(this, () => this.runView = undefined); diff --git a/src/Call.ts b/src/Call.ts index 417f085..8f16da1 100644 --- a/src/Call.ts +++ b/src/Call.ts @@ -58,7 +58,7 @@ class RESTCall extends ListEntry { this.provider.log.appendLine(`Running ${this.label}`); if (this.runView) { this.runView.webview.reveal(); - this.runView.run(); + this.runView.prepareRun(); return; } this.runView = new CallRun(this, () => this.runView = undefined); diff --git a/src/CallEdit.html b/src/CallEdit.html index 2f154d1..5cb489e 100644 --- a/src/CallEdit.html +++ b/src/CallEdit.html @@ -69,8 +69,14 @@ border: 1px solid var(--vscode-widget-border); border-radius: 4px; } + #body-errors { + color: darkorange; + font-family: var(--vscode-editor-font-family); + background: var(--vscode-textPreformat-background); + padding: 0.25rem; + } - #json-errors, #body-errors { + #json-errors { color: lightcoral; font-family: var(--vscode-editor-font-family); background: darkred; @@ -300,7 +306,7 @@

} catch (error) { vscode.postMessage({channel: 'err', value: `Error parsing body: ${error.message}`}); body_errors.hidden = false; - body_errors.innerText = error.message; + body_errors.innerText = `Warning: ${error.message}`; } } input_body.onchange = (e) => { @@ -349,7 +355,6 @@

// ----------------- (function() { window.addEventListener('message', event => { - vscode.postMessage({channel: 'log', value: `Message from host: ${JSON.stringify(event.data)}`}); switch (event.data.channel) { case 'call-data': data = event.data.value; diff --git a/src/CallEdit.ts b/src/CallEdit.ts index c4c89e5..fe9afd8 100644 --- a/src/CallEdit.ts +++ b/src/CallEdit.ts @@ -38,11 +38,11 @@ export class CallEdit { webview: vscode.WebviewPanel; private webviewSendMessage = (message: any): void => { - this.log.appendLine(`Sending to webview edit: ${JSON.stringify(message)}`); + this.log.appendLine(`Sending to webview edit: ${JSON.stringify(message.channel)}`); this.webview.webview.postMessage(message); }; private webviewReceiveMessage = (message: any): void => { - this.log.appendLine(`Receiving from webview edit: ${JSON.stringify(message)}`); + this.log.appendLine(`Receiving from webview edit: ${JSON.stringify(message.channel)}`); switch (message.channel) { case 'event': switch (message.value) { diff --git a/src/CallRun.html b/src/CallRun.html index c9fff4d..9daee8b 100644 --- a/src/CallRun.html +++ b/src/CallRun.html @@ -35,6 +35,14 @@ vscode-table { --vscode-font-family: var(--vscode-editor-font-family); } + vscode-table-body { + padding-top: 0.25rem; + } + vscode-table-cell { + word-wrap: break-word; + white-space: normal; + vertical-align: top; + } #status-container { display: flex; @@ -104,9 +112,8 @@

-
- - +
+