@@ -11,6 +11,7 @@ import {
11
11
} from "../extension" ;
12
12
import { cspAppsForUri , handleError , notIsfs } from "../utils" ;
13
13
import { pickProject } from "./project" ;
14
+ import { isfsConfig , IsfsUriParam } from "../utils/FileProviderUtil" ;
14
15
15
16
/**
16
17
* @param message The prefix of the message to show when the server manager API can't be found.
@@ -143,9 +144,7 @@ export async function addServerNamespaceToWorkspace(resource?: vscode.Uri): Prom
143
144
return ;
144
145
}
145
146
// Generate the name
146
- const params = new URLSearchParams ( uri . query ) ;
147
- const project = params . get ( "project" ) ;
148
- const csp = params . has ( "csp" ) ;
147
+ const { csp, project } = isfsConfig ( uri ) ;
149
148
const name = `${ project ? `${ project } - ${ serverName } :${ namespace } ` : ! csp ? `${ serverName } :${ namespace } ` : [ "" , "/" ] . includes ( uri . path ) ? `${ serverName } :${ namespace } web files` : `${ serverName } (${ uri . path } )` } ${
150
149
scheme == FILESYSTEM_READONLY_SCHEMA && ! project ? " (read-only)" : ""
151
150
} `;
@@ -188,7 +187,7 @@ export async function getServerManagerApi(): Promise<any> {
188
187
/** Prompt the user to fill in the `path` and `query` of `uri`. */
189
188
async function modifyWsFolderUri ( uri : vscode . Uri ) : Promise < vscode . Uri | undefined > {
190
189
if ( notIsfs ( uri ) ) return ;
191
- const params = new URLSearchParams ( uri . query ) ;
190
+ const { project , csp , system , generated , mapped , filter } = isfsConfig ( uri ) ;
192
191
const api = new AtelierAPI ( uri ) ;
193
192
194
193
// Prompt the user for the files to show
@@ -211,9 +210,7 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
211
210
detail : "Choose an existing project, or create a new one." ,
212
211
} ,
213
212
] ;
214
- quickPick . activeItems = [
215
- params . has ( "project" ) ? quickPick . items [ 2 ] : params . has ( "csp" ) ? quickPick . items [ 1 ] : quickPick . items [ 0 ] ,
216
- ] ;
213
+ quickPick . activeItems = [ project ? quickPick . items [ 2 ] : csp ? quickPick . items [ 1 ] : quickPick . items [ 0 ] ] ;
217
214
218
215
quickPick . onDidChangeSelection ( ( items ) => {
219
216
switch ( items [ 0 ] . label ) {
@@ -258,7 +255,7 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
258
255
// Catch handler reported the error already
259
256
return ;
260
257
} else if ( cspApps . length == 0 ) {
261
- vscode . window . showWarningMessage ( `No web applications are configured to use namespace ${ api . ns } .` , "Dismiss" ) ;
258
+ vscode . window . showWarningMessage ( `No web applications are configured in namespace ${ api . ns } .` , "Dismiss" ) ;
262
259
return ;
263
260
}
264
261
}
@@ -292,43 +289,43 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
292
289
if ( ! newPath ) {
293
290
return ;
294
291
}
295
- newParams = "csp" ;
292
+ newParams = IsfsUriParam . CSP ;
296
293
} else if ( filterType == "project" ) {
297
294
// Prompt for project
298
295
const project = await pickProject ( new AtelierAPI ( uri ) ) ;
299
296
if ( ! project ) {
300
297
return ;
301
298
}
302
- newParams = `project =${ project } ` ;
299
+ newParams = `${ IsfsUriParam . Project } =${ project } ` ;
303
300
} else {
304
301
// Prompt the user for other query parameters
305
302
const items = [
306
303
{
307
304
label : "$(filter) Filter" ,
308
305
detail : "Comma-delimited list of search options, e.g. '*.cls,*.inc,*.mac,*.int'" ,
309
- picked : params . has ( " filter" ) ,
310
- value : "filter" ,
306
+ picked : filter != "" ,
307
+ value : IsfsUriParam . Filter ,
311
308
} ,
312
309
{
313
310
label : "$(server-process) Show Generated" ,
314
311
detail : "Also show files tagged as generated, e.g. by compilation." ,
315
- picked : params . has ( " generated" ) ,
316
- value : "generated" ,
312
+ picked : generated ,
313
+ value : IsfsUriParam . Generated ,
317
314
} ,
318
315
{
319
316
label : "$(references) Hide Mapped" ,
320
317
detail : `Hide files that are mapped into ${ api . ns } from another code database.` ,
321
- picked : params . has ( " mapped" ) ,
322
- value : "mapped" ,
318
+ picked : ! mapped ,
319
+ value : IsfsUriParam . Mapped ,
323
320
} ,
324
321
] ;
325
322
if ( api . ns != "%SYS" ) {
326
323
// Only show system item for non-%SYS namespaces
327
324
items . push ( {
328
325
label : "$(library) Show System" ,
329
326
detail : "Also show '%' items and INFORMATION.SCHEMA items." ,
330
- picked : params . has ( " system" ) ,
331
- value : "system" ,
327
+ picked : system ,
328
+ value : IsfsUriParam . System ,
332
329
} ) ;
333
330
}
334
331
const otherParams = await vscode . window . showQuickPick ( items , {
@@ -340,37 +337,29 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
340
337
return ;
341
338
}
342
339
// Build the new query parameter string
343
- params . delete ( "csp" ) ;
344
- params . delete ( "project" ) ;
345
- params . delete ( "filter" ) ;
346
- params . delete ( "flat" ) ;
347
- params . delete ( "generated" ) ;
348
- params . delete ( "mapped" ) ;
349
- params . delete ( "system" ) ;
350
- params . delete ( "type" ) ;
340
+ const params = new URLSearchParams ( ) ;
351
341
for ( const otherParam of otherParams ) {
352
342
switch ( otherParam . value ) {
353
- case "filter" : {
343
+ case IsfsUriParam . Filter : {
354
344
// Prompt for filter
355
- const filter = await vscode . window . showInputBox ( {
345
+ const newFilter = await vscode . window . showInputBox ( {
356
346
title : "Enter a filter string." ,
357
347
ignoreFocusOut : true ,
358
- value : params . get ( " filter" ) ,
348
+ value : filter ,
359
349
placeHolder : "*.cls,*.inc,*.mac,*.int" ,
360
350
prompt :
361
351
"Patterns are comma-delimited and may contain both * (zero or more characters) and ? (a single character) as wildcards. To exclude items, prefix the pattern with a single quote." ,
362
352
} ) ;
363
- if ( filter && filter . length ) {
364
- params . set ( otherParam . value , filter ) ;
353
+ if ( newFilter && newFilter . length ) {
354
+ params . set ( otherParam . value , newFilter ) ;
365
355
}
366
356
break ;
367
357
}
368
- case "generated" :
369
- case "system" :
370
- params . set ( otherParam . value , "1" ) ;
371
- break ;
372
- case "mapped" :
358
+ case IsfsUriParam . Mapped :
373
359
params . set ( otherParam . value , "0" ) ;
360
+ break ;
361
+ default : // system and generated
362
+ params . set ( otherParam . value , "1" ) ;
374
363
}
375
364
}
376
365
newParams = params . toString ( ) ;
0 commit comments