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

@@ -32,7 +32,7 @@ describe('AddPermissionDialog', () => {
let fixture: ComponentFixture<AddPermissionDialogComponent>;
let element: HTMLElement;
let data: AddPermissionDialogData = {
const data: AddPermissionDialogData = {
title: 'dead or alive you are coming with me',
nodeId: 'fake-node-id',
confirm: new Subject<NodeEntry[]> ()

View File

@@ -50,7 +50,7 @@ describe('AddPermissionPanelComponent', () => {
});
function typeWordIntoSearchInput(word: string): void {
let inputDebugElement = debugElement.query(By.css('#searchInput'));
const inputDebugElement = debugElement.query(By.css('#searchInput'));
inputDebugElement.nativeElement.value = word;
inputDebugElement.nativeElement.focus();
inputDebugElement.nativeElement.dispatchEvent(new Event('input'));

View File

@@ -104,7 +104,7 @@ describe('AddPermissionComponent', () => {
fixture.componentInstance.currentNode = new Node({ id: 'fake-node-id' });
spyOn(nodePermissionService, 'updateNodePermissions').and.returnValue(of({ id: 'fake-node-id' }));
let spySuccess = spyOn(fixture.componentInstance, 'success');
const spySuccess = spyOn(fixture.componentInstance, 'success');
fixture.componentInstance.applySelection();
expect(spySuccess).not.toHaveBeenCalled();
});

View File

@@ -98,7 +98,7 @@ describe('InheritPermissionDirective', () => {
it('should not update the node when node has no permission', async(() => {
spyOn(nodeService, 'getNode').and.returnValue(of(fakeNodeWithInheritNoPermission));
let spyUpdateNode = spyOn(nodeService, 'updateNode');
const spyUpdateNode = spyOn(nodeService, 'updateNode');
component.updatedNode = true;
fixture.detectChanges();
const buttonPermission: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#sample-button-permission');

View File

@@ -120,7 +120,7 @@ describe('PermissionDisplayComponent', () => {
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
let options: any = fixture.debugElement.queryAll(By.css('mat-option'));
const options: any = fixture.debugElement.queryAll(By.css('mat-option'));
expect(options).not.toBeNull();
expect(options.length).toBe(4);
expect(options[0].nativeElement.innerText).toContain('SiteCollaborator');
@@ -145,7 +145,7 @@ describe('PermissionDisplayComponent', () => {
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
let options: any = fixture.debugElement.queryAll(By.css('mat-option'));
const options: any = fixture.debugElement.queryAll(By.css('mat-option'));
expect(options).not.toBeNull();
expect(options.length).toBe(5);
expect(options[0].nativeElement.innerText).toContain('Contributor');
@@ -178,7 +178,7 @@ describe('PermissionDisplayComponent', () => {
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
let options: any = fixture.debugElement.queryAll(By.css('mat-option'));
const options: any = fixture.debugElement.queryAll(By.css('mat-option'));
expect(options).not.toBeNull();
expect(options.length).toBe(5);
options[3].triggerEventHandler('click', {});

View File

@@ -69,16 +69,16 @@ export class PermissionListComponent implements OnInit {
}
private getPermissionList(node: Node): PermissionDisplayModel[] {
let allPermissions: PermissionDisplayModel[] = [];
const allPermissions: PermissionDisplayModel[] = [];
if (node.permissions.locallySet) {
node.permissions.locallySet.map((permissionElement: PermissionElement) => {
let permission = new PermissionDisplayModel(permissionElement);
const permission = new PermissionDisplayModel(permissionElement);
allPermissions.push(permission);
});
}
if (node.permissions.inherited) {
node.permissions.inherited.map((permissionElement: PermissionElement) => {
let permissionInherited = new PermissionDisplayModel(permissionElement);
const permissionInherited = new PermissionDisplayModel(permissionElement);
permissionInherited.isInherited = true;
allPermissions.push(permissionInherited);
});
@@ -87,7 +87,7 @@ export class PermissionListComponent implements OnInit {
}
saveNewRole(event: any, permissionRow: PermissionDisplayModel) {
let updatedPermissionRole: PermissionElement = this.buildUpdatedPermission(event.value, permissionRow);
const updatedPermissionRole: PermissionElement = this.buildUpdatedPermission(event.value, permissionRow);
this.nodePermissionService.updatePermissionRole(this.actualNode, updatedPermissionRole)
.subscribe((node: Node) => {
this.update.emit(updatedPermissionRole);
@@ -95,7 +95,7 @@ export class PermissionListComponent implements OnInit {
}
private buildUpdatedPermission(newRole: string, permissionRow: PermissionDisplayModel): PermissionElement {
let permissionRole: PermissionElement = {};
const permissionRole: PermissionElement = {};
permissionRole.accessStatus = permissionRow.accessStatus;
permissionRole.name = newRole;
permissionRole.authorityId = permissionRow.authorityId;

View File

@@ -39,7 +39,7 @@ describe('NodePermissionDialogService', () => {
});
beforeEach(() => {
let appConfig: AppConfigService = TestBed.get(AppConfigService);
const appConfig: AppConfigService = TestBed.get(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
service = TestBed.get(NodePermissionDialogService);
materialDialog = TestBed.get(MatDialog);

View File

@@ -58,7 +58,7 @@ export class NodePermissionDialogService {
this.openDialog(data, 'adf-add-permission-dialog', '630px');
return confirm;
} else {
let errors = new Error(JSON.stringify({ error: { statusCode: 403 } }));
const errors = new Error(JSON.stringify({ error: { statusCode: 403 } }));
errors.message = 'PERMISSION_MANAGER.ERROR.NOT-ALLOWED';
return throwError(errors);
}

View File

@@ -52,7 +52,7 @@ describe('NodePermissionService', () => {
});
function returnUpdatedNode(nodeId, nodeBody) {
let fakeNode: Node = new Node({});
const fakeNode: Node = new Node({});
fakeNode.id = 'fake-updated-node';
fakeNode.permissions = nodeBody.permissions;
return of(fakeNode);
@@ -149,7 +149,7 @@ describe('NodePermissionService', () => {
}));
it('should be able to update locally permissions on the node without locally set permissions', async(() => {
let fakeNodeCopy = JSON.parse(JSON.stringify(fakeNodeWithoutPermissions));
const fakeNodeCopy = JSON.parse(JSON.stringify(fakeNodeWithoutPermissions));
fakeNodeCopy.permissions.locallySet = undefined;
spyOn(nodeService, 'updateNode').and.callFake((nodeId, permissionBody) => returnUpdatedNode(nodeId, permissionBody));

View File

@@ -43,7 +43,7 @@ export class NodePermissionService {
.pipe(
switchMap((siteNodeList: any) => {
if ( siteNodeList.list.entries.length > 0 ) {
let siteName = siteNodeList.list.entries[0].entry.name;
const siteName = siteNodeList.list.entries[0].entry.name;
return this.getGroupMembersBySiteName(siteName);
} else {
return of(node.permissions.settable);
@@ -59,7 +59,7 @@ export class NodePermissionService {
* @returns Node with updated permission
*/
updatePermissionRole(node: Node, updatedPermissionRole: PermissionElement): Observable<Node> {
let permissionBody = { permissions: { locallySet: []} };
const permissionBody = { permissions: { locallySet: []} };
const index = node.permissions.locallySet.map((permission) => permission.authorityId).indexOf(updatedPermissionRole.authorityId);
permissionBody.permissions.locallySet = permissionBody.permissions.locallySet.concat(node.permissions.locallySet);
if (index !== -1) {
@@ -95,7 +95,7 @@ export class NodePermissionService {
* @returns Node with updated permissions
*/
updateLocallySetPermissions(node: Node, nodes: NodeEntry[], nodeRole: string[]): Observable<Node> {
let permissionBody = { permissions: { locallySet: []} };
const permissionBody = { permissions: { locallySet: []} };
const permissionList = this.transformNodeToPermissionElement(nodes, nodeRole[0]);
const duplicatedPermissions = this.getDuplicatedPermissions(node.permissions.locallySet, permissionList);
if (duplicatedPermissions.length > 0) {
@@ -108,7 +108,7 @@ export class NodePermissionService {
}
private getDuplicatedPermissions(nodeLocallySet: PermissionElement[], permissionListAdded: PermissionElement[]): PermissionElement[] {
let duplicatePermissions: PermissionElement[] = [];
const duplicatePermissions: PermissionElement[] = [];
if (nodeLocallySet) {
permissionListAdded.forEach((permission: PermissionElement) => {
const duplicate = nodeLocallySet.find((localPermission) => this.isEqualPermission(localPermission, permission));
@@ -128,7 +128,7 @@ export class NodePermissionService {
private transformNodeToPermissionElement(nodes: NodeEntry[], nodeRole: any): PermissionElement[] {
return nodes.map((node) => {
let newPermissionElement: PermissionElement = <PermissionElement> {
const newPermissionElement: PermissionElement = <PermissionElement> {
'authorityId': node.entry.properties['cm:authorityName'] ?
node.entry.properties['cm:authorityName'] :
node.entry.properties['cm:userName'],
@@ -146,7 +146,7 @@ export class NodePermissionService {
* @returns Node with modified permissions
*/
removePermission(node: Node, permissionToRemove: PermissionElement): Observable<Node> {
let permissionBody = { permissions: { locallySet: [] } };
const permissionBody = { permissions: { locallySet: [] } };
const index = node.permissions.locallySet.map((permission) => permission.authorityId).indexOf(permissionToRemove.authorityId);
if (index !== -1) {
node.permissions.locallySet.splice(index, 1);
@@ -160,7 +160,7 @@ export class NodePermissionService {
return this.getGroupMemberByGroupName(groupName)
.pipe(
map((groupMemberPaging: GroupMemberPaging) => {
let displayResult: string[] = [];
const displayResult: string[] = [];
groupMemberPaging.list.entries.forEach((member: GroupMemberEntry) => {
displayResult.push(this.formattedRoleName(member.entry.displayName, 'site_' + siteName));
});