various code quality fixes (#5792)

* various code quality fixes

* reduce duplicated code

* add safety check
This commit is contained in:
Denys Vuika
2020-06-18 17:57:46 +01:00
committed by GitHub
parent dc2060fe49
commit e9350bd297
54 changed files with 96 additions and 154 deletions

View File

@@ -136,7 +136,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
}
hasPreviousNodes(): boolean {
return this.previousNodes ? true : false;
return !!this.previousNodes;
}
parseRoute(node: Node): PathElementEntity[] {

View File

@@ -210,7 +210,7 @@ export class ContentNodeDialogService {
actionName: action,
currentFolderId: contentEntry.id,
imageResolver: this.imageResolver.bind(this),
isSelectionValid: this.isNodeFile.bind(this),
isSelectionValid: (entry: Node) => entry.isFile,
select: select,
showFilesInResult
};
@@ -234,10 +234,6 @@ export class ContentNodeDialogService {
return null;
}
private isNodeFile(entry: Node): boolean {
return entry.isFile;
}
private hasAllowableOperationsOnNodeFolder(entry: Node): boolean {
return this.isNodeFolder(entry) && this.contentService.hasAllowableOperations(entry, 'create');
}

View File

@@ -87,7 +87,7 @@ describe('NodeSharedDirective', () => {
});
it('should have share button disabled when selection is empty', async () => {
fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
expect(shareButtonElement.disabled).toBe(true);
});
@@ -96,7 +96,7 @@ describe('NodeSharedDirective', () => {
component.documentList.selection = [selection];
fixture.detectChanges();
fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
expect(shareButtonElement.disabled).toBe(false);
});
@@ -106,7 +106,7 @@ describe('NodeSharedDirective', () => {
component.documentList.selection = [selection];
fixture.detectChanges();
fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
expect(shareButtonElement.disabled).toBe(true);
});
@@ -115,7 +115,7 @@ describe('NodeSharedDirective', () => {
component.documentList.selection = [selection];
fixture.detectChanges();
fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
expect(shareButtonElement.title).toBe('Not Shared');
});
@@ -124,7 +124,7 @@ describe('NodeSharedDirective', () => {
selection.entry.properties['qshare:sharedId'] = 'someId';
component.documentList.selection = [selection];
fixture.detectChanges();
fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
expect(shareButtonElement.title).toBe('Shared');
@@ -135,7 +135,7 @@ describe('NodeSharedDirective', () => {
component.documentList.selection = [selection];
fixture.detectChanges();
fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
shareButtonElement.click();

View File

@@ -101,7 +101,7 @@ export class SearchControlComponent implements OnDestroy {
) {}
isNoSearchTemplatePresent(): boolean {
return this.emptySearchTemplate ? true : false;
return !!this.emptySearchTemplate;
}
ngOnDestroy(): void {

View File

@@ -96,7 +96,6 @@ export abstract class UploadBase implements OnInit, OnDestroy {
/**
* Upload a list of file in the specified path
* @param files
* @param path
*/
uploadFiles(files: File[]): void {
const filteredFiles: FileModel[] = files
@@ -152,17 +151,16 @@ export abstract class UploadBase implements OnInit, OnDestroy {
.split(',')
.map((ext) => ext.trim().replace(/^\./, ''));
if (allowedExtensions.indexOf(file.extension) !== -1) {
return true;
}
return false;
return allowedExtensions.indexOf(file.extension) !== -1;
}
/**
* Creates FileModel from File
*
* @param file
* @param parentId
* @param path
* @param id
*/
protected createFileModel(file: File, parentId: string, path: string, id?: string): FileModel {
return new FileModel(file, {

View File

@@ -55,7 +55,7 @@ export class VersionUploadComponent {
}
isMajorVersion(): boolean {
return this.semanticVersion === 'minor' ? false : true;
return this.semanticVersion !== 'minor';
}
cancelUpload() {