Skip to content

Commit 9c52efd

Browse files
authored
Don't show REST APIs in Explorer CSP Files list (#1248)
1 parent 8194d56 commit 9c52efd

File tree

1 file changed

+41
-22
lines changed

1 file changed

+41
-22
lines changed

src/explorer/models/rootNode.ts

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { RoutineNode } from "./routineNode";
66
import { AtelierAPI } from "../../api";
77
import { ClassNode } from "./classNode";
88
import { CSPFileNode } from "./cspFileNode";
9+
import { cspApps } from "../../extension";
910

1011
type IconPath =
1112
| string
@@ -57,7 +58,7 @@ export class RootNode extends NodeBase {
5758
return this.getItems(path, this._category);
5859
}
5960

60-
public getList(
61+
public async getList(
6162
path: string,
6263
category: string,
6364
flat: boolean
@@ -81,7 +82,7 @@ export class RootNode extends NodeBase {
8182
spec = "*";
8283
break;
8384
case "OTH":
84-
spec = "*";
85+
spec = "*.other";
8586
break;
8687
default:
8788
return;
@@ -97,27 +98,45 @@ export class RootNode extends NodeBase {
9798

9899
const api = new AtelierAPI(this.workspaceFolder);
99100
api.setNamespace(this.namespace);
100-
return api
101-
.actionQuery(sql, [spec, direction, orderBy, systemFiles, flat ? "1" : "0", notStudio, generated])
102-
.then((data) => {
103-
const content = data.result.content;
104-
return content;
105-
})
106-
.then((data) =>
107-
data.map((el: { Name: string; Type: number }) => {
108-
let fullName = el.Name;
109-
if (this instanceof PackageNode) {
110-
fullName = this.fullName + "." + el.Name;
111-
} else if (this.isCsp) {
112-
fullName = this.fullName + "/" + el.Name;
113-
}
114-
return {
115-
Name: el.Name,
116-
Type: String(el.Type),
117-
fullName,
118-
};
101+
if (category == "CSP" && path == "") {
102+
// Use the results from the getCSPApps() API
103+
const cspAppsKey = (
104+
api.config.serverName && api.config.serverName != ""
105+
? `${api.config.serverName}:${api.config.ns}`
106+
: `${api.config.host}:${api.config.port}${api.config.pathPrefix}:${api.config.ns}`
107+
).toLowerCase();
108+
let nsCspApps: string[] | undefined = cspApps.get(cspAppsKey);
109+
if (nsCspApps == undefined) {
110+
nsCspApps = await api.getCSPApps().then((data) => data.result.content || []);
111+
cspApps.set(cspAppsKey, nsCspApps);
112+
}
113+
return nsCspApps.map((cspApp) => {
114+
return { Name: cspApp.slice(1), fullName: cspApp.slice(1), Type: "10" };
115+
});
116+
} else {
117+
// Use StudioOpenDialog
118+
return api
119+
.actionQuery(sql, [spec, direction, orderBy, systemFiles, flat ? "1" : "0", notStudio, generated])
120+
.then((data) => {
121+
const content = data.result.content;
122+
return content;
119123
})
120-
);
124+
.then((data) =>
125+
data.map((el: { Name: string; Type: number }) => {
126+
let fullName = el.Name;
127+
if (this instanceof PackageNode) {
128+
fullName = this.fullName + "." + el.Name;
129+
} else if (this.isCsp) {
130+
fullName = this.fullName + "/" + el.Name;
131+
}
132+
return {
133+
Name: el.Name,
134+
Type: String(el.Type),
135+
fullName,
136+
};
137+
})
138+
);
139+
}
121140
}
122141

123142
public getItems(path: string, category: string): Promise<NodeBase[]> {

0 commit comments

Comments
 (0)