[ACA-823] refactoring (#1077)

This commit is contained in:
Adina Parpalita
2019-04-16 12:01:39 +03:00
committed by Denys Vuika
parent 2e61c49537
commit 2a4be64bcc
9 changed files with 287 additions and 248 deletions

View File

@@ -45,6 +45,11 @@ export class NodesApi extends RepoApi {
return await this.nodesApi.getNode(id);
}
async getNodeIdFromParent(name: string, parentId: string) {
const children = (await this.getNodeChildren(parentId)).list.entries;
return children.find(elem => elem.entry.name === name).entry.id;
}
async getNodeDescription(name: string, parentId: string) {
const children = (await this.getNodeChildren(parentId)).list.entries;
return children.find(elem => elem.entry.name === name).entry.properties['cm:description'];
@@ -245,7 +250,11 @@ export class NodesApi extends RepoApi {
}
async isFileLockedWrite(nodeId: string) {
await this.apiAuth();
return (await this.getLockType(nodeId)) === 'WRITE_LOCK';
}
async isFileLockedByName(fileName: string, parentId: string) {
const id = await this.getNodeIdFromParent(fileName, parentId);
return await this.isFileLockedWrite(id);
}
}