1
1
import axios from "axios" ;
2
2
import * as httpsModule from "https" ;
3
-
4
3
import * as vscode from "vscode" ;
5
4
import { AtelierAPI } from "../api" ;
6
- import { cspAppsForUri , handleError } from "../utils" ;
5
+ import { handleError } from "../utils" ;
7
6
import { iscIcon } from "../extension" ;
8
7
9
8
interface WebviewMessage {
@@ -83,24 +82,6 @@ export class RESTDebugPanel {
83
82
return ;
84
83
}
85
84
86
- // Build the list of all non-CSP web apps
87
- const cspWebApps : string [ ] = cspAppsForUri ( openEditor . document . uri ) ;
88
- const allWebApps : string [ ] | null = await api
89
- . actionQuery ( "CALL %CSP.Apps_CSPAppList()" , [ ] )
90
- . then ( ( data ) => data . result . content . map ( ( obj ) => obj . AppUrl ) )
91
- . catch ( ( error ) => {
92
- handleError ( error , "Failed to fetch the list of web applications from the server." ) ;
93
- return null ;
94
- } ) ;
95
- if ( allWebApps == null ) {
96
- return ;
97
- }
98
- const restWebApps = allWebApps . filter ( ( app ) => ! cspWebApps . includes ( app ) ) ;
99
- if ( restWebApps . length == 0 ) {
100
- vscode . window . showErrorMessage ( "No REST web applications are configured in the server's namespace." , "Dismiss" ) ;
101
- return ;
102
- }
103
-
104
85
if ( this . currentPanel !== undefined ) {
105
86
// Can only have one panel open at once
106
87
if ( ! this . currentPanel . _panel . visible ) {
@@ -133,10 +114,10 @@ export class RESTDebugPanel {
133
114
panel . iconPath = iscIcon ;
134
115
135
116
this . _file = openEditor . document . uri ;
136
- this . currentPanel = new RESTDebugPanel ( panel , webviewFolderUri , api , restWebApps ) ;
117
+ this . currentPanel = new RESTDebugPanel ( panel , webviewFolderUri , api ) ;
137
118
}
138
119
139
- private constructor ( panel : vscode . WebviewPanel , webviewFolderUri : vscode . Uri , api : AtelierAPI , webApps : string [ ] ) {
120
+ private constructor ( panel : vscode . WebviewPanel , webviewFolderUri : vscode . Uri , api : AtelierAPI ) {
140
121
this . _panel = panel ;
141
122
const serverInfo = `${ api . config . https ? "https" : "http" } ://${ api . config . host } :${ api . config . port } ${
142
123
api . config . pathPrefix
@@ -153,12 +134,7 @@ export class RESTDebugPanel {
153
134
vscode . Uri . joinPath ( webviewFolderUri , "elements-1.6.3.js" )
154
135
) } "></script>
155
136
<title>${ RESTDebugPanel . _viewTitle } </title>
156
- <style>
157
- .path-grid {
158
- display: grid;
159
- grid-template-columns: 1fr 20fr;
160
- column-gap: 0.5rem;
161
- }
137
+ <style>
162
138
.component-container > * {
163
139
margin: 0.5rem 0;
164
140
}
@@ -168,15 +144,6 @@ export class RESTDebugPanel {
168
144
vscode-tabs {
169
145
display: contents;
170
146
}
171
- .path-grid-container {
172
- display: flex;
173
- flex-direction: row;
174
- align-items: flex-start;
175
- justify-content: flex-start;
176
- }
177
- #webApp {
178
- max-width: 45vw;
179
- }
180
147
#button {
181
148
margin-top: 0.5rem;
182
149
}
@@ -198,15 +165,8 @@ export class RESTDebugPanel {
198
165
<vscode-tab-header id="bodyTab">BODY</vscode-tab-header>
199
166
<vscode-tab-panel id="methodPathView">
200
167
<section class="component-container">
201
- <p>
202
- Select a method for this request, then select the web application
203
- to use from the dropdown and enter the rest of the path in the input field
204
- next to the dropdown.
205
- </p>
206
- <p>
207
- The connection information of the server definition
208
- is shown for clarity but it cannot be edited.
209
- </p>
168
+ <p>Select a method for this request, then enter the path in the bottom input field.</p>
169
+ <p>The connection information of the server definition is shown, but it cannot be edited.</p>
210
170
<vscode-radio-group id="method" name="method">
211
171
<vscode-radio value="GET" name="method" checked>GET</vscode-radio>
212
172
<vscode-radio value="POST" name="method">POST</vscode-radio>
@@ -217,14 +177,7 @@ export class RESTDebugPanel {
217
177
<vscode-radio value="OPTIONS" name="method">OPTIONS</vscode-radio>
218
178
</vscode-radio-group>
219
179
<vscode-textfield readonly id="serverInfo"></vscode-textfield>
220
- <section class="path-grid">
221
- <section class="path-grid-container">
222
- <vscode-single-select id="webApp" name="webApp" position="below"></vscode-single-select>
223
- </section>
224
- <section class="path-grid-container">
225
- <vscode-textfield id="path" name="path" placeholder="/path" pattern="^/.*$" required></vscode-textfield>
226
- </section>
227
- </section>
180
+ <vscode-textfield id="path" name="path" placeholder="/path" pattern="^/.*$" required></vscode-textfield>
228
181
</section>
229
182
</vscode-tab-panel>
230
183
<vscode-tab-panel id="headersView">
@@ -271,13 +224,12 @@ export class RESTDebugPanel {
271
224
const bodyType = document.getElementById("bodyType");
272
225
const bodyContent = document.getElementById("bodyContent");
273
226
const button = document.getElementById("button");
274
- const webApp = document.getElementById("webApp");
275
- const formFields = [method, serverInfo, path, headersText, paramsText, bodyType, bodyContent, webApp];
227
+ const formFields = [method, serverInfo, path, headersText, paramsText, bodyType, bodyContent];
276
228
const sendData = (submitted) => {
277
229
const data = Object.fromEntries(new FormData(form));
278
230
if (
279
231
Object.keys(data).length == (formFields.length - 1) &&
280
- data.webApp != "" && data. method != "" && data.bodyType != "" &&
232
+ data.method != "" && data.bodyType != "" &&
281
233
(!submitted || (submitted && path.checkValidity()))
282
234
) {
283
235
vscode.postMessage({
@@ -290,24 +242,7 @@ export class RESTDebugPanel {
290
242
window.onmessage = (event) => {
291
243
const data = event.data, currentVals = new FormData(form);
292
244
formFields.forEach((field) => {
293
- if (field.id == "webApp" && webApp.children.length == 0) {
294
- // Create options and set the initial value
295
- const initIdx = data.webApps.findIndex((e) => e == data.webApp) ?? 0;
296
- data.webApps.forEach((webAppStr, idx) => {
297
- const option = document.createElement("vscode-option");
298
- option.innerText = webAppStr;
299
- option.setAttribute("value",webAppStr);
300
- if (idx == initIdx) {
301
- option.selected = true;
302
- }
303
- webApp.appendChild(option);
304
- });
305
- // Update width of dropdown
306
- const longest = data.webApps.reduce((a,b) => a.length > b.length ? a : b);
307
- const context = document.createElement("canvas").getContext("2d");
308
- context.font = window.getComputedStyle(webApp,null).getPropertyValue("font");
309
- webApp.style.width = Math.ceil(context.measureText(longest).width*(4/3)) + "px";
310
- } else if (data[field.id] != undefined && currentVals.get(field.id) != data[field.id]) {
245
+ if (data[field.id] != undefined && currentVals.get(field.id) != data[field.id]) {
311
246
if (["method","bodyType"].includes(field.id)) {
312
247
// Check the correct radio
313
248
for (const c of field.children) {
@@ -341,7 +276,7 @@ export class RESTDebugPanel {
341
276
// Bubble change events up to the form
342
277
bodyContent.onchange = headersText.onchange =
343
278
paramsText.onchange = path.onchange =
344
- webApp.onchange = () => form.dispatchEvent(new Event("change"));
279
+ () => form.dispatchEvent(new Event("change"));
345
280
</script>
346
281
</body>
347
282
</html>` ;
@@ -460,7 +395,6 @@ export class RESTDebugPanel {
460
395
// Restore the content
461
396
this . _panel . webview . postMessage ( {
462
397
serverInfo,
463
- webApps,
464
398
...RESTDebugPanel . _cache ,
465
399
} ) ;
466
400
}
0 commit comments