Skip to content

Commit 11601be

Browse files
committed
Eliminate webapps without a physical path
1 parent dc12be8 commit 11601be

File tree

2 files changed

+31
-40
lines changed

2 files changed

+31
-40
lines changed

src/api/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,12 @@ export class AtelierAPI {
496496
};
497497
return this.request(1, "GET", `%SYS/jobs`, null, params);
498498
}
499+
500+
// v1+
501+
public getCSPApps(detail = false): Promise<Atelier.Response> {
502+
const params = {
503+
detail: detail ? 1 : 0,
504+
};
505+
return this.request(1, "GET", `%SYS/cspapps/${this.ns || ""}`, null, params);
506+
}
499507
}

src/providers/FileSystemPovider/FileSystemProvider.ts

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,36 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
7676
const flat = query.flat && query.flat.length ? query.flat.toString() : "0";
7777
const notStudio = "0";
7878
const generated = query.generated && query.generated.length ? query.generated.toString() : "0";
79+
// get all web apps that have a filepath (Studio dialog used below returns REST ones too)
80+
const cspApps = csp ? await api.getCSPApps().then((data) => data.result.content || []) : [];
81+
const cspSubfolderMap = new Map<string, vscode.FileType>();
82+
const prefix = folder === "" ? "/" : folder;
83+
for (const app of cspApps) {
84+
if ((app + "/").startsWith(prefix)) {
85+
const subfolder = app.slice(prefix.length).split("/")[0];
86+
if (subfolder) {
87+
cspSubfolderMap.set(subfolder, vscode.FileType.Directory);
88+
}
89+
}
90+
}
91+
const cspSubfolders = Array.from(cspSubfolderMap.entries());
92+
// Assemble the results
7993
return api
8094
.actionQuery(sql, [spec, dir, orderBy, system, flat, notStudio, generated])
8195
.then((data) => data.result.content || [])
8296
.then((data) => {
8397
const results = data
8498
.filter((item: StudioOpenDialog) =>
85-
item.Type === "10" ? csp && item.Name !== "/" : item.Type === "9" ? !csp : csp ? item.Type === "5" : true
99+
item.Type === "10"
100+
? csp && !item.Name.includes("/") // ignore web apps here because there may be REST ones
101+
: item.Type === "9" // class package
102+
? !csp
103+
: csp
104+
? item.Type === "5" // web app file
105+
: true
86106
)
87107
.map((item: StudioOpenDialog) => {
88-
// Handle how query returns web apps
89-
const name = item.Name.split("/")[0];
108+
const name = item.Name;
90109
const fullName = folder === "" ? name : csp ? folder + name : folder + "/" + name;
91110
if (item.Type === "10" || item.Type === "9") {
92111
parent.entries.set(name, new Directory(name, fullName));
@@ -98,43 +117,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
98117
if (!csp) {
99118
return results;
100119
}
101-
if (folder !== "") {
102-
// For CSP-type access at least one folder down, a further root-level request is done to check for next level in CSP app names
103-
// e.g. folder root is isfs://server/?ns=USER&csp
104-
// and USER namespace is the home of /csp/app1 and /csp/app2
105-
// Initial expand showed the csp folder.
106-
// Expand of that came here and asked Studio dialog query for /csp/*
107-
// but this doesn't return app1 and app2 folders.
108-
// Filter out as much as possible on the server side.
109-
return api
110-
.actionQuery(sql, [
111-
"*,'*.inc,'*.mac,'*.dtl,'*.cls,'*.bpl,'*.int,'*.prj",
112-
dir,
113-
orderBy,
114-
"0",
115-
"0",
116-
notStudio,
117-
"0",
118-
])
119-
.then((data) => data.result.content || [])
120-
.then((data) => {
121-
const piece = folder.split("/").length - 1;
122-
const cspSubdirs: [string, vscode.FileType][] = data
123-
.filter(
124-
(item) =>
125-
item.Type === "10" && item.Name.startsWith(folder.slice(1)) && item.Name.length >= folder.length
126-
)
127-
.map((item) => {
128-
const name = item.Name.split("/")[piece - 1];
129-
parent.entries.set(name, new Directory(name, folder + name));
130-
return [name, vscode.FileType.Directory];
131-
});
132-
return results.concat(cspSubdirs);
133-
});
134-
} else {
135-
// Nothing else to add.
136-
return results;
137-
}
120+
return results.concat(cspSubfolders);
138121
})
139122
.catch((error) => {
140123
error && console.error(error);

0 commit comments

Comments
 (0)