Skip to content

Server-side improvements #1488

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

Merged
merged 5 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -581,22 +581,22 @@
},
{
"command": "vscode-objectscript.addItemsToProject",
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && explorerResourceIsRoot && !listMultiSelection",
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && resourcePath =~ /^\\/?$/ && !listMultiSelection",
"group": "objectscript_prj@1"
},
{
"command": "vscode-objectscript.removeFromProject",
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && !explorerResourceIsRoot && !listMultiSelection",
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && !(resourcePath =~ /^\\/?$/) && !listMultiSelection",
"group": "objectscript_prj@2"
},
{
"command": "vscode-objectscript.removeItemsFromProject",
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && explorerResourceIsRoot && !listMultiSelection",
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && resourcePath =~ /^\\/?$/ && !listMultiSelection",
"group": "objectscript_prj@2"
},
{
"command": "vscode-objectscript.modifyProjectMetadata",
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && explorerResourceIsRoot && !listMultiSelection",
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && resourcePath =~ /^\\/?$/ && !listMultiSelection",
"group": "objectscript_prj@3"
},
{
Expand Down
11 changes: 3 additions & 8 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { currentWorkspaceFolder, outputChannel, outputConsole } from "../utils";
const DEFAULT_API_VERSION = 1;
const DEFAULT_SERVER_VERSION = "2016.2.0";
import * as Atelier from "./atelier";
import { isfsConfig } from "../utils/FileProviderUtil";

// Map of the authRequest promises for each username@host:port target to avoid concurrency issues
const authRequestMap = new Map<string, Promise<any>>();
Expand Down Expand Up @@ -120,10 +121,8 @@ export class AtelierAPI {
workspaceFolderName = parts[0];
namespace = parts[1];
} else {
const params = new URLSearchParams(wsOrFile.query);
if (params.has("ns") && params.get("ns") != "") {
namespace = params.get("ns");
}
const { ns } = isfsConfig(wsOrFile);
if (ns) namespace = ns;
}
} else {
const wsFolderOfFile = vscode.workspace.getWorkspaceFolder(wsOrFile);
Expand All @@ -138,10 +137,6 @@ export class AtelierAPI {
this.setConnection(workspaceFolderName || currentWorkspaceFolder(), namespace);
}

public get enabled(): boolean {
return this._config.active;
}

public setNamespace(namespace: string): void {
this.namespace = namespace;
}
Expand Down
61 changes: 25 additions & 36 deletions src/commands/addServerNamespaceToWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "../extension";
import { cspAppsForUri, handleError, notIsfs } from "../utils";
import { pickProject } from "./project";
import { isfsConfig, IsfsUriParam } from "../utils/FileProviderUtil";

/**
* @param message The prefix of the message to show when the server manager API can't be found.
Expand Down Expand Up @@ -143,9 +144,7 @@ export async function addServerNamespaceToWorkspace(resource?: vscode.Uri): Prom
return;
}
// Generate the name
const params = new URLSearchParams(uri.query);
const project = params.get("project");
const csp = params.has("csp");
const { csp, project } = isfsConfig(uri);
const name = `${project ? `${project} - ${serverName}:${namespace}` : !csp ? `${serverName}:${namespace}` : ["", "/"].includes(uri.path) ? `${serverName}:${namespace} web files` : `${serverName} (${uri.path})`}${
scheme == FILESYSTEM_READONLY_SCHEMA && !project ? " (read-only)" : ""
}`;
Expand Down Expand Up @@ -188,7 +187,7 @@ export async function getServerManagerApi(): Promise<any> {
/** Prompt the user to fill in the `path` and `query` of `uri`. */
async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefined> {
if (notIsfs(uri)) return;
const params = new URLSearchParams(uri.query);
const { project, csp, system, generated, mapped, filter } = isfsConfig(uri);
const api = new AtelierAPI(uri);

// Prompt the user for the files to show
Expand All @@ -211,9 +210,7 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
detail: "Choose an existing project, or create a new one.",
},
];
quickPick.activeItems = [
params.has("project") ? quickPick.items[2] : params.has("csp") ? quickPick.items[1] : quickPick.items[0],
];
quickPick.activeItems = [project ? quickPick.items[2] : csp ? quickPick.items[1] : quickPick.items[0]];

quickPick.onDidChangeSelection((items) => {
switch (items[0].label) {
Expand Down Expand Up @@ -258,7 +255,7 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
// Catch handler reported the error already
return;
} else if (cspApps.length == 0) {
vscode.window.showWarningMessage(`No web applications are configured to use namespace ${api.ns}.`, "Dismiss");
vscode.window.showWarningMessage(`No web applications are configured in namespace ${api.ns}.`, "Dismiss");
return;
}
}
Expand Down Expand Up @@ -292,43 +289,43 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
if (!newPath) {
return;
}
newParams = "csp";
newParams = IsfsUriParam.CSP;
} else if (filterType == "project") {
// Prompt for project
const project = await pickProject(new AtelierAPI(uri));
if (!project) {
return;
}
newParams = `project=${project}`;
newParams = `${IsfsUriParam.Project}=${project}`;
} else {
// Prompt the user for other query parameters
const items = [
{
label: "$(filter) Filter",
detail: "Comma-delimited list of search options, e.g. '*.cls,*.inc,*.mac,*.int'",
picked: params.has("filter"),
value: "filter",
picked: filter != "",
value: IsfsUriParam.Filter,
},
{
label: "$(server-process) Show Generated",
detail: "Also show files tagged as generated, e.g. by compilation.",
picked: params.has("generated"),
value: "generated",
picked: generated,
value: IsfsUriParam.Generated,
},
{
label: "$(references) Hide Mapped",
detail: `Hide files that are mapped into ${api.ns} from another code database.`,
picked: params.has("mapped"),
value: "mapped",
picked: !mapped,
value: IsfsUriParam.Mapped,
},
];
if (api.ns != "%SYS") {
// Only show system item for non-%SYS namespaces
items.push({
label: "$(library) Show System",
detail: "Also show '%' items and INFORMATION.SCHEMA items.",
picked: params.has("system"),
value: "system",
picked: system,
value: IsfsUriParam.System,
});
}
const otherParams = await vscode.window.showQuickPick(items, {
Expand All @@ -340,37 +337,29 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
return;
}
// Build the new query parameter string
params.delete("csp");
params.delete("project");
params.delete("filter");
params.delete("flat");
params.delete("generated");
params.delete("mapped");
params.delete("system");
params.delete("type");
const params = new URLSearchParams();
for (const otherParam of otherParams) {
switch (otherParam.value) {
case "filter": {
case IsfsUriParam.Filter: {
// Prompt for filter
const filter = await vscode.window.showInputBox({
const newFilter = await vscode.window.showInputBox({
title: "Enter a filter string.",
ignoreFocusOut: true,
value: params.get("filter"),
value: filter,
placeHolder: "*.cls,*.inc,*.mac,*.int",
prompt:
"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.",
});
if (filter && filter.length) {
params.set(otherParam.value, filter);
if (newFilter && newFilter.length) {
params.set(otherParam.value, newFilter);
}
break;
}
case "generated":
case "system":
params.set(otherParam.value, "1");
break;
case "mapped":
case IsfsUriParam.Mapped:
params.set(otherParam.value, "0");
break;
default: // system and generated
params.set(otherParam.value, "1");
}
}
newParams = params.toString();
Expand Down
Loading