mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
Sonarcloud issues fixes (#3499)
* Sonarcloud issues fixes * Code smell fixes * Refactoring to remove new code duplications * Sonarcloud code smell fixes part I * Sonarcloud code smell fixes part II * Missing code smell fix * Add new ESLint rules to cover fixed SonarCloud issues * Add missing command * Add missing is existing check
This commit is contained in:
@@ -58,12 +58,7 @@ export class LoginComponent extends Component {
|
||||
const type = await this.passwordInput.getAttribute('type');
|
||||
if (type === 'text') {
|
||||
return true;
|
||||
} else {
|
||||
if (type === 'password') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -28,10 +28,6 @@ import { UserActions } from './user-actions';
|
||||
import { browser } from 'protractor';
|
||||
|
||||
export class AdminActions extends UserActions {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
sites: SitesApi = new SitesApi();
|
||||
upload: UploadApi = new UploadApi();
|
||||
nodes: NodesApi = new NodesApi();
|
||||
@@ -42,12 +38,10 @@ export class AdminActions extends UserActions {
|
||||
}
|
||||
|
||||
private async getDataDictionaryId(): Promise<string> {
|
||||
try {
|
||||
return this.nodes.getNodeIdFromParent('Data Dictionary', '-root-');
|
||||
} catch (error) {
|
||||
return this.nodes.getNodeIdFromParent('Data Dictionary', '-root-').catch((error) => {
|
||||
super.handleError('Admin Actions - getDataDictionaryId failed : ', error);
|
||||
return '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async getNodeTemplatesFolderId(): Promise<string> {
|
||||
@@ -106,19 +100,15 @@ export class AdminActions extends UserActions {
|
||||
}
|
||||
|
||||
async createNodeTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
|
||||
try {
|
||||
return this.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`);
|
||||
} catch (error) {
|
||||
return this.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`).catch((error) => {
|
||||
super.handleError('Admin Actions - createNodeTemplatesHierarchy failed : ', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async createSpaceTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
|
||||
try {
|
||||
return this.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`);
|
||||
} catch (error) {
|
||||
return this.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`).catch((error) => {
|
||||
super.handleError('Admin Actions - createSpaceTemplatesHierarchy failed : ', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async removeUserAccessOnNodeTemplate(nodeName: string): Promise<NodeEntry> {
|
||||
|
@@ -97,22 +97,20 @@ export class SharedLinksApi extends RepoApi {
|
||||
}
|
||||
|
||||
async waitForFilesToBeShared(filesIds: string[]): Promise<any> {
|
||||
try {
|
||||
const sharedFile = async () => {
|
||||
const sharedFiles = (await this.getSharedLinks()).list.entries.map((link) => link.entry.nodeId);
|
||||
const foundItems = filesIds.every((id) => sharedFiles.includes(id));
|
||||
if (foundItems) {
|
||||
return Promise.resolve(foundItems);
|
||||
} else {
|
||||
return Promise.reject(foundItems);
|
||||
}
|
||||
};
|
||||
const sharedFile = async () => {
|
||||
const sharedFiles = (await this.getSharedLinks()).list.entries.map((link) => link.entry.nodeId);
|
||||
const foundItems = filesIds.every((id) => sharedFiles.includes(id));
|
||||
if (foundItems) {
|
||||
return Promise.resolve(foundItems);
|
||||
} else {
|
||||
return Promise.reject(foundItems);
|
||||
}
|
||||
};
|
||||
|
||||
return Utils.retryCall(sharedFile);
|
||||
} catch (error) {
|
||||
return Utils.retryCall(sharedFile).catch((error) => {
|
||||
Logger.error(`SharedLinksApi waitForFilesToBeShared : catch : ${error}`);
|
||||
Logger.error(`\tWait timeout reached waiting for files to be shared`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async waitForFilesToNotBeShared(filesIds: string[]): Promise<any> {
|
||||
|
@@ -142,20 +142,18 @@ export class UserActions {
|
||||
* @param expectedSize Size of the trashcan to wait for.
|
||||
*/
|
||||
async waitForTrashcanSize(expectedSize: number): Promise<number> {
|
||||
try {
|
||||
return Utils.retryCall(async () => {
|
||||
const totalItems = await this.getTrashcanSize();
|
||||
return Utils.retryCall(async () => {
|
||||
const totalItems = await this.getTrashcanSize();
|
||||
|
||||
if (totalItems !== expectedSize) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
return Promise.resolve(totalItems);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
if (totalItems !== expectedSize) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
return Promise.resolve(totalItems);
|
||||
}
|
||||
}).catch((error) => {
|
||||
this.handleError('User Actions - waitForTrashcanSize failed : ', error);
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async lockNodes(nodeIds: string[], lockType: string = 'ALLOW_OWNER_CHANGES') {
|
||||
|
Reference in New Issue
Block a user