mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
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:
committed by
Eugenio Romano
parent
26c5982a1a
commit
a7a48e8b2b
@@ -32,7 +32,7 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
|
||||
let widget: AttachFileWidgetDialogComponent;
|
||||
let fixture: ComponentFixture<AttachFileWidgetDialogComponent>;
|
||||
let data: AttachFileWidgetDialogComponentData = {
|
||||
const data: AttachFileWidgetDialogComponentData = {
|
||||
title: 'Move along citizen...',
|
||||
actionName: 'move',
|
||||
selected: new EventEmitter<any>(),
|
||||
@@ -94,8 +94,8 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
spyOn(authService, 'login').and.returnValue(of({ type: 'type', ticket: 'ticket'}));
|
||||
isLogged = true;
|
||||
let loginButton: HTMLButtonElement = element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]');
|
||||
let usernameInput: HTMLInputElement = element.querySelector('#username');
|
||||
let passwordInput: HTMLInputElement = element.querySelector('#password');
|
||||
const usernameInput: HTMLInputElement = element.querySelector('#username');
|
||||
const passwordInput: HTMLInputElement = element.querySelector('#password');
|
||||
usernameInput.value = 'fakse-user';
|
||||
passwordInput.value = 'fakse-user';
|
||||
usernameInput.dispatchEvent(new Event('input'));
|
||||
@@ -105,7 +105,7 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#attach-file-content-node')).not.toBeNull();
|
||||
loginButton = element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]');
|
||||
let chooseButton = element.querySelector('button[data-automation-id="attach-file-dialog-actions-choose"]');
|
||||
const chooseButton = element.querySelector('button[data-automation-id="attach-file-dialog-actions-choose"]');
|
||||
expect(loginButton).toBeNull();
|
||||
expect(chooseButton).not.toBeNull();
|
||||
done();
|
||||
@@ -137,11 +137,11 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
expect(nodeList[0].isFile).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
let fakeNode: Node = new Node({ id: 'fake', isFile: true});
|
||||
const fakeNode: Node = new Node({ id: 'fake', isFile: true});
|
||||
contentNodePanel.componentInstance.select.emit([fakeNode]);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let chooseButton: HTMLButtonElement = element.querySelector('button[data-automation-id="attach-file-dialog-actions-choose"]');
|
||||
const chooseButton: HTMLButtonElement = element.querySelector('button[data-automation-id="attach-file-dialog-actions-choose"]');
|
||||
chooseButton.click();
|
||||
});
|
||||
});
|
||||
|
@@ -27,7 +27,6 @@ describe('AttachFileWidgetDialogService', () => {
|
||||
let service: AttachFileWidgetDialogService;
|
||||
let materialDialog: MatDialog;
|
||||
let spyOnDialogOpen: jasmine.Spy;
|
||||
let afterOpenObservable: Subject<any>;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -40,7 +39,7 @@ describe('AttachFileWidgetDialogService', () => {
|
||||
service = TestBed.get(AttachFileWidgetDialogService);
|
||||
materialDialog = TestBed.get(MatDialog);
|
||||
spyOnDialogOpen = spyOn(materialDialog, 'open').and.returnValue({
|
||||
afterOpen: () => afterOpenObservable,
|
||||
afterOpen: () => of({}),
|
||||
afterClosed: () => of({}),
|
||||
componentInstance: {
|
||||
error: new Subject<any>()
|
||||
|
@@ -41,7 +41,7 @@ export class AttachFileWidgetDialogService {
|
||||
* @returns Information about the chosen file(s)
|
||||
*/
|
||||
openLogin(ecmHost: string, actionName?: string, context?: string): Observable<Node[]> {
|
||||
let titleString: string = `Please log in for ${ecmHost}`;
|
||||
const titleString: string = `Please log in for ${ecmHost}`;
|
||||
const selected = new Subject<Node[]>();
|
||||
selected.subscribe({
|
||||
complete: this.close.bind(this)
|
||||
|
@@ -130,7 +130,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
}
|
||||
|
||||
openSelectDialogFromFileSource() {
|
||||
let params = this.field.params;
|
||||
const params = this.field.params;
|
||||
if (this.isDefinedSourceFolder()) {
|
||||
this.contentDialog.openFileBrowseDialogByFolderId(params.fileSource.selectedFolder.pathId).subscribe(
|
||||
(selections: Node[]) => {
|
||||
@@ -183,10 +183,10 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
|
||||
openSelectDialog(repository) {
|
||||
const accountIdentifier = 'alfresco-' + repository.id + '-' + repository.name;
|
||||
let currentECMHost = this.getDomainHost(this.appConfigService.get(AppConfigValues.ECMHOST));
|
||||
let chosenRepositoryHost = this.getDomainHost(repository.repositoryUrl);
|
||||
const currentECMHost = this.getDomainHost(this.appConfigService.get(AppConfigValues.ECMHOST));
|
||||
const chosenRepositoryHost = this.getDomainHost(repository.repositoryUrl);
|
||||
if (chosenRepositoryHost !== currentECMHost) {
|
||||
let formattedRepositoryHost = repository.repositoryUrl.replace('/alfresco', '');
|
||||
const formattedRepositoryHost = repository.repositoryUrl.replace('/alfresco', '');
|
||||
this.attachDialogService.openLogin(formattedRepositoryHost).subscribe(
|
||||
(selections: any[]) => {
|
||||
selections.forEach((node) => node.isExternal = true);
|
||||
@@ -229,7 +229,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
}
|
||||
|
||||
private getDomainHost(urlToCheck) {
|
||||
let result = urlToCheck.match('^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/?\n]+)');
|
||||
const result = urlToCheck.match('^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/?\n]+)');
|
||||
return result[1];
|
||||
}
|
||||
|
||||
|
@@ -155,7 +155,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||
fixture.detectChanges();
|
||||
fixture.whenRenderingDone().then(() => {
|
||||
let attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||
expect(attachButton).not.toBeNull();
|
||||
attachButton.click();
|
||||
fixture.detectChanges();
|
||||
@@ -182,7 +182,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
widget.field.params = <FormFieldMetadata> allSourceParams;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||
expect(attachButton).not.toBeNull();
|
||||
attachButton.click();
|
||||
fixture.detectChanges();
|
||||
@@ -206,7 +206,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
spyOn(contentNodeDialogService, 'openFileBrowseDialogByFolderId').and.returnValue(of([fakeMinimalNode]));
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||
expect(attachButton).not.toBeNull();
|
||||
attachButton.click();
|
||||
fixture.detectChanges();
|
||||
@@ -228,7 +228,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
spyOn(processContentService, 'createTemporaryRawRelatedContent').and.returnValue(of(fakePngAnswer));
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let inputDebugElement = fixture.debugElement.query(By.css('#attach-file-attach'));
|
||||
const inputDebugElement = fixture.debugElement.query(By.css('#attach-file-attach'));
|
||||
inputDebugElement.triggerEventHandler('change', { target: { files: [fakePngAnswer] } });
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -263,7 +263,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
spyOn(processContentService, 'createTemporaryRawRelatedContent').and.returnValue(of(fakePngAnswer));
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let inputDebugElement = fixture.debugElement.query(By.css('#attach-file-attach'));
|
||||
const inputDebugElement = fixture.debugElement.query(By.css('#attach-file-attach'));
|
||||
inputDebugElement.triggerEventHandler('change', {target: {files: [fakePngAnswer]}});
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#file-1155-icon')).not.toBeNull();
|
||||
@@ -271,7 +271,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
}));
|
||||
|
||||
it('should show the action menu', async(() => {
|
||||
let menuButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#file-1155-option-menu');
|
||||
const menuButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#file-1155-option-menu');
|
||||
expect(menuButton).not.toBeNull();
|
||||
menuButton.click();
|
||||
fixture.detectChanges();
|
||||
@@ -283,7 +283,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
}));
|
||||
|
||||
it('should remove file when remove is clicked', async(() => {
|
||||
let menuButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#file-1155-option-menu');
|
||||
const menuButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#file-1155-option-menu');
|
||||
expect(menuButton).not.toBeNull();
|
||||
menuButton.click();
|
||||
fixture.detectChanges();
|
||||
@@ -297,7 +297,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
|
||||
it('should download file when download is clicked', async(() => {
|
||||
spyOn(contentService, 'downloadBlob').and.stub();
|
||||
let menuButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#file-1155-option-menu');
|
||||
const menuButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#file-1155-option-menu');
|
||||
expect(menuButton).not.toBeNull();
|
||||
menuButton.click();
|
||||
fixture.detectChanges();
|
||||
@@ -314,7 +314,7 @@ describe('AttachFileWidgetComponent', () => {
|
||||
expect(file).not.toBeNull();
|
||||
expect(file.id).toBe(1155);
|
||||
});
|
||||
let menuButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#file-1155-option-menu');
|
||||
const menuButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#file-1155-option-menu');
|
||||
expect(menuButton).not.toBeNull();
|
||||
menuButton.click();
|
||||
fixture.detectChanges();
|
||||
|
@@ -71,7 +71,7 @@ export class AttachFolderWidgetComponent extends WidgetComponent implements OnIn
|
||||
}
|
||||
|
||||
openSelectDialogFromFileSource() {
|
||||
let params = this.field.params;
|
||||
const params = this.field.params;
|
||||
if (this.isDefinedSourceFolder()) {
|
||||
this.contentDialog.openFolderBrowseDialogByFolderId(params.folderSource.selectedFolder.pathId).subscribe(
|
||||
(selections: Node[]) => {
|
||||
|
Reference in New Issue
Block a user