enable prefer-const rule for tslint, fix issues (#4409)

* enable prefer-const rule for tslint, fix issues

* Update content-node-selector.component.spec.ts

* Update content-node-selector.component.spec.ts

* fix const

* fix lint issues

* update tests

* update tests

* update tests

* fix code

* fix page class
This commit is contained in:
Denys Vuika
2019-03-25 12:19:33 +00:00
committed by Eugenio Romano
parent 26c5982a1a
commit a7a48e8b2b
581 changed files with 5435 additions and 5402 deletions

View File

@@ -116,7 +116,7 @@ export abstract class UploadBase implements OnInit, OnDestroy {
}
private uploadQueue(files: FileModel[]) {
let filteredFiles = files
const filteredFiles = files
.filter(this.isFileAcceptable.bind(this))
.filter(this.isFileSizeAcceptable.bind(this));

View File

@@ -88,7 +88,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
this.uploadService.fileDeleted.subscribe((objId) => {
if (this.filesUploadingList) {
let file = this.filesUploadingList.find((item) => {
const file = this.filesUploadingList.find((item) => {
return item.data.entry.id === objId;
});
if (file) {

View File

@@ -23,7 +23,7 @@ import { FileUploadingListRowComponent } from './file-uploading-list-row.compone
describe('FileUploadingListRowComponent', () => {
let fixture: ComponentFixture<FileUploadingListRowComponent>;
let component: FileUploadingListRowComponent;
let file = new FileModel(<File> { name: 'fake-name' });
const file = new FileModel(<File> { name: 'fake-name' });
beforeEach(() => {
TestBed.configureTestingModule({

View File

@@ -26,15 +26,15 @@ import { NodeEntry } from '@alfresco/js-api';
describe('UploadButtonComponent', () => {
let file = { name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json' };
let fakeEvent = {
const file = { name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json' };
const fakeEvent = {
currentTarget: {
files: [file]
},
target: { value: 'fake-name-1' }
};
let fakeFolderNodeWithPermission = new NodeEntry({
const fakeFolderNodeWithPermission = new NodeEntry({
entry: {
allowableOperations: [
'create',
@@ -82,21 +82,21 @@ describe('UploadButtonComponent', () => {
it('should render upload-single-file button as default', () => {
component.multipleFiles = false;
let compiled = fixture.debugElement.nativeElement;
const compiled = fixture.debugElement.nativeElement;
fixture.detectChanges();
expect(compiled.querySelector('#upload-single-file')).toBeDefined();
});
it('should render upload-multiple-file button if multipleFiles is true', () => {
component.multipleFiles = true;
let compiled = fixture.debugElement.nativeElement;
const compiled = fixture.debugElement.nativeElement;
fixture.detectChanges();
expect(compiled.querySelector('#upload-multiple-files')).toBeDefined();
});
it('should render an uploadFolder button if uploadFolder is true', () => {
component.uploadFolders = true;
let compiled = fixture.debugElement.nativeElement;
const compiled = fixture.debugElement.nativeElement;
fixture.detectChanges();
expect(compiled.querySelector('#uploadFolder')).toBeDefined();
});
@@ -104,7 +104,7 @@ describe('UploadButtonComponent', () => {
it('should disable uploadFolder button if disabled is true', () => {
component.disabled = true;
component.uploadFolders = true;
let compiled = fixture.debugElement.nativeElement;
const compiled = fixture.debugElement.nativeElement;
fixture.detectChanges();
expect(compiled.querySelector('#uploadFolder').getAttribute('disabled')).toBe('true');
});
@@ -112,7 +112,7 @@ describe('UploadButtonComponent', () => {
it('should disable upload-single-file button if disabled is true', () => {
component.disabled = true;
component.multipleFiles = false;
let compiled = fixture.debugElement.nativeElement;
const compiled = fixture.debugElement.nativeElement;
fixture.detectChanges();
expect(compiled.querySelector('#upload-single-file').getAttribute('disabled')).toBe('true');
});
@@ -182,7 +182,7 @@ describe('UploadButtonComponent', () => {
});
it('should by default the title of the button get from the JSON file', () => {
let compiled = fixture.debugElement.nativeElement;
const compiled = fixture.debugElement.nativeElement;
fixture.detectChanges();
component.uploadFolders = false;
component.multipleFiles = false;
@@ -199,7 +199,7 @@ describe('UploadButtonComponent', () => {
});
it('should staticTitle properties change the title of the upload buttons', () => {
let compiled = fixture.debugElement.nativeElement;
const compiled = fixture.debugElement.nativeElement;
component.staticTitle = 'test-text';
component.uploadFolders = false;
component.multipleFiles = false;

View File

@@ -78,7 +78,7 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
}
ngOnChanges(changes: SimpleChanges) {
let rootFolderId = changes['rootFolderId'];
const rootFolderId = changes['rootFolderId'];
if (rootFolderId && rootFolderId.currentValue) {
this.checkPermission();
}
@@ -89,7 +89,7 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
}
onFilesAdded($event: any): void {
let files: File[] = FileUtils.toFileArray($event.currentTarget.files);
const files: File[] = FileUtils.toFileArray($event.currentTarget.files);
if (this.hasAllowableOperations) {
this.uploadFiles(files);
@@ -102,7 +102,7 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
onDirectoryAdded($event: any): void {
if (this.hasAllowableOperations) {
let files: File[] = FileUtils.toFileArray($event.currentTarget.files);
const files: File[] = FileUtils.toFileArray($event.currentTarget.files);
this.uploadFiles(files);
} else {
this.permissionEvent.emit(new PermissionModel({ type: 'content', action: 'upload', permission: 'create' }));
@@ -113,7 +113,7 @@ export class UploadButtonComponent extends UploadBase implements OnInit, OnChang
checkPermission() {
if (this.rootFolderId) {
let opts: any = {
const opts: any = {
includeSource: true,
include: ['allowableOperations']
};

View File

@@ -163,7 +163,7 @@ describe('UploadDragAreaComponent', () => {
spyOn(uploadService, 'uploadFilesInTheQueue');
fixture.detectChanges();
let itemEntity = {
const itemEntity = {
isDirectory: true,
createReader: () => {
return {
@@ -187,20 +187,20 @@ describe('UploadDragAreaComponent', () => {
spyOn(uploadService, 'addToQueue');
spyOn(uploadService, 'uploadFilesInTheQueue');
let fakeItem = {
const fakeItem = {
fullPath: '/folder-fake/file-fake.png',
isDirectory: false,
isFile: true,
relativeFolder: '/',
name: 'file-fake.png',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
fixture.detectChanges();
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
detail: { data: getFakeShareDataRow([]), files: [fakeItem] }
});
component.onUploadFiles(fakeCustomEvent);
@@ -288,19 +288,19 @@ describe('UploadDragAreaComponent', () => {
}));
it('should upload a file when user has create permission on target folder', async(() => {
let fakeItem = {
const fakeItem = {
fullPath: '/folder-fake/file-fake.png',
isDirectory: false,
isFile: true,
name: 'file-fake.png',
relativeFolder: '/',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
detail: {
data: getFakeShareDataRow(),
files: [fakeItem]
@@ -313,14 +313,14 @@ describe('UploadDragAreaComponent', () => {
it('should upload a file to a specific target folder when dropped onto one', async(() => {
let fakeItem = {
const fakeItem = {
fullPath: '/folder-fake/file-fake.png',
isDirectory: false,
isFile: true,
name: 'file-fake.png',
relativeFolder: '/',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
@@ -330,7 +330,7 @@ describe('UploadDragAreaComponent', () => {
expect(fileList.options.path).toBe('pippo/');
});
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
detail: {
data: getFakeShareDataRow(),
files: [fakeItem]
@@ -342,14 +342,14 @@ describe('UploadDragAreaComponent', () => {
it('should upload a folder to a specific target folder when dropped onto one', async(() => {
let fakeItem = {
const fakeItem = {
fullPath: '/folder-fake/file-fake.png',
isDirectory: false,
isFile: true,
name: 'file-fake.png',
relativeFolder: '/super',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
@@ -359,7 +359,7 @@ describe('UploadDragAreaComponent', () => {
expect(fileList.options.path).toBe('pippo/super');
});
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
detail: {
data: getFakeShareDataRow(),
files: [fakeItem]
@@ -371,14 +371,14 @@ describe('UploadDragAreaComponent', () => {
it('should upload the file in the current folder when the target is file', async(() => {
let fakeItem = {
const fakeItem = {
fullPath: '/folder-fake/file-fake.png',
isDirectory: false,
isFile: true,
name: 'file-fake.png',
relativeFolder: '/',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
@@ -388,7 +388,7 @@ describe('UploadDragAreaComponent', () => {
expect(fileList.options.path).toBe('/');
});
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
detail: {
data: getFakeFileShareRow(),
files: [fakeItem]
@@ -404,14 +404,14 @@ describe('UploadDragAreaComponent', () => {
it('should raise an error if upload a file goes wrong', (done) => {
spyOn(uploadService, 'getUploadPromise').and.callThrough();
let fakeItem = {
const fakeItem = {
fullPath: '/folder-fake/file-fake.png',
isDirectory: false,
isFile: true,
relativeFolder: '/',
name: 'file-fake.png',
file: (callbackFile) => {
let fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
const fileFake = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
callbackFile(fileFake);
}
};
@@ -424,7 +424,7 @@ describe('UploadDragAreaComponent', () => {
done();
});
let fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
detail: {
data: getFakeShareDataRow(),
files: [fakeItem]

View File

@@ -94,9 +94,9 @@ export class UploadDragAreaComponent extends UploadBase implements NodeAllowable
onUploadFiles(event: CustomEvent) {
event.stopPropagation();
event.preventDefault();
let isAllowed: boolean = this.contentService.hasAllowableOperations(event.detail.data.obj.entry, AllowableOperationsEnum.CREATE);
const isAllowed: boolean = this.contentService.hasAllowableOperations(event.detail.data.obj.entry, AllowableOperationsEnum.CREATE);
if (isAllowed) {
let fileInfo: FileInfo[] = event.detail.files;
const fileInfo: FileInfo[] = event.detail.files;
if (this.isTargetNodeFolder(event)) {
const destinationFolderName = event.detail.data.obj.entry.name;
fileInfo.map((file) => file.relativeFolder = destinationFolderName ? destinationFolderName.concat(file.relativeFolder) : file.relativeFolder);