Skip to content

Commit

Permalink
DA#239: Modified: Fix collection directory
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushTyagi1 committed Oct 4, 2023
1 parent 9641dc3 commit b8c0195
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions src/model/IndexDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
* limitations under the License.
*/
import * as vscode from "vscode";
import * as path from "path";
import { IConnection } from "../types/IConnection";
import { INode } from "../types/INode";
import IndexNode from "./IndexNode";
import { Constants } from "../util/constants";
import { getActiveConnection, getConnectionId } from "../util/connections";
import { getActiveConnection } from "../util/connections";
import InformationNode from "./InformationNode";
import { logger } from "../logger/logger";
import { getIndexDefinition } from "../util/indexUtils";
Expand All @@ -31,6 +29,7 @@ export class IndexDirectory implements INode {
public readonly itemName: string,
public readonly bucketName: string,
public readonly scopeName: string,
public readonly collection: string,
public readonly indexes: any[],
public readonly collapsibleState: vscode.TreeItemCollapsibleState
) {
Expand All @@ -46,22 +45,6 @@ export class IndexDirectory implements INode {
label: `${this.itemName}`,
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
contextValue: "indexDirectory",
iconPath: {
light: path.join(
__filename,
"..",
"..",
"images/light",
"scope-item.svg"
),
dark: path.join(
__filename,
"..",
"..",
"images/dark",
"scope-item.svg"
),
},
};
}
/*
Expand All @@ -74,7 +57,7 @@ export class IndexDirectory implements INode {
try {
const connection = getActiveConnection();
//TODO: Change it to not include IndexNode with undefined scope once the issues with undefined scope and collections fixed
result = await connection?.cluster?.queryIndexes().getAllIndexes(this.bucketName, { scopeName: this.scopeName });
result = await connection?.cluster?.queryIndexes().getAllIndexes(this.bucketName, { scopeName: this.scopeName, collectionName: this.collection });
if (result === undefined) { return []; }
for (const query of result) {
if (query.scopeName === this.scopeName || this.scopeName === "_default") {
Expand All @@ -83,7 +66,7 @@ export class IndexDirectory implements INode {
this.connection,
this.scopeName,
this.bucketName,
`${query.name.substring(1)}_${(query.collectionName ?? "")}`,
`${query.name[0] === '#' ? query.name.substring(1) : query.name}${(query.collectionName ? ("_" + query.collectionName) : "")}`,
getIndexDefinition(query),
vscode.TreeItemCollapsibleState.None
);
Expand All @@ -95,9 +78,6 @@ export class IndexDirectory implements INode {
logger.error("Failed to load Indexes");
logger.debug(err);
}
if (indexesList.length === 0) {
indexesList.push(new InformationNode("No Indexes found"));
}
return indexesList;
};
}

0 comments on commit b8c0195

Please sign in to comment.