Skip to content

Commit

Permalink
Don't show REST APIs in Explorer CSP Files list (#1248)
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-bsaviano authored Oct 10, 2023
1 parent 8194d56 commit 9c52efd
Showing 1 changed file with 41 additions and 22 deletions.
63 changes: 41 additions & 22 deletions src/explorer/models/rootNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RoutineNode } from "./routineNode";
import { AtelierAPI } from "../../api";
import { ClassNode } from "./classNode";
import { CSPFileNode } from "./cspFileNode";
import { cspApps } from "../../extension";

type IconPath =
| string
Expand Down Expand Up @@ -57,7 +58,7 @@ export class RootNode extends NodeBase {
return this.getItems(path, this._category);
}

public getList(
public async getList(
path: string,
category: string,
flat: boolean
Expand All @@ -81,7 +82,7 @@ export class RootNode extends NodeBase {
spec = "*";
break;
case "OTH":
spec = "*";
spec = "*.other";
break;
default:
return;
Expand All @@ -97,27 +98,45 @@ export class RootNode extends NodeBase {

const api = new AtelierAPI(this.workspaceFolder);
api.setNamespace(this.namespace);
return api
.actionQuery(sql, [spec, direction, orderBy, systemFiles, flat ? "1" : "0", notStudio, generated])
.then((data) => {
const content = data.result.content;
return content;
})
.then((data) =>
data.map((el: { Name: string; Type: number }) => {
let fullName = el.Name;
if (this instanceof PackageNode) {
fullName = this.fullName + "." + el.Name;
} else if (this.isCsp) {
fullName = this.fullName + "/" + el.Name;
}
return {
Name: el.Name,
Type: String(el.Type),
fullName,
};
if (category == "CSP" && path == "") {
// Use the results from the getCSPApps() API
const cspAppsKey = (
api.config.serverName && api.config.serverName != ""
? `${api.config.serverName}:${api.config.ns}`
: `${api.config.host}:${api.config.port}${api.config.pathPrefix}:${api.config.ns}`
).toLowerCase();
let nsCspApps: string[] | undefined = cspApps.get(cspAppsKey);
if (nsCspApps == undefined) {
nsCspApps = await api.getCSPApps().then((data) => data.result.content || []);
cspApps.set(cspAppsKey, nsCspApps);
}
return nsCspApps.map((cspApp) => {
return { Name: cspApp.slice(1), fullName: cspApp.slice(1), Type: "10" };
});
} else {
// Use StudioOpenDialog
return api
.actionQuery(sql, [spec, direction, orderBy, systemFiles, flat ? "1" : "0", notStudio, generated])
.then((data) => {
const content = data.result.content;
return content;
})
);
.then((data) =>
data.map((el: { Name: string; Type: number }) => {
let fullName = el.Name;
if (this instanceof PackageNode) {
fullName = this.fullName + "." + el.Name;
} else if (this.isCsp) {
fullName = this.fullName + "/" + el.Name;
}
return {
Name: el.Name,
Type: String(el.Type),
fullName,
};
})
);
}
}

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

0 comments on commit 9c52efd

Please sign in to comment.