mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
various code quality fixes (#5792)
* various code quality fixes * reduce duplicated code * add safety check
This commit is contained in:
@@ -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[] {
|
||||
|
@@ -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');
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -101,7 +101,7 @@ export class SearchControlComponent implements OnDestroy {
|
||||
) {}
|
||||
|
||||
isNoSearchTemplatePresent(): boolean {
|
||||
return this.emptySearchTemplate ? true : false;
|
||||
return !!this.emptySearchTemplate;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
@@ -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, {
|
||||
|
@@ -55,7 +55,7 @@ export class VersionUploadComponent {
|
||||
}
|
||||
|
||||
isMajorVersion(): boolean {
|
||||
return this.semanticVersion === 'minor' ? false : true;
|
||||
return this.semanticVersion !== 'minor';
|
||||
}
|
||||
|
||||
cancelUpload() {
|
||||
|
Reference in New Issue
Block a user