[ACA-3611] Add parentFolderId variable to getNodeByPath() (#2174)

* Add parentFolderId variable to getNodeByPath()

* update getNodeByPath() usage

* fix

* lint fix
This commit is contained in:
Iulia Burcă
2021-06-14 10:21:11 +03:00
committed by GitHub
parent dc859e276c
commit 97e88e1ce0
2 changed files with 6 additions and 6 deletions

View File

@@ -37,9 +37,9 @@ export class FavoritesApi extends RepoApi {
super(username, password);
}
async addFavorite(api: RepoClient, nodeType: string, name: string) {
async addFavorite(api: RepoClient, nodeType: string, name: string, parentFolderId?: string) {
try {
const nodeId = (await api.nodes.getNodeByPath(name)).entry.id;
const nodeId = (await api.nodes.getNodeByPath(name, parentFolderId)).entry.id;
const data = {
target: {
[nodeType]: {

View File

@@ -36,10 +36,10 @@ export class NodesApi extends RepoApi {
super(username, password);
}
async getNodeByPath(relativePath: string = '/'): Promise<NodeEntry | null> {
async getNodeByPath(relativePath: string = '/', parentFolderId: string = '-my-'): Promise<NodeEntry | null> {
try {
await this.apiAuth();
return await this.nodesApi.getNode('-my-', { relativePath });
return await this.nodesApi.getNode(parentFolderId, { relativePath });
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getNodeByPath.name}`, error);
return null;
@@ -155,9 +155,9 @@ export class NodesApi extends RepoApi {
}
}
async deleteNodeByPath(path: string, permanent: boolean = true): Promise<void> {
async deleteNodeByPath(path: string, permanent: boolean = true, parentFolderId?: string): Promise<void> {
try {
const id = (await this.getNodeByPath(path)).entry.id;
const id = (await this.getNodeByPath(path, parentFolderId)).entry.id;
await this.deleteNodeById(id, permanent);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteNodeByPath.name}`, error);