diff --git a/lib/content-services/.eslintrc.json b/lib/content-services/.eslintrc.json index b06c12ded0d..a71bbf7dceb 100644 --- a/lib/content-services/.eslintrc.json +++ b/lib/content-services/.eslintrc.json @@ -24,13 +24,14 @@ "@typescript-eslint/naming-convention": "warn", "@typescript-eslint/consistent-type-assertions": "warn", "@typescript-eslint/prefer-for-of": "warn", - "no-underscore-dangle": "warn", + "@typescript-eslint/member-ordering": "off", + "no-underscore-dangle": ["error", { "allowAfterThis": true }], "no-shadow": "warn", "quote-props": "warn", "object-shorthand": "warn", "prefer-const": "warn", "arrow-body-style": "warn", - "@angular-eslint/no-output-native": "warn", + "@angular-eslint/no-output-native": "off", "space-before-function-paren": "warn", "@angular-eslint/component-selector": [ diff --git a/lib/content-services/src/lib/aspect-list/aspect-list-dialog.component.spec.ts b/lib/content-services/src/lib/aspect-list/aspect-list-dialog.component.spec.ts index 787e60ed811..a455a4f7a45 100644 --- a/lib/content-services/src/lib/aspect-list/aspect-list-dialog.component.spec.ts +++ b/lib/content-services/src/lib/aspect-list/aspect-list-dialog.component.spec.ts @@ -102,7 +102,7 @@ describe('AspectListDialogComponent', () => { describe('Without passing node id', () => { beforeEach(async () => { - data = { + data = { title: 'Title', description: 'Description that can be longer or shorter', overTableMessage: 'Over here', @@ -239,7 +239,7 @@ describe('AspectListDialogComponent', () => { describe('Passing the node id', () => { beforeEach(async () => { - data = { + data = { title: 'Title', description: 'Description that can be longer or shorter', overTableMessage: 'Over here', diff --git a/lib/content-services/src/lib/aspect-list/aspect-list.service.ts b/lib/content-services/src/lib/aspect-list/aspect-list.service.ts index 5baa8c759b3..cb8655459e5 100644 --- a/lib/content-services/src/lib/aspect-list/aspect-list.service.ts +++ b/lib/content-services/src/lib/aspect-list/aspect-list.service.ts @@ -85,9 +85,7 @@ export class AspectListService { private filterAspectByConfig(visibleAspectList: string[], aspectEntries: AspectEntry[]): AspectEntry[] { let result = aspectEntries ? aspectEntries : []; if (visibleAspectList?.length > 0 && aspectEntries) { - result = aspectEntries.filter((value) => { - return visibleAspectList.includes(value?.entry?.id); - }); + result = aspectEntries.filter((value) => visibleAspectList.includes(value?.entry?.id)); } return result; } diff --git a/lib/content-services/src/lib/audit/audit.service.spec.ts b/lib/content-services/src/lib/audit/audit.service.spec.ts index fbddf227d32..e1060891d79 100644 --- a/lib/content-services/src/lib/audit/audit.service.spec.ts +++ b/lib/content-services/src/lib/audit/audit.service.spec.ts @@ -59,34 +59,34 @@ describe('AuditService', () => { status: 200, contentType: 'json', responseText: { - 'list': { - 'pagination': { - 'count': 3, - 'hasMoreItems': false, - 'totalItems': 3, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 3, + hasMoreItems: false, + totalItems: 3, + skipCount: 0, + maxItems: 100 }, - 'entries': [ + entries: [ { - 'entry': { - 'isEnabled': true, - 'name': 'Alfresco Tagging Service', - 'id': 'tagging' + entry: { + isEnabled: true, + name: 'Alfresco Tagging Service', + id: 'tagging' } }, { - 'entry': { - 'isEnabled': true, - 'name': 'ShareSiteAccess', - 'id': 'share-site-access' + entry: { + isEnabled: true, + name: 'ShareSiteAccess', + id: 'share-site-access' } }, { - 'entry': { - 'isEnabled': true, - 'name': 'alfresco-access', - 'id': 'alfresco-access' + entry: { + isEnabled: true, + name: 'alfresco-access', + id: 'alfresco-access' } } ] @@ -106,10 +106,10 @@ describe('AuditService', () => { status: 200, contentType: 'json', responseText: { - 'entry': { - 'id': 'alfresco-access', - 'name': 'alfresco-access', - 'isEnabled': true + entry: { + id: 'alfresco-access', + name: 'alfresco-access', + isEnabled: true } } }); @@ -125,49 +125,49 @@ describe('AuditService', () => { status: 200, contentType: 'json', responseText: { - 'list': { - 'pagination': { - 'count': 3, - 'hasMoreItems': false, - 'totalItems': 3, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 3, + hasMoreItems: false, + totalItems: 3, + skipCount: 0, + maxItems: 100 }, - 'entries': [ + entries: [ { - 'entry': { - 'id': '1', - 'auditApplicationId': 'alfresco-access', - 'createdByUser': { - 'displayName': 'admin', - 'id': 'admin' + entry: { + id: '1', + auditApplicationId: 'alfresco-access', + createdByUser: { + displayName: 'admin', + id: 'admin' }, - 'createdAt': '2020-08-11T13:11:59.141Z', - 'values': {} + createdAt: '2020-08-11T13:11:59.141Z', + values: {} } }, { - 'entry': { - 'id': '2', - 'auditApplicationId': 'alfresco-access', - 'createdByUser': { - 'displayName': 'admin', - 'id': 'admin' + entry: { + id: '2', + auditApplicationId: 'alfresco-access', + createdByUser: { + displayName: 'admin', + id: 'admin' }, - 'createdAt': '2020-08-11T13:11:59.141Z', - 'values': {} + createdAt: '2020-08-11T13:11:59.141Z', + values: {} } }, { - 'entry': { - 'id': '3', - 'auditApplicationId': 'alfresco-access', - 'createdByUser': { - 'displayName': 'admin', - 'id': 'admin' + entry: { + id: '3', + auditApplicationId: 'alfresco-access', + createdByUser: { + displayName: 'admin', + id: 'admin' }, - 'createdAt': '2020-08-11T13:11:59.141Z', - 'values': {} + createdAt: '2020-08-11T13:11:59.141Z', + values: {} } } ] @@ -187,15 +187,15 @@ describe('AuditService', () => { status: 200, contentType: 'json', responseText: { - 'entry': { - 'id': '1', - 'auditApplicationId': 'alfresco-access', - 'createdByUser': { - 'displayName': 'admin', - 'id': 'admin' + entry: { + id: '1', + auditApplicationId: 'alfresco-access', + createdByUser: { + displayName: 'admin', + id: 'admin' }, - 'createdAt': '2020-08-11T13:11:59.148Z', - 'values': {} + createdAt: '2020-08-11T13:11:59.148Z', + values: {} } } }); diff --git a/lib/content-services/src/lib/audit/audit.service.ts b/lib/content-services/src/lib/audit/audit.service.ts index e0326c67124..b8f631bcdbb 100644 --- a/lib/content-services/src/lib/audit/audit.service.ts +++ b/lib/content-services/src/lib/audit/audit.service.ts @@ -56,7 +56,7 @@ export class AuditService { getAuditApp(auditApplicationId: string, opts?: any): Observable { const defaultOptions = { - auditApplicationId: auditApplicationId + auditApplicationId }; const queryOptions = Object.assign({}, defaultOptions, opts); return from(this.auditApi.getAuditApp(queryOptions)) @@ -97,7 +97,7 @@ export class AuditService { getAuditEntriesForNode(nodeId: string, opts?: any): Observable { const defaultOptions = { - nodeId: nodeId + nodeId }; const queryOptions = Object.assign({}, defaultOptions, opts); return from(this.auditApi.listAuditEntriesForNode(queryOptions)) diff --git a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.spec.ts b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.spec.ts index 244a791cf0d..b660dbbfff8 100644 --- a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.spec.ts +++ b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.spec.ts @@ -17,7 +17,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { PathElementEntity, Node } from '@alfresco/js-api'; +import { Node } from '@alfresco/js-api'; import { setupTestBed } from '@alfresco/adf-core'; import { fakeNodeWithCreatePermission } from '../mock'; import { DocumentListComponent, DocumentListService } from '../document-list'; @@ -72,7 +72,7 @@ describe('Breadcrumb', () => { }); it('should emit navigation event', (done) => { - const node = { id: '-id-', name: 'name' }; + const node = { id: '-id-', name: 'name' }; component.navigate.subscribe((val) => { expect(val).toBe(node); done(); @@ -112,8 +112,7 @@ describe('Breadcrumb', () => { }); it('should update document list on click', () => { - - const node = { id: '-id-', name: 'name' }; + const node = { id: '-id-', name: 'name' }; component.target = documentListComponent; component.onRoutePathClick(node, null); diff --git a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.ts b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.ts index 8151825b68b..037e47f73a4 100644 --- a/lib/content-services/src/lib/breadcrumb/breadcrumb.component.ts +++ b/lib/content-services/src/lib/breadcrumb/breadcrumb.component.ts @@ -37,7 +37,7 @@ import { takeUntil } from 'rxjs/operators'; templateUrl: './breadcrumb.component.html', styleUrls: ['./breadcrumb.component.scss'], encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-breadcrumb' } + host: { class: 'adf-breadcrumb' } }) export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy { @@ -143,13 +143,13 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy { parseRoute(node: Node): PathElementEntity[] { if (node && node.path) { - const route = (node.path.elements || []).slice(); + const route = (node.path.elements || []).slice(); - route.push( { + route.push({ id: node.id, name: node.name, - node: node - }); + node + } as PathElementEntity); const rootPos = this.getElementPosition(route, this.rootId); if (rootPos > 0) { diff --git a/lib/content-services/src/lib/breadcrumb/dropdown-breadcrumb.component.spec.ts b/lib/content-services/src/lib/breadcrumb/dropdown-breadcrumb.component.spec.ts index e3a5bf3c51c..1b72bbb1186 100644 --- a/lib/content-services/src/lib/breadcrumb/dropdown-breadcrumb.component.spec.ts +++ b/lib/content-services/src/lib/breadcrumb/dropdown-breadcrumb.component.spec.ts @@ -31,7 +31,7 @@ describe('DropdownBreadcrumb', () => { let component: DropdownBreadcrumbComponent; let fixture: ComponentFixture; let documentList: DocumentListComponent; - let documentListService: DocumentListService = jasmine.createSpyObj({ 'loadFolderByNodeId': of(''), 'isCustomSourceService': false }); + let documentListService: DocumentListService = jasmine.createSpyObj({ loadFolderByNodeId: of(''), isCustomSourceService: false }); setupTestBed({ imports: [ @@ -53,22 +53,22 @@ describe('DropdownBreadcrumb', () => { fixture.destroy(); }); - function openSelect() { + const openSelect = () => { const folderIcon = fixture.debugElement.nativeElement.querySelector('[data-automation-id="dropdown-breadcrumb-trigger"]'); folderIcon.click(); fixture.detectChanges(); - } + }; - function triggerComponentChange(fakeNodeData) { + const triggerComponentChange = (fakeNodeData) => { component.folderNode = fakeNodeData; component.ngOnChanges(); fixture.detectChanges(); - } + }; - function clickOnTheFirstOption() { + const clickOnTheFirstOption = () => { const option: any = document.querySelector('[id^="mat-option"]'); option.click(); - } + }; it('should display only the current folder name if there is no previous folders', (done) => { const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission)); diff --git a/lib/content-services/src/lib/breadcrumb/dropdown-breadcrumb.component.ts b/lib/content-services/src/lib/breadcrumb/dropdown-breadcrumb.component.ts index 73849a682c4..34ff12beaff 100644 --- a/lib/content-services/src/lib/breadcrumb/dropdown-breadcrumb.component.ts +++ b/lib/content-services/src/lib/breadcrumb/dropdown-breadcrumb.component.ts @@ -25,7 +25,7 @@ import { BreadcrumbComponent } from './breadcrumb.component'; templateUrl: './dropdown-breadcrumb.component.html', styleUrls: ['./dropdown-breadcrumb.component.scss'], encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-dropdown-breadcrumb' } + host: { class: 'adf-dropdown-breadcrumb' } }) export class DropdownBreadcrumbComponent extends BreadcrumbComponent implements OnChanges { diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts index a6f20d6b566..c7d61731267 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.spec.ts @@ -48,14 +48,14 @@ describe('ContentMetadataCardComponent', () => { fixture = TestBed.createComponent(ContentMetadataCardComponent); contentMetadataService = TestBed.inject(ContentMetadataService); component = fixture.componentInstance; - node = { + node = { aspectNames: [], nodeType: '', content: {}, properties: {}, createdByUser: {}, modifiedByUser: {} - }; + } as Node; component.node = node; component.preset = preset; diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.ts index d48cc0b0637..b509548aa11 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata-card/content-metadata-card.component.ts @@ -25,7 +25,7 @@ import { PresetConfig } from '../../interfaces/content-metadata.interfaces'; templateUrl: './content-metadata-card.component.html', styleUrls: ['./content-metadata-card.component.scss'], encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-content-metadata-card' } + host: { class: 'adf-content-metadata-card' } }) export class ContentMetadataCardComponent implements OnChanges { diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.spec.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.spec.ts index 4d88ad1c5d4..29230552322 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.spec.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.spec.ts @@ -55,7 +55,7 @@ describe('ContentMetadataComponent', () => { updateService = TestBed.inject(CardViewUpdateService); nodesApiService = TestBed.inject(NodesApiService); - node = { + node = { id: 'node-id', aspectNames: [], nodeType: 'cm:node', @@ -63,15 +63,15 @@ describe('ContentMetadataComponent', () => { properties: {}, createdByUser: {}, modifiedByUser: {} - }; + } as Node; - folderNode = { + folderNode = { id: 'folder-id', aspectNames: [], nodeType: '', createdByUser: {}, modifiedByUser: {} - }; + } as Node; component.node = node; component.preset = preset; @@ -116,7 +116,7 @@ describe('ContentMetadataComponent', () => { describe('Saving', () => { it('itemUpdate', fakeAsync(() => { spyOn(component, 'updateChanges').and.callThrough(); - const property = { key: 'properties.property-key', value: 'original-value' }; + const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel; updateService.update(property, 'updated-value'); tick(600); @@ -126,7 +126,7 @@ describe('ContentMetadataComponent', () => { })); it('nodeAspectUpdate', fakeAsync(() => { - const fakeNode: MinimalNode = { id: 'fake-minimal-node', aspectNames: ['ft:a', 'ft:b', 'ft:c'], name: 'fake-node'}; + const fakeNode = { id: 'fake-minimal-node', aspectNames: ['ft:a', 'ft:b', 'ft:c'], name: 'fake-node'} as MinimalNode; spyOn(contentMetadataService, 'getGroupedProperties').and.stub(); spyOn(contentMetadataService, 'getBasicProperties').and.stub(); updateService.updateNodeAspect(fakeNode); @@ -138,7 +138,7 @@ describe('ContentMetadataComponent', () => { it('should save changedProperties on save click', fakeAsync(async () => { component.editable = true; - const property = { key: 'properties.property-key', value: 'original-value' }; + const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel; const expectedNode = { ...node, name: 'some-modified-value' }; spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode)); @@ -158,7 +158,7 @@ describe('ContentMetadataComponent', () => { it('should throw error on unsuccessful save', fakeAsync((done) => { const logService: LogService = TestBed.inject(LogService); component.editable = true; - const property = { key: 'properties.property-key', value: 'original-value' }; + const property = { key: 'properties.property-key', value: 'original-value' } as CardViewBaseItemModel; updateService.update(property, 'updated-value'); tick(600); @@ -182,7 +182,7 @@ describe('ContentMetadataComponent', () => { it('should open the confirm dialog when content type is changed', fakeAsync(() => { component.editable = true; - const property = { key: 'nodeType', value: 'ft:sbiruli' }; + const property = { key: 'nodeType', value: 'ft:sbiruli' } as CardViewBaseItemModel; const expectedNode = { ...node, nodeType: 'ft:sbiruli' }; spyOn(contentMetadataService, 'openConfirmDialog').and.returnValue(of(true)); spyOn(nodesApiService, 'updateNode').and.returnValue(of(expectedNode)); @@ -203,7 +203,7 @@ describe('ContentMetadataComponent', () => { it('should retrigger the load of the properties when the content type has changed', fakeAsync(() => { component.editable = true; - const property = { key: 'nodeType', value: 'ft:sbiruli' }; + const property = { key: 'nodeType', value: 'ft:sbiruli' } as CardViewBaseItemModel; const expectedNode = Object.assign({}, node, { nodeType: 'ft:sbiruli' }); spyOn(contentMetadataService, 'openConfirmDialog').and.returnValue(of(true)); spyOn(updateService, 'updateNodeAspect'); @@ -512,6 +512,5 @@ describe('ContentMetadataComponent', () => { }); }); -function queryDom(fixture: ComponentFixture, properties: string = 'properties') { - return fixture.debugElement.query(By.css(`[data-automation-id="adf-metadata-group-${properties}"]`)); -} +const queryDom = (fixture: ComponentFixture, properties: string = 'properties') => + fixture.debugElement.query(By.css(`[data-automation-id="adf-metadata-group-${properties}"]`)); diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts index b22ef104792..c83b7f0616c 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts @@ -33,17 +33,16 @@ import { ContentMetadataService } from '../../services/content-metadata.service' import { CardViewGroup, PresetConfig } from '../../interfaces/content-metadata.interfaces'; import { takeUntil, debounceTime, catchError, map } from 'rxjs/operators'; +const DEFAULT_SEPARATOR = ', '; + @Component({ selector: 'adf-content-metadata', templateUrl: './content-metadata.component.html', styleUrls: ['./content-metadata.component.scss'], - host: { 'class': 'adf-content-metadata' }, + host: { class: 'adf-content-metadata' }, encapsulation: ViewEncapsulation.None }) export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { - - static DEFAULT_SEPARATOR = ', '; - protected onDestroy$ = new Subject(); /** (required) The node entity to fetch metadata about */ @@ -106,7 +105,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { private appConfig: AppConfigService ) { this.copyToClipboardAction = this.appConfig.get('content-metadata.copy-to-clipboard-action'); - this.multiValueSeparator = this.appConfig.get('content-metadata.multi-value-pipe-separator') || ContentMetadataComponent.DEFAULT_SEPARATOR; + this.multiValueSeparator = this.appConfig.get('content-metadata.multi-value-pipe-separator') || DEFAULT_SEPARATOR; this.useChipsForMultiValueProperty = this.appConfig.get('content-metadata.multi-value-chips'); } @@ -233,9 +232,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { } showGroup(group: CardViewGroup): boolean { - const properties = group.properties.filter((property) => { - return !this.isEmpty(property.displayValue); - }); + const properties = group.properties.filter((property) => !this.isEmpty(property.displayValue)); return properties.length > 0; } diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata/mock-data.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata/mock-data.ts index f9dd0caf105..7d725736442 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata/mock-data.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata/mock-data.ts @@ -17,57 +17,57 @@ export const mockGroupProperties = [ { - 'title': 'EXIF', - 'properties': [ + title: 'EXIF', + properties: [ { - 'label': 'Image Width', - 'value': 363, - 'key': 'properties.exif:pixelXDimension', - 'default': null, - 'editable': true, - 'clickable': false, - 'icon': '', - 'data': null, - 'type': 'int', - 'multiline': false, - 'pipes': [], - 'clickCallBack': null, - 'displayValue': 400 + label: 'Image Width', + value: 363, + key: 'properties.exif:pixelXDimension', + default: null, + editable: true, + clickable: false, + icon: '', + data: null, + type: 'int', + multiline: false, + pipes: [], + clickCallBack: null, + displayValue: 400 }, { - 'label': 'Image Height', - 'value': 400, - 'key': 'properties.exif:pixelYDimension', - 'default': null, - 'editable': true, - 'clickable': false, - 'icon': '', - 'data': null, - 'type': 'int', - 'multiline': false, - 'pipes': [], - 'clickCallBack': null, - 'displayValue': 400 + label: 'Image Height', + value: 400, + key: 'properties.exif:pixelYDimension', + default: null, + editable: true, + clickable: false, + icon: '', + data: null, + type: 'int', + multiline: false, + pipes: [], + clickCallBack: null, + displayValue: 400 } ] }, { - 'title': 'CUSTOM', - 'properties': [ + title: 'CUSTOM', + properties: [ { - 'label': 'Height', - 'value': 400, - 'key': 'properties.custom:abc', - 'default': null, - 'editable': true, - 'clickable': false, - 'icon': '', - 'data': null, - 'type': 'int', - 'multiline': false, - 'pipes': [], - 'clickCallBack': null, - 'displayValue': 400 + label: 'Height', + value: 400, + key: 'properties.custom:abc', + default: null, + editable: true, + clickable: false, + icon: '', + data: null, + type: 'int', + multiline: false, + pipes: [], + clickCallBack: null, + displayValue: 400 } ] } diff --git a/lib/content-services/src/lib/content-metadata/services/config/aspect-oriented-config.service.spec.ts b/lib/content-services/src/lib/content-metadata/services/config/aspect-oriented-config.service.spec.ts index 83138a3bf3b..59f8ab69e41 100644 --- a/lib/content-services/src/lib/content-metadata/services/config/aspect-oriented-config.service.spec.ts +++ b/lib/content-services/src/lib/content-metadata/services/config/aspect-oriented-config.service.spec.ts @@ -22,9 +22,7 @@ describe('AspectOrientedConfigService', () => { let configService: AspectOrientedConfigService; - function createConfigService(configObj: AspectOrientedConfig) { - return new AspectOrientedConfigService(configObj); - } + const createConfigService = (configObj: AspectOrientedConfig) => new AspectOrientedConfigService(configObj); describe('reorganiseByConfig', () => { @@ -34,10 +32,10 @@ describe('AspectOrientedConfigService', () => { expectations: OrganisedPropertyGroup[]; } - const property1 = { name: 'property1' }; - const property2 = { name: 'property2' }; - const property3 = { name: 'property3' }; - const property4 = { name: 'property4' }; + const property1 = { name: 'property1' } as Property; + const property2 = { name: 'property2' } as Property; + const property3 = { name: 'property3' } as Property; + const property4 = { name: 'property4' } as Property; const propertyGroups: PropertyGroupContainer = { berseria: { title: 'Berseria', description: '', name: 'berseria', properties: { property1, property2 } }, @@ -53,7 +51,7 @@ describe('AspectOrientedConfigService', () => { { name: 'One property from One group', config: { - 'berseria': [ 'property1' ] + berseria: [ 'property1' ] }, expectations: [{ title: 'Berseria', @@ -63,7 +61,7 @@ describe('AspectOrientedConfigService', () => { { name: 'More properties from One group', config: { - 'berseria': [ 'property1', 'property2' ] + berseria: [ 'property1', 'property2' ] }, expectations: [{ title: 'Berseria', @@ -73,8 +71,8 @@ describe('AspectOrientedConfigService', () => { { name: 'One-one properties from More group', config: { - 'berseria': [ 'property1' ], - 'zestiria': [ 'property3' ] + berseria: [ 'property1' ], + zestiria: [ 'property3' ] }, expectations: [ { @@ -90,8 +88,8 @@ describe('AspectOrientedConfigService', () => { { name: 'More properties from More groups', config: { - 'zestiria': [ 'property4', 'property3' ], - 'berseria': [ 'property2', 'property1' ] + zestiria: [ 'property4', 'property3' ], + berseria: [ 'property2', 'property1' ] }, expectations: [ { @@ -107,8 +105,8 @@ describe('AspectOrientedConfigService', () => { { name: 'Wildcard', config: { - 'berseria': '*', - 'zestiria': [ 'property4' ] + berseria: '*', + zestiria: [ 'property4' ] }, expectations: [ { @@ -124,9 +122,9 @@ describe('AspectOrientedConfigService', () => { { name: 'Not existing group', config: { - 'berseria': '*', + berseria: '*', 'not-existing-group': '*', - 'zestiria': [ 'property4' ] + zestiria: [ 'property4' ] }, expectations: [ { @@ -142,8 +140,8 @@ describe('AspectOrientedConfigService', () => { { name: 'Not existing property', config: { - 'berseria': [ 'not-existing-property' ], - 'zestiria': [ 'property4' ] + berseria: [ 'not-existing-property' ], + zestiria: [ 'property4' ] }, expectations: [ { @@ -177,10 +175,10 @@ describe('AspectOrientedConfigService', () => { }); describe('appendAllPreset', () => { - const property1 = { name: 'property1' }; - const property2 = { name: 'property2' }; - const property3 = { name: 'property3' }; - const property4 = { name: 'property4' }; + const property1 = { name: 'property1' } as Property; + const property2 = { name: 'property2' } as Property; + const property3 = { name: 'property3' } as Property; + const property4 = { name: 'property4' } as Property; const propertyGroups: PropertyGroupContainer = { berseria: { title: 'Berseria', description: '', name: 'berseria', properties: { property1, property2 } }, diff --git a/lib/content-services/src/lib/content-metadata/services/config/aspect-oriented-config.service.ts b/lib/content-services/src/lib/content-metadata/services/config/aspect-oriented-config.service.ts index ad0eda37709..034d02b59a8 100644 --- a/lib/content-services/src/lib/content-metadata/services/config/aspect-oriented-config.service.ts +++ b/lib/content-services/src/lib/content-metadata/services/config/aspect-oriented-config.service.ts @@ -92,9 +92,7 @@ export class AspectOrientedConfigService implements ContentMetadataConfig { public filterExcludedPreset(propertyGroups: OrganisedPropertyGroup[]): OrganisedPropertyGroup[] { if (this.config.exclude) { - return propertyGroups.filter((preset) => { - return !this.config.exclude.includes(preset.name); - }); + return propertyGroups.filter((preset) => !this.config.exclude.includes(preset.name)); } return propertyGroups; } @@ -114,7 +112,7 @@ export class AspectOrientedConfigService implements ContentMetadataConfig { if (aspectProperties === '*') { properties = getProperty(propertyGroups, aspectName, aspectProperties); } else { - properties = ( aspectProperties) + properties = aspectProperties .map((propertyName) => getProperty(propertyGroups, aspectName, propertyName)) .filter((props) => props !== undefined); } diff --git a/lib/content-services/src/lib/content-metadata/services/config/content-metadata-config.factory.spec.ts b/lib/content-services/src/lib/content-metadata/services/config/content-metadata-config.factory.spec.ts index 690c834a737..73a1b608736 100644 --- a/lib/content-services/src/lib/content-metadata/services/config/content-metadata-config.factory.spec.ts +++ b/lib/content-services/src/lib/content-metadata/services/config/content-metadata-config.factory.spec.ts @@ -87,13 +87,13 @@ describe('ContentMetadataConfigFactory', () => { describe('set', () => { - function setConfig(presetName: string, presetConfig: any) { + const setConfig = (presetName: string, presetConfig: any) => { appConfig.config['content-metadata'] = { presets: { [presetName]: presetConfig } }; - } + }; it('should get back the IndifferentConfigService preset if the preset config is indifferent', () => { setConfig('default', '*'); diff --git a/lib/content-services/src/lib/content-metadata/services/config/content-metadata-config.factory.ts b/lib/content-services/src/lib/content-metadata/services/config/content-metadata-config.factory.ts index 0d25b70fe02..270407f2588 100644 --- a/lib/content-services/src/lib/content-metadata/services/config/content-metadata-config.factory.ts +++ b/lib/content-services/src/lib/content-metadata/services/config/content-metadata-config.factory.ts @@ -20,21 +20,15 @@ import { AppConfigService, LogService } from '@alfresco/adf-core'; import { AspectOrientedConfigService } from './aspect-oriented-config.service'; import { IndifferentConfigService } from './indifferent-config.service'; import { LayoutOrientedConfigService } from './layout-oriented-config.service'; -import { - PresetConfig, - ContentMetadataConfig, - AspectOrientedConfig, - LayoutOrientedConfig -} from '../../interfaces/content-metadata.interfaces'; +import { PresetConfig, ContentMetadataConfig } from '../../interfaces/content-metadata.interfaces'; + +const INDIFFERENT_PRESET = '*'; +const DEFAULT_PRESET_NAME = 'default'; @Injectable({ providedIn: 'root' }) export class ContentMetadataConfigFactory { - - static readonly INDIFFERENT_PRESET = '*'; - static readonly DEFAULT_PRESET_NAME = 'default'; - constructor(private appConfigService: AppConfigService, private logService: LogService) {} public get(presetName: string = 'default'): ContentMetadataConfig { @@ -42,10 +36,10 @@ export class ContentMetadataConfigFactory { try { presetConfig = this.appConfigService.config['content-metadata'].presets[presetName]; } catch { - if (presetName !== ContentMetadataConfigFactory.DEFAULT_PRESET_NAME) { + if (presetName !== DEFAULT_PRESET_NAME) { this.logService.error(`No content-metadata preset for: ${presetName}`); } - presetConfig = ContentMetadataConfigFactory.INDIFFERENT_PRESET; + presetConfig = INDIFFERENT_PRESET; } return this.createConfig(presetConfig); @@ -55,9 +49,9 @@ export class ContentMetadataConfigFactory { let config: ContentMetadataConfig; if (this.isLayoutOrientedPreset(presetConfig)) { - config = new LayoutOrientedConfigService( presetConfig); + config = new LayoutOrientedConfigService(presetConfig); } else if (this.isAspectOrientedPreset(presetConfig)) { - config = new AspectOrientedConfigService( presetConfig); + config = new AspectOrientedConfigService(presetConfig); } else { config = new IndifferentConfigService(); } diff --git a/lib/content-services/src/lib/content-metadata/services/config/layout-oriented-config.service.spec.ts b/lib/content-services/src/lib/content-metadata/services/config/layout-oriented-config.service.spec.ts index 8d3aeda85a7..9bfe79f64f6 100644 --- a/lib/content-services/src/lib/content-metadata/services/config/layout-oriented-config.service.spec.ts +++ b/lib/content-services/src/lib/content-metadata/services/config/layout-oriented-config.service.spec.ts @@ -27,9 +27,7 @@ describe('LayoutOrientedConfigService', () => { let configService: LayoutOrientedConfigService; - function createConfigService(configObj: LayoutOrientedConfig) { - return new LayoutOrientedConfigService(configObj); - } + const createConfigService = (configObj: LayoutOrientedConfig) => new LayoutOrientedConfigService(configObj); describe('isGroupAllowed', () => { @@ -102,12 +100,12 @@ describe('LayoutOrientedConfigService', () => { expectations: OrganisedPropertyGroup[]; } - const property1 = { name: 'property1' }; - const property2 = { name: 'property2' }; - const property3 = { name: 'property3' }; - const property4 = { name: 'property4' }; - const property5 = { name: 'property5' }; - const property6 = { name: 'property6' }; + const property1 = { name: 'property1' } as Property; + const property2 = { name: 'property2' } as Property; + const property3 = { name: 'property3' } as Property; + const property4 = { name: 'property4' } as Property; + const property5 = { name: 'property5' } as Property; + const property6 = { name: 'property6' } as Property; const propertyGroups: PropertyGroupContainer = { berseria: { title: 'Berseria', description: '', name: 'berseria', properties: { property1, property2 } }, @@ -282,8 +280,8 @@ describe('LayoutOrientedConfigService', () => { title: 'First group', items: [ { aspect: 'zestiria', properties: 'property3' }, - { type: 'berseria', properties: ['property2', { title: 'Custom title', name: 'property1' }] }, - { type: 'otherTales', properties: [ { title: 'Custom title', name: 'property5' }] } + { type: 'berseria', properties: ['property2', { title: 'Custom title', name: 'property1' } as any] }, + { type: 'otherTales', properties: [{ title: 'Custom title', name: 'property5' } as any] } ] } ], @@ -293,8 +291,8 @@ describe('LayoutOrientedConfigService', () => { properties: [ property3, property2, - { name: 'property1', title: 'Custom title', editable: true }, - { name: 'property5', title: 'Custom title', editable: true } + { name: 'property1', title: 'Custom title', editable: true } as Property, + { name: 'property5', title: 'Custom title', editable: true } as Property ] } ] diff --git a/lib/content-services/src/lib/content-metadata/services/config/layout-oriented-config.service.ts b/lib/content-services/src/lib/content-metadata/services/config/layout-oriented-config.service.ts index 63ac0297eac..8e15b8823fc 100644 --- a/lib/content-services/src/lib/content-metadata/services/config/layout-oriented-config.service.ts +++ b/lib/content-services/src/lib/content-metadata/services/config/layout-oriented-config.service.ts @@ -83,9 +83,7 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig { excludedConfig = [excludedConfig]; } - return propertyGroups.filter((props) => { - return !excludedConfig.includes(props.name); - }); + return propertyGroups.filter((props) => !excludedConfig.includes(props.name)); } public isIncludeAllEnabled() { @@ -116,13 +114,11 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig { private flattenItems(items) { return items.reduce((accumulator, item) => { const properties = Array.isArray(item.properties) ? item.properties : [item.properties]; - const flattenedProperties = properties.map((property) => { - return { - groupName: item.aspect || item.type, - property, - editable: item.editable - }; - }); + const flattenedProperties = properties.map((property) => ({ + groupName: item.aspect || item.type, + property, + editable: item.editable + })); return accumulator.concat(flattenedProperties); }, []); diff --git a/lib/content-services/src/lib/content-metadata/services/config/property-group-reader.ts b/lib/content-services/src/lib/content-metadata/services/config/property-group-reader.ts index ebc8286bee6..8d3407cb532 100644 --- a/lib/content-services/src/lib/content-metadata/services/config/property-group-reader.ts +++ b/lib/content-services/src/lib/content-metadata/services/config/property-group-reader.ts @@ -21,15 +21,10 @@ const emptyGroup = { properties: {} }; -function convertObjectToArray(object: any): Property[] { - return Object.keys(object).map((key) => object[key]); -} +const convertObjectToArray = (object: any): Property[] => Object.keys(object).map((key) => object[key]); +export const getGroup = (propertyGroups: PropertyGroupContainer, groupName: string): PropertyGroup | undefined => propertyGroups[groupName]; -export function getGroup(propertyGroups: PropertyGroupContainer, groupName: string): PropertyGroup | undefined { - return propertyGroups[groupName]; -} - -export function getProperty(propertyGroups: PropertyGroupContainer, groupName: string, propertyName: string): Property | Property[] | undefined { +export const getProperty = (propertyGroups: PropertyGroupContainer, groupName: string, propertyName: string): Property | Property[] | undefined => { const groupDefinition = getGroup(propertyGroups, groupName) || emptyGroup; let propertyDefinitions; @@ -40,4 +35,4 @@ export function getProperty(propertyGroups: PropertyGroupContainer, groupName: s } return propertyDefinitions; -} +}; diff --git a/lib/content-services/src/lib/content-metadata/services/content-metadata.service.spec.ts b/lib/content-services/src/lib/content-metadata/services/content-metadata.service.spec.ts index 9525a885e1f..05ff2ac044c 100644 --- a/lib/content-services/src/lib/content-metadata/services/content-metadata.service.spec.ts +++ b/lib/content-services/src/lib/content-metadata/services/content-metadata.service.spec.ts @@ -57,13 +57,13 @@ describe('ContentMetaDataService', () => { ] }); - function setConfig(presetName, presetConfig) { + const setConfig = (presetName, presetConfig) => { appConfig.config['content-metadata'] = { presets: { [presetName]: presetConfig } }; - } + }; beforeEach(() => { service = TestBed.inject(ContentMetadataService); @@ -74,14 +74,14 @@ describe('ContentMetaDataService', () => { }); it('should return all the properties of the node', () => { - const fakeNode: Node = { + const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, aspectNames: ['exif:exif'], createdByUser: {displayName: 'test-user'}, modifiedByUser: {displayName: 'test-user-modified'} - }; + } as Node; service.getBasicProperties(fakeNode).subscribe( (res) => { @@ -94,7 +94,7 @@ describe('ContentMetaDataService', () => { }); it('should return the content type property', () => { - const fakeNode: Node = { + const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, @@ -103,7 +103,7 @@ describe('ContentMetaDataService', () => { createdByUser: {displayName: 'test-user'}, modifiedByUser: {displayName: 'test-user-modified'}, properties: [] - }; + } as Node; spyOn(contentPropertyService, 'getContentTypeCardItem').and.returnValue(of({ label: 'hello i am a weird content type'} as any)); service.getContentTypeProperty(fakeNode).subscribe( @@ -128,7 +128,7 @@ describe('ContentMetaDataService', () => { describe('AspectOriented preset', () => { it('should return response with exif property', (done) => { - const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, aspectNames: ['exif:exif'] } ; + const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, aspectNames: ['exif:exif'] } as Node; setConfig('default', { 'exif:exif': '*' }); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(exifResponse)); @@ -146,7 +146,7 @@ describe('ContentMetaDataService', () => { }); it('should filter the record options for node ', (done) => { - const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, aspectNames: ['exif:exif'] } ; + const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, aspectNames: ['exif:exif'] } as Node; setConfig('default', { 'exif:exif': '*', 'rma:record': '*' }); spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve(exifResponse)); @@ -167,17 +167,17 @@ describe('ContentMetaDataService', () => { describe('LayoutOriented preset', () => { it('should return the node property', (done) => { - const fakeNode: Node = { name: 'Node Action', id: 'fake-id', nodeType: 'cm:content', isFile: true, aspectNames: [] } ; + const fakeNode: Node = { name: 'Node Action', id: 'fake-id', nodeType: 'cm:content', isFile: true, aspectNames: [] } as Node; const customLayoutOrientedScheme = [ { - 'id': 'app.content.metadata.customGroup2', - 'title': 'Properties', - 'items': [ + id: 'app.content.metadata.customGroup2', + title: 'Properties', + items: [ { - 'id': 'app.content.metadata.content', - 'aspect': 'cm:content', - 'properties': '*' + id: 'app.content.metadata.content', + aspect: 'cm:content', + properties: '*' } ] } @@ -199,28 +199,28 @@ describe('ContentMetaDataService', () => { }); it('should filter the exif property', (done) => { - const fakeNode: Node = { name: 'Node Action', id: 'fake-id', nodeType: 'cm:content', isFile: true, aspectNames: [] } ; + const fakeNode: Node = { name: 'Node Action', id: 'fake-id', nodeType: 'cm:content', isFile: true, aspectNames: [] } as Node; const customLayoutOrientedScheme = [ { - 'id': 'app.content.metadata.customGroup', - 'title': 'Exif', - 'items': [ + id: 'app.content.metadata.customGroup', + title: 'Exif', + items: [ { - 'id': 'app.content.metadata.exifAspect2', - 'aspect': 'exif:exif', - 'properties': '*' + id: 'app.content.metadata.exifAspect2', + aspect: 'exif:exif', + properties: '*' } ] }, { - 'id': 'app.content.metadata.customGroup2', - 'title': 'Properties', - 'items': [ + id: 'app.content.metadata.customGroup2', + title: 'Properties', + items: [ { - 'id': 'app.content.metadata.content', - 'aspect': 'cm:content', - 'properties': '*' + id: 'app.content.metadata.content', + aspect: 'cm:content', + properties: '*' } ] } @@ -242,19 +242,19 @@ describe('ContentMetaDataService', () => { }); it('should exclude the property if this property is excluded from config', (done) => { - const fakeNode: Node = { name: 'Node Action', id: 'fake-id', nodeType: 'cm:content', isFile: true, aspectNames: [] } ; + const fakeNode: Node = { name: 'Node Action', id: 'fake-id', nodeType: 'cm:content', isFile: true, aspectNames: [] } as Node; const customLayoutOrientedScheme = [ { - 'id': 'app.content.metadata.customGroup', - 'title': 'Exif', - 'includeAll': true, - 'exclude': ['cm:content'], - 'items': [ + id: 'app.content.metadata.customGroup', + title: 'Exif', + includeAll: true, + exclude: ['cm:content'], + items: [ { - 'id': 'app.content.metadata.exifAspect2', - 'aspect': 'exif:exif', - 'properties': '*' + id: 'app.content.metadata.exifAspect2', + aspect: 'exif:exif', + properties: '*' } ] } @@ -276,29 +276,29 @@ describe('ContentMetaDataService', () => { }); describe('Provided preset config', () => { - it('should create the metadata config on the fly when preset config is provided', async(done) => { - const fakeNode: Node = { name: 'Node Action', id: 'fake-id', nodeType: 'cm:content', isFile: true, aspectNames: [] } ; + it('should create the metadata config on the fly when preset config is provided', async (done) => { + const fakeNode: Node = { name: 'Node Action', id: 'fake-id', nodeType: 'cm:content', isFile: true, aspectNames: [] } as Node; const customLayoutOrientedScheme = [ { - 'id': 'app.content.metadata.customGroup', - 'title': 'Exif', - 'items': [ + id: 'app.content.metadata.customGroup', + title: 'Exif', + items: [ { - 'id': 'app.content.metadata.exifAspect2', - 'aspect': 'exif:exif', - 'properties': '*' + id: 'app.content.metadata.exifAspect2', + aspect: 'exif:exif', + properties: '*' } ] }, { - 'id': 'app.content.metadata.customGroup2', - 'title': 'Properties', - 'items': [ + id: 'app.content.metadata.customGroup2', + title: 'Properties', + items: [ { - 'id': 'app.content.metadata.content', - 'aspect': 'cm:content', - 'properties': '*' + id: 'app.content.metadata.content', + aspect: 'cm:content', + properties: '*' } ] } diff --git a/lib/content-services/src/lib/content-metadata/services/content-type-property.service.spec.ts b/lib/content-services/src/lib/content-metadata/services/content-type-property.service.spec.ts index 39d036bf6ba..07b848359da 100644 --- a/lib/content-services/src/lib/content-metadata/services/content-type-property.service.spec.ts +++ b/lib/content-services/src/lib/content-metadata/services/content-type-property.service.spec.ts @@ -31,84 +31,84 @@ describe('ContentTypePropertyService', () => { let contentTypeService: ContentTypeService; const mockContent: any = { - 'entry': + entry: { - 'associations': [], - 'isArchive': true, - 'includedInSupertypeQuery': true, - 'description': 'Base Content Object', - 'isContainer': false, - 'id': 'fk:nodeType', - 'title': 'Content', - 'model': { 'namespacePrefix': 'fk' }, - 'properties': [{ 'id': 'cm:name', 'title': 'Name', 'description': 'Name', 'dataType': 'd:text', 'isMultiValued': false, 'isMandatory': true, 'isMandatoryEnforced': true, 'isProtected': false }], - 'parentId': 'cm:cmobject' + associations: [], + isArchive: true, + includedInSupertypeQuery: true, + description: 'Base Content Object', + isContainer: false, + id: 'fk:nodeType', + title: 'Content', + model: { namespacePrefix: 'fk' }, + properties: [{ id: 'cm:name', title: 'Name', description: 'Name', dataType: 'd:text', isMultiValued: false, isMandatory: true, isMandatoryEnforced: true, isProtected: false }], + parentId: 'cm:cmobject' } }; const mockContentWithProperties: any = { - 'entry': + entry: { - 'associations': [], - 'isArchive': true, - 'includedInSupertypeQuery': true, - 'description': 'Base Content Object', - 'isContainer': false, - 'id': 'fk:nodeType', - 'title': 'Content', - 'model': { 'namespacePrefix': 'fk' }, - 'properties': [ + associations: [], + isArchive: true, + includedInSupertypeQuery: true, + description: 'Base Content Object', + isContainer: false, + id: 'fk:nodeType', + title: 'Content', + model: { namespacePrefix: 'fk' }, + properties: [ { - 'id': 'cm:name', - 'title': 'Name', - 'description': 'Name', - 'dataType': 'd:text', - 'isMultiValued': false, - 'isMandatory': true, - 'isMandatoryEnforced': true, - 'isProtected': false + id: 'cm:name', + title: 'Name', + description: 'Name', + dataType: 'd:text', + isMultiValued: false, + isMandatory: true, + isMandatoryEnforced: true, + isProtected: false }, { - 'id': 'fk:brendonstare', - 'title': 'Brendon', - 'description': 'is watching the dark emperor', - 'dataType': 'd:text', - 'isMultiValued': false, - 'isMandatory': true, - 'defaultValue': 'default', - 'isMandatoryEnforced': true, - 'isProtected': false + id: 'fk:brendonstare', + title: 'Brendon', + description: 'is watching the dark emperor', + dataType: 'd:text', + isMultiValued: false, + isMandatory: true, + defaultValue: 'default', + isMandatoryEnforced: true, + isProtected: false }], - 'parentId': 'cm:cmobject' + parentId: 'cm:cmobject' } }; const mockSelectOptions: TypeEntry[] = [ { - 'entry': { - 'isArchive': true, - 'includedInSupertypeQuery': true, - 'isContainer': false, - 'model': { - 'id': 'e2e:test', - 'author': 'E2e Automation User', - 'description': 'Custom type e2e model', - 'namespaceUri': 'http://www.customModel.com/whatever', - 'namespacePrefix': 'e2e' + entry: { + isArchive: true, + includedInSupertypeQuery: true, + isContainer: false, + model: { + id: 'e2e:test', + author: 'E2e Automation User', + description: 'Custom type e2e model', + namespaceUri: 'http://www.customModel.com/whatever', + namespacePrefix: 'e2e' }, - 'id': 'e2e:test', - 'title': 'Test type', - 'properties': [{ - 'id': 'cm:name', - 'title': 'Name', - 'description': 'Name', - 'dataType': 'd:text', - 'isMultiValued': false, - 'isMandatory': true, - 'isMandatoryEnforced': true, - 'isProtected': false + id: 'e2e:test', + title: 'Test type', + properties: [{ + id: 'cm:name', + title: 'Name', + description: 'Name', + dataType: 'd:text', + isMultiValued: false, + isMandatory: true, + isMandatoryEnforced: true, + isProtected: false }], - 'parentId': 'cm:content' + parentId: 'cm:content' } } ]; @@ -127,7 +127,7 @@ describe('ContentTypePropertyService', () => { }); it('should return a card text item for ACS version below 7', (done) => { - const fakeNode: Node = { + const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, @@ -136,7 +136,7 @@ describe('ContentTypePropertyService', () => { createdByUser: { displayName: 'test-user' }, modifiedByUser: { displayName: 'test-user-modified' }, properties: {} - }; + } as Node; spyOn(versionCompatibilityService, 'isVersionSupported').and.returnValue(false); service.getContentTypeCardItem(fakeNode).subscribe((items: CardViewItem[]) => { expect(items.length).toBe(1); @@ -150,7 +150,7 @@ describe('ContentTypePropertyService', () => { }); it('should return a card select item for ACS version 7 and above', (done) => { - const fakeNode: Node = { + const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, @@ -159,7 +159,7 @@ describe('ContentTypePropertyService', () => { createdByUser: { displayName: 'test-user' }, modifiedByUser: { displayName: 'test-user-modified' }, properties: {} - }; + } as Node; spyOn(versionCompatibilityService, 'isVersionSupported').and.returnValue(true); spyOn(contentTypeService, 'getContentTypeByPrefix').and.returnValue(of(mockContent)); spyOn(contentTypeService, 'getContentTypeChildren').and.returnValue(of(mockSelectOptions)); @@ -175,7 +175,7 @@ describe('ContentTypePropertyService', () => { }); it('should return a list of cards for the content type and all its own properties', (done) => { - const fakeNode: Node = { + const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, @@ -184,7 +184,7 @@ describe('ContentTypePropertyService', () => { createdByUser: { displayName: 'test-user' }, modifiedByUser: { displayName: 'test-user-modified' }, properties: {} - }; + } as Node; spyOn(versionCompatibilityService, 'isVersionSupported').and.returnValue(true); spyOn(contentTypeService, 'getContentTypeByPrefix').and.returnValue(of(mockContentWithProperties)); spyOn(contentTypeService, 'getContentTypeChildren').and.returnValue(of(mockSelectOptions)); @@ -206,7 +206,7 @@ describe('ContentTypePropertyService', () => { }); it('should return a list of cards for the content type and all its own properties with relative value set', (done) => { - const fakeNode: Node = { + const fakeNode: Node = { name: 'Node', id: 'fake-id', isFile: true, @@ -215,7 +215,7 @@ describe('ContentTypePropertyService', () => { createdByUser: { displayName: 'test-user' }, modifiedByUser: { displayName: 'test-user-modified' }, properties: {'fk:brendonstare': 'i keep staring i do not know why'} - }; + } as Node; spyOn(versionCompatibilityService, 'isVersionSupported').and.returnValue(true); spyOn(contentTypeService, 'getContentTypeByPrefix').and.returnValue(of(mockContentWithProperties)); spyOn(contentTypeService, 'getContentTypeChildren').and.returnValue(of(mockSelectOptions)); diff --git a/lib/content-services/src/lib/content-metadata/services/content-type-property.service.ts b/lib/content-services/src/lib/content-metadata/services/content-type-property.service.ts index 683f1645710..93ebab2cdd1 100644 --- a/lib/content-services/src/lib/content-metadata/services/content-type-property.service.ts +++ b/lib/content-services/src/lib/content-metadata/services/content-type-property.service.ts @@ -85,7 +85,7 @@ export class ContentTypePropertiesService { value: currentValue, key: 'nodeType', editable: true, - options$: options$, + options$, displayNoneOption: false }); @@ -98,7 +98,7 @@ export class ContentTypePropertiesService { distinctUntilChanged(), map(([contentTypesEntries, currentContentType]) => { const updatedTypes = this.appendCurrentType(currentContentType, contentTypesEntries); - return updatedTypes.map((contentType) => > { key: contentType.entry.id, label: contentType.entry.title ?? contentType.entry.id }); + return updatedTypes.map((contentType) => ({ key: contentType.entry.id, label: contentType.entry.title ?? contentType.entry.id })); })); } @@ -121,7 +121,7 @@ export class ContentTypePropertiesService { title: 'CORE.METADATA.CONTENT_TYPE.DIALOG.TITLE', description: 'CORE.METADATA.CONTENT_TYPE.DIALOG.DESCRIPTION', confirmMessage: 'CORE.METADATA.CONTENT_TYPE.DIALOG.CONFIRM', - select: select, + select, nodeType }; diff --git a/lib/content-services/src/lib/content-metadata/services/property-descriptors.service.spec.ts b/lib/content-services/src/lib/content-metadata/services/property-descriptors.service.spec.ts index e20a93abaa5..437ec0d8fe4 100644 --- a/lib/content-services/src/lib/content-metadata/services/property-descriptors.service.spec.ts +++ b/lib/content-services/src/lib/content-metadata/services/property-descriptors.service.spec.ts @@ -74,9 +74,7 @@ describe('PropertyDescriptorLoaderService', () => { const apiResponses = [ exifResponse, contentResponse ]; let counter = 0; - spyOn(classesApi, 'getClass').and.callFake(() => { - return Promise.resolve(apiResponses[counter++]); - }); + spyOn(classesApi, 'getClass').and.callFake(() => Promise.resolve(apiResponses[counter++])); service.load(['exif:exif', 'cm:content']) .subscribe({ diff --git a/lib/content-services/src/lib/content-metadata/services/property-descriptors.service.ts b/lib/content-services/src/lib/content-metadata/services/property-descriptors.service.ts index d4e05ba7d36..4efe8d501a1 100644 --- a/lib/content-services/src/lib/content-metadata/services/property-descriptors.service.ts +++ b/lib/content-services/src/lib/content-metadata/services/property-descriptors.service.ts @@ -47,10 +47,8 @@ export class PropertyDescriptorsService { } private convertToObject(propertyGroupsArray: PropertyGroup[]): PropertyGroupContainer { - return propertyGroupsArray.reduce((propertyGroups, propertyGroup) => { - return Object.assign({}, propertyGroups, { - [propertyGroup.name]: propertyGroup - }); - }, {}); + return propertyGroupsArray.reduce((propertyGroups, propertyGroup) => Object.assign({}, propertyGroups, { + [propertyGroup.name]: propertyGroup + }), {}); } } diff --git a/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.spec.ts b/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.spec.ts index 46d7fa590de..9a1f1bab5ea 100644 --- a/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.spec.ts +++ b/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.spec.ts @@ -15,8 +15,10 @@ * limitations under the License. */ +/* eslint-disable @typescript-eslint/naming-convention */ + import { TestBed } from '@angular/core/testing'; -import { PropertyGroupTranslatorService } from './property-groups-translator.service'; +import { PropertyGroupTranslatorService, RECOGNISED_ECM_TYPES } from './property-groups-translator.service'; import { Property, OrganisedPropertyGroup } from '../interfaces/content-metadata.interfaces'; import { CardViewTextItemModel, @@ -165,7 +167,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': 'The Chariot Line' }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0] as CardViewTextItemModel; expect(cardViewProperty instanceof CardViewTextItemModel).toBeTruthy('Property should be instance of CardViewTextItemModel'); }); @@ -183,7 +185,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAKE:NAME': 'API Fake response' }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0] as CardViewTextItemModel; expect(cardViewProperty instanceof CardViewTextItemModel).toBeTruthy('Property should be instance of CardViewTextItemModel'); expect(cardViewProperty.editable).toBe(false); }); @@ -195,7 +197,7 @@ describe('PropertyGroupTranslatorService', () => { propertyGroups.push(propertyGroup); }); - PropertyGroupTranslatorService.RECOGNISED_ECM_TYPES.forEach((dataType) => { + RECOGNISED_ECM_TYPES.forEach((dataType) => { it(`should translate properly the basic attributes of a property for ${dataType}`, () => { property.name = 'prefix:name'; property.title = 'title'; @@ -219,7 +221,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': 'The Chariot Line' }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0] as CardViewTextItemModel; expect(cardViewProperty instanceof CardViewTextItemModel).toBeTruthy('Property should be instance of CardViewTextItemModel'); expect(cardViewProperty.value).toBe('The Chariot Line'); expect(cardViewProperty.multiline).toBeFalsy('Property should be singleline'); @@ -231,7 +233,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': 'The Chariot Line' }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewTextItemModel = cardViewGroup[0].properties[0] as CardViewTextItemModel; expect(cardViewProperty instanceof CardViewTextItemModel).toBeTruthy('Property should be instance of CardViewTextItemModel'); expect(cardViewProperty.value).toBe('The Chariot Line'); expect(cardViewProperty.multiline).toBeTruthy('Property should be multiline'); @@ -244,7 +246,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': expectedValue }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewDateItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewDateItemModel = cardViewGroup[0].properties[0] as CardViewDateItemModel; expect(cardViewProperty instanceof CardViewDateItemModel).toBeTruthy('Property should be instance of CardViewDateItemModel'); expect(cardViewProperty.value).toBe(expectedValue); }); @@ -256,7 +258,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': expectedValue }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewDatetimeItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewDatetimeItemModel = cardViewGroup[0].properties[0] as CardViewDatetimeItemModel; expect(cardViewProperty instanceof CardViewDatetimeItemModel).toBeTruthy('Property should be instance of CardViewDatetimeItemModel'); expect(cardViewProperty.value).toBe(expectedValue); }); @@ -267,7 +269,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': '1024' }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewIntItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewIntItemModel = cardViewGroup[0].properties[0] as CardViewIntItemModel; expect(cardViewProperty instanceof CardViewIntItemModel).toBeTruthy('Property should be instance of CardViewIntItemModel'); expect(cardViewProperty.value).toBe(1024); }); @@ -278,7 +280,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': 0 }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewIntItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewIntItemModel = cardViewGroup[0].properties[0] as CardViewIntItemModel; expect(cardViewProperty instanceof CardViewIntItemModel).toBeTruthy('Property should be instance of CardViewIntItemModel'); expect(cardViewProperty.value).toBe(0); }); @@ -289,7 +291,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': '1024' }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewIntItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewIntItemModel = cardViewGroup[0].properties[0] as CardViewIntItemModel; expect(cardViewProperty instanceof CardViewIntItemModel).toBeTruthy('Property should be instance of CardViewIntItemModel'); expect(cardViewProperty.value).toBe(1024); }); @@ -300,7 +302,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': '1024.24' }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewFloatItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewFloatItemModel = cardViewGroup[0].properties[0] as CardViewFloatItemModel; expect(cardViewProperty instanceof CardViewFloatItemModel).toBeTruthy('Property should be instance of CardViewFloatItemModel'); expect(cardViewProperty.value).toBe(1024.24); }); @@ -311,7 +313,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': 0 }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewFloatItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewFloatItemModel = cardViewGroup[0].properties[0] as CardViewFloatItemModel; expect(cardViewProperty instanceof CardViewFloatItemModel).toBeTruthy('Property should be instance of CardViewFloatItemModel'); expect(cardViewProperty.value).toBe(0); }); @@ -322,7 +324,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': '1024.24' }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewFloatItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewFloatItemModel = cardViewGroup[0].properties[0] as CardViewFloatItemModel; expect(cardViewProperty instanceof CardViewFloatItemModel).toBeTruthy('Property should be instance of CardViewFloatItemModel'); expect(cardViewProperty.value).toBe(1024.24); }); @@ -333,7 +335,7 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': true }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, null); - const cardViewProperty: CardViewBoolItemModel = cardViewGroup[0].properties[0]; + const cardViewProperty: CardViewBoolItemModel = cardViewGroup[0].properties[0] as CardViewBoolItemModel; expect(cardViewProperty instanceof CardViewBoolItemModel).toBeTruthy('Property should be instance of CardViewBoolItemModel'); expect(cardViewProperty.value).toBe(true); }); @@ -356,23 +358,23 @@ describe('PropertyGroupTranslatorService', () => { propertyValues = { 'FAS:PLAGUE': 'two' }; const cardViewGroup = service.translateToCardViewGroups(propertyGroups, propertyValues, definition); - const cardViewProperty: CardViewSelectItemModel> = >> cardViewGroup[0].properties[0]; + const cardViewProperty = cardViewGroup[0].properties[0] as CardViewSelectItemModel>; expect(cardViewProperty instanceof CardViewSelectItemModel).toBeTruthy('Property should be instance of CardViewBoolItemModel'); expect(cardViewProperty.value).toBe('two'); }); it('should translate content type properties into card items', () => { - const propertyBase = { - 'id': 'fk:brendonstare', - 'title': 'Brendon', - 'description': 'is watching the dark emperor', - 'dataType': 'd:text', - 'isMultiValued': true, - 'isMandatory': true, - 'defaultValue': 'default', - 'isMandatoryEnforced': true, - 'isProtected': false - }; + const propertyBase = { + id: 'fk:brendonstare', + title: 'Brendon', + description: 'is watching the dark emperor', + dataType: 'd:text', + isMultiValued: true, + isMandatory: true, + defaultValue: 'default', + isMandatoryEnforced: true, + isProtected: false + } as PropertyBase; const cardViewProperty = service.translateProperty(propertyBase, 'Scary Brandon and the DuckTales', true); @@ -382,17 +384,17 @@ describe('PropertyGroupTranslatorService', () => { }); it('should translate content type properties into card items with default value when no value is passed', () => { - const propertyBase = { - 'id': 'fk:brendonstare', - 'title': 'Brendon', - 'description': 'is watching the dark emperor', - 'dataType': 'd:text', - 'isMultiValued': true, - 'isMandatory': true, - 'defaultValue': 'default', - 'isMandatoryEnforced': true, - 'isProtected': false - }; + const propertyBase = { + id: 'fk:brendonstare', + title: 'Brendon', + description: 'is watching the dark emperor', + dataType: 'd:text', + isMultiValued: true, + isMandatory: true, + defaultValue: 'default', + isMandatoryEnforced: true, + isProtected: false + } as PropertyBase; const cardViewProperty = service.translateProperty(propertyBase, null, true); @@ -402,17 +404,17 @@ describe('PropertyGroupTranslatorService', () => { }); it('should not edit the protected fields', () => { - const propertyBase = { - 'id': 'fk:emperor', - 'title': 'Emperor', - 'description': 'is watching the dark emperor', - 'dataType': 'd:text', - 'isMultiValued': true, - 'isMandatory': true, - 'defaultValue': 'default', - 'isMandatoryEnforced': true, - 'isProtected': true - }; + const propertyBase = { + id: 'fk:emperor', + title: 'Emperor', + description: 'is watching the dark emperor', + dataType: 'd:text', + isMultiValued: true, + isMandatory: true, + defaultValue: 'default', + isMandatoryEnforced: true, + isProtected: true + } as PropertyBase; const cardViewProperty = service.translateProperty(propertyBase, null, true); diff --git a/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.ts b/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.ts index 50164b62ef6..84ee93b4905 100644 --- a/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.ts +++ b/lib/content-services/src/lib/content-metadata/services/property-groups-translator.service.ts @@ -45,13 +45,12 @@ const D_FLOAT = 'd:float'; const D_DOUBLE = 'd:double'; const D_BOOLEAN = 'd:boolean'; +export const RECOGNISED_ECM_TYPES = [D_TEXT, D_MLTEXT, D_DATE, D_DATETIME, D_INT, D_LONG, D_FLOAT, D_DOUBLE, D_BOOLEAN]; + @Injectable({ providedIn: 'root' }) export class PropertyGroupTranslatorService { - - static readonly RECOGNISED_ECM_TYPES = [D_TEXT, D_MLTEXT, D_DATE, D_DATETIME, D_INT, D_LONG, D_FLOAT, D_DOUBLE, D_BOOLEAN]; - valueSeparator: string; constructor(private logService: LogService, @@ -87,9 +86,7 @@ export class PropertyGroupTranslatorService { } private translateArray(properties: Property[], propertyValues: any, definition: Definition): CardViewItem[] { - return properties.map((property) => { - return this.translate(property, propertyValues, this.getPropertyConstraints(property.name, definition)); - }); + return properties.map((property) => this.translate(property, propertyValues, this.getPropertyConstraints(property.name, definition))); } private translate(property: Property, propertyValues: any, constraints: Constraint[]): CardViewItem { @@ -108,7 +105,7 @@ export class PropertyGroupTranslatorService { key: `${prefix}${property.name}`, default: property.defaultValue, editable: property.protected ? false : property.editable !== undefined ? property.editable : true, - constraints: constraints + constraints }; return this.transform(propertyDefinition, property.dataType, property.multiValued); @@ -189,7 +186,7 @@ export class PropertyGroupTranslatorService { } private checkECMTypeValidity(ecmPropertyType: string) { - if (PropertyGroupTranslatorService.RECOGNISED_ECM_TYPES.indexOf(ecmPropertyType) === -1) { + if (RECOGNISED_ECM_TYPES.indexOf(ecmPropertyType) === -1) { this.logService.error(`Unknown type for mapping: ${ecmPropertyType}`); } } diff --git a/lib/content-services/src/lib/content-node-selector/content-node-dialog.service.spec.ts b/lib/content-services/src/lib/content-node-selector/content-node-dialog.service.spec.ts index af8b467a418..968ecdd1eea 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-dialog.service.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-dialog.service.spec.ts @@ -26,17 +26,17 @@ import { ContentTestingModule } from '../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; import { NodeAction } from '../document-list/models/node-action.enum'; -const fakeNodeEntry: NodeEntry = { +const fakeNodeEntry = { entry: { id: 'fake', name: 'fake-name' } -}; +} as NodeEntry; -const fakeNode: Node = { +const fakeNode = { id: 'fake', name: 'fake-name' -}; +} as Node; const fakeSiteList: SitePaging = new SitePaging({ list: { @@ -94,10 +94,10 @@ describe('ContentNodeDialogService', () => { }); it('should not open the lock node dialog if have no permission', () => { - const testNode: Node = { + const testNode = { id: 'fake', isFile: false - }; + } as Node; service.openLockNodeDialog(testNode).subscribe(() => { }, (error) => { @@ -143,26 +143,26 @@ describe('ContentNodeDialogService', () => { })); describe('for the copy/move dialog', () => { - const siteNode: Node = { + const siteNode: Node = { id: 'site-node-id', nodeType: 'st:site' - }; - const sites: Node = { + } as Node; + const sites: Node = { id: 'sites-id', nodeType: 'st:sites' - }; - const site: Site = { + } as Node; + const site: Site = { id: 'site-id', guid: 'any-guid' - }; - const nodeEntryWithRightPermissions: Node = { + } as Site; + const nodeEntryWithRightPermissions: Node = { id: 'node-id', allowableOperations: ['create'] - }; - const nodeEntryNoPermissions: Node = { + } as Node; + const nodeEntryNoPermissions: Node = { id: 'node-id', allowableOperations: [] - }; + } as Node; const siteFixture = [ { diff --git a/lib/content-services/src/lib/content-node-selector/content-node-dialog.service.ts b/lib/content-services/src/lib/content-node-selector/content-node-dialog.service.ts index cbd261e7add..73a53349a09 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-dialog.service.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-dialog.service.ts @@ -57,17 +57,17 @@ export class ContentNodeDialogService { /** * Opens a file browser at a chosen folder location. * shows files and folders in the dialog search result. + * * @param folderNodeId ID of the folder to use * @returns Information about the selected file(s) */ openFileBrowseDialogByFolderId(folderNodeId: string): Observable { - return this.documentListService.getFolderNode(folderNodeId).pipe(switchMap((nodeEntry: NodeEntry) => { - return this.openUploadFileDialog(NodeAction.CHOOSE, nodeEntry.entry, true); - })); + return this.documentListService.getFolderNode(folderNodeId).pipe(switchMap((nodeEntry: NodeEntry) => this.openUploadFileDialog(NodeAction.CHOOSE, nodeEntry.entry, true))); } /** * Opens a lock node dialog. + * * @param contentEntry Node to lock * @returns Error/status message (if any) */ @@ -95,17 +95,17 @@ export class ContentNodeDialogService { /** * Opens a file browser at a chosen site location. * shows files and folders in the dialog search result. + * * @returns Information about the selected file(s) */ openFileBrowseDialogBySite(): Observable { - return this.siteService.getSites().pipe(switchMap((response: SitePaging) => { - return this.openFileBrowseDialogByFolderId(response.list.entries[0].entry.guid); - })); + return this.siteService.getSites().pipe(switchMap((response: SitePaging) => this.openFileBrowseDialogByFolderId(response.list.entries[0].entry.guid))); } /** * Opens a file browser at a default myFile location. * shows files and folders in the dialog search result. + * * @returns Information about the selected file(s) */ openFileBrowseDialogByDefaultLocation(): Observable { @@ -114,6 +114,7 @@ export class ContentNodeDialogService { /** * Opens a folder browser at a chosen site location. + * * @returns Information about the selected folder(s) */ openFolderBrowseDialogBySite(): Observable { @@ -122,17 +123,17 @@ export class ContentNodeDialogService { /** * Opens a folder browser at a chosen folder location. + * * @param folderNodeId ID of the folder to use * @returns Information about the selected folder(s) */ openFolderBrowseDialogByFolderId(folderNodeId: string): Observable { - return this.documentListService.getFolderNode(folderNodeId).pipe(switchMap((node: NodeEntry) => { - return this.openUploadFolderDialog(NodeAction.CHOOSE, node.entry); - })); + return this.documentListService.getFolderNode(folderNodeId).pipe(switchMap((node: NodeEntry) => this.openUploadFolderDialog(NodeAction.CHOOSE, node.entry))); } /** * Opens a dialog to copy or move an item to a new location. + * * @param action Name of the action (eg, "Copy" or "Move") to show in the title * @param contentEntry Item to be copied or moved * @param permission Permission for the operation @@ -153,7 +154,7 @@ export class ContentNodeDialogService { where: '(isFolder=true)', isSelectionValid: this.isCopyMoveSelectionValid.bind(this), excludeSiteContent: excludeSiteContent || ContentNodeDialogService.nonDocumentSiteContent, - select: select + select }; const dialogRef = this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '630px'); @@ -168,6 +169,7 @@ export class ContentNodeDialogService { /** * Gets the translation of the dialog title. + * * @param action Name of the action to display in the dialog title * @param name Name of the item on which the action is being performed * @returns Translated version of the title @@ -178,6 +180,7 @@ export class ContentNodeDialogService { /** * Opens a dialog to choose folders to upload. + * * @param action Name of the action to show in the title * @param contentEntry Item to upload * @returns Information about the chosen folder(s) @@ -193,7 +196,7 @@ export class ContentNodeDialogService { imageResolver: this.imageResolver.bind(this), isSelectionValid: this.hasAllowableOperationsOnNodeFolder.bind(this), where: '(isFolder=true)', - select: select + select }; const dialogRef = this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '630px'); @@ -204,6 +207,7 @@ export class ContentNodeDialogService { /** * Opens a dialog to choose a file to upload. + * * @param action Name of the action to show in the title * @param contentEntry Item to upload * @param showFilesInResult Show files in dialog search result @@ -219,7 +223,7 @@ export class ContentNodeDialogService { currentFolderId: contentEntry.id, imageResolver: this.imageResolver.bind(this), isSelectionValid: (entry: Node) => entry.isFile, - select: select, + select, showFilesInResult }; diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts index eef77df6d77..71849fdde08 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts @@ -69,16 +69,16 @@ describe('ContentNodeSelectorPanelComponent', () => { let thumbnailService: ThumbnailService; let contentService: ContentService; - function typeToSearchBox(searchTerm = 'string-to-search') { + const typeToSearchBox = (searchTerm = 'string-to-search') => { const searchInput = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-input"]')); searchInput.nativeElement.value = searchTerm; component.searchInput.setValue(searchTerm); fixture.detectChanges(); - } + }; - function triggerSearchResults(searchResults: ResultSetPaging) { + const triggerSearchResults = (searchResults: ResultSetPaging) => { component.queryBuilderService.executed.next(searchResults); - } + }; setupTestBed({ imports: [ @@ -122,12 +122,14 @@ describe('ContentNodeSelectorPanelComponent', () => { beforeEach(() => { documentListService = TestBed.inject(DocumentListService); - spyOn(documentListService, 'getFolderNode').and.returnValue(of( { entry: { path: { elements: [] } } })); + spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: { path: { elements: [] } } })); spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test')); spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { - entries: [ { entry: { guid: 'namek', id: 'namek' } }, - { entry: { guid: 'blog', id: 'blog' } }] + entries: [ + { entry: { guid: 'namek', id: 'namek' } }, + { entry: { guid: 'blog', id: 'blog' } } + ] } }))); @@ -140,7 +142,7 @@ describe('ContentNodeSelectorPanelComponent', () => { }); it('should trigger the select event when selection has been made', (done) => { - const expectedNode = { id: 'fakeid'}; + const expectedNode = { id: 'fakeid'} as Node; component.select.subscribe((nodes) => { expect(nodes.length).toBe(1); expect(nodes[0]).toBe(expectedNode); @@ -155,14 +157,12 @@ describe('ContentNodeSelectorPanelComponent', () => { fixture.detectChanges(); const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } }); - expect(component.rowFilter( { node: { entry: testSiteContent } }, null, null)) + expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)) .toBe(false, 'did not filter out blog'); }); it('should still be able to filter out the exclude site content after rowFilter changes', () => { - const filterFunction1 = () => { - return true; - }; + const filterFunction1 = () => true; const filterFunction2 = (row: ShareDataRow) => { const node: Node = row.node.entry; return node.isFile; @@ -177,12 +177,12 @@ describe('ContentNodeSelectorPanelComponent', () => { properties: { 'st:componentId': 'blog' }, isFile: true }); - expect(component.rowFilter( { node: { entry: testSiteContent } }, null, null)) + expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)) .toBe(false, 'did not filter out blog with filterFunction1'); component.rowFilter = filterFunction2; fixture.detectChanges(); - expect(component.rowFilter( { node: { entry: testSiteContent } }, null, null)) + expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)) .toBe(false, 'did not filter out blog with filterFunction2'); }); @@ -190,7 +190,7 @@ describe('ContentNodeSelectorPanelComponent', () => { fixture.detectChanges(); const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } }); - expect(component.rowFilter( { node: { entry: testSiteContent } }, null, null)).toBe(true); + expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)).toBe(true); }); it('should render search input by default', () => { @@ -227,7 +227,7 @@ describe('ContentNodeSelectorPanelComponent', () => { beforeEach(() => { documentListService = TestBed.inject(DocumentListService); - spyOn(documentListService, 'getFolderNode').and.returnValue(of( { entry: { path: { elements: [] } } })); + spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: { path: { elements: [] } } })); spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test')); spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } }))); @@ -305,7 +305,7 @@ describe('ContentNodeSelectorPanelComponent', () => { component.onFolderChange(nodeEntryEvent); fixture.detectChanges(); - const chosenNode = { path: { elements: [] } }; + const chosenNode = { path: { elements: [] } } as Node; component.onCurrentSelection([ { entry: chosenNode } ]); fixture.detectChanges(); @@ -328,14 +328,12 @@ describe('ContentNodeSelectorPanelComponent', () => { }); it('should make changes to breadcrumb folderNode if breadcrumbTransform is defined', (done) => { - const transformedFolderNode = { + const transformedFolderNode = { id: 'trans-node', name: 'trans-node-name', path: { elements: [{ id: 'testId', name: 'testName' }] } }; - component.breadcrumbTransform = (() => { - return transformedFolderNode; - }); + component.breadcrumbTransform = (() => transformedFolderNode); fixture.detectChanges(); fixture.whenStable().then(() => { @@ -387,11 +385,11 @@ describe('ContentNodeSelectorPanelComponent', () => { describe('Search functionality', () => { let getCorrespondingNodeIdsSpy; let customResourcesService: CustomResourcesService; - const entry: Node = { id: 'fakeid'}; + const entry: Node = { id: 'fakeid'} as Node; beforeEach(() => { const documentListService = TestBed.inject(DocumentListService); - const expectedDefaultFolderNode = { entry: { path: { elements: [] } } }; + const expectedDefaultFolderNode = { entry: { path: { elements: [] } } }; component.isSelectionValid = (node: Node) => node.isFile; spyOn(documentListService, 'getFolderNode').and.returnValue(of(expectedDefaultFolderNode)); @@ -506,7 +504,7 @@ describe('ContentNodeSelectorPanelComponent', () => { })); it('should update the breadcrumb when changing to a custom site', async () => { - component.siteChanged( { entry: { guid: '-mysites-', title: 'My Sites' } }); + component.siteChanged({ entry: { guid: '-mysites-', title: 'My Sites' } } as SiteEntry); expect(component.breadcrumbFolderTitle).toBe('My Sites'); }); @@ -518,7 +516,7 @@ describe('ContentNodeSelectorPanelComponent', () => { expect(searchSpy.calls.count()).toBe(1, 'Search count should be one after only one search'); - component.siteChanged( { entry: { guid: 'namek' } }); + component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry); const expectedQueryBody = mockQueryBody; expectedQueryBody.filterQueries = [ { query: `ANCESTOR:'workspace://SpacesStore/namek'`} ]; @@ -528,7 +526,7 @@ describe('ContentNodeSelectorPanelComponent', () => { })); it('should create the query with the right parameters on changing the site selectBox value from a custom dropdown menu', fakeAsync(() => { - component.dropdownSiteList = { list: { entries: [ { entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } }; + component.dropdownSiteList = { list: { entries: [{ entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } } as SitePaging; fixture.detectChanges(); typeToSearchBox('search-term'); @@ -537,7 +535,7 @@ describe('ContentNodeSelectorPanelComponent', () => { expect(searchSpy.calls.count()).toBe(1); - component.siteChanged( { entry: { guid: '-sites-' } }); + component.siteChanged({ entry: { guid: '-sites-' } } as SiteEntry); const expectedQueryBodyWithSiteChange = mockQueryBody; expectedQueryBodyWithSiteChange.filterQueries = [ @@ -555,26 +553,26 @@ describe('ContentNodeSelectorPanelComponent', () => { tick(debounceSearch); - component.siteChanged( { entry: { guid: '-sites-' } }); + component.siteChanged({ entry: { guid: '-sites-' } } as SiteEntry); expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1, 'getCorrespondingNodeIdsSpy calls count should be one after the site changes to known alias \'-sites\-'); expect(getCorrespondingNodeIdsSpy.calls.mostRecent().args[0]).toEqual('-sites-'); })); it('should get the corresponding node ids on search when a known alias is selected from CUSTOM dropdown', fakeAsync(() => { - component.dropdownSiteList = { list: { entries: [ { entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } }; + component.dropdownSiteList = { list: { entries: [{ entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } } as SitePaging; fixture.detectChanges(); typeToSearchBox('vegeta'); tick(debounceSearch); - component.siteChanged( { entry: { guid: '-sites-' } }); + component.siteChanged({ entry: { guid: '-sites-' } } as SiteEntry); expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1); expect(getCorrespondingNodeIdsSpy.calls.mostRecent().args[0]).toEqual('-sites-'); })); it('should NOT get the corresponding node ids on search when NOTHING is selected from dropdown', fakeAsync(() => { - component.dropdownSiteList = { list: { entries: [ { entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } }; + component.dropdownSiteList = { list: { entries: [{ entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } } as SitePaging; fixture.detectChanges(); typeToSearchBox('vegeta'); @@ -590,13 +588,13 @@ describe('ContentNodeSelectorPanelComponent', () => { expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy should not be called'); - component.siteChanged( { entry: { guid: 'namek' } }); + component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry); expect(getCorrespondingNodeIdsSpy).not.toHaveBeenCalled(); })); it('should NOT get the corresponding node ids on search when NO known alias is selected from CUSTOM dropdown', fakeAsync(() => { - component.dropdownSiteList = { list: { entries: [ { entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } }; + component.dropdownSiteList = { list: { entries: [{ entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } } as SitePaging; fixture.detectChanges(); typeToSearchBox('vegeta'); @@ -604,7 +602,7 @@ describe('ContentNodeSelectorPanelComponent', () => { expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy should not be called'); - component.siteChanged( { entry: { guid: 'namek' } }); + component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry); expect(getCorrespondingNodeIdsSpy).not.toHaveBeenCalled(); })); @@ -730,7 +728,7 @@ describe('ContentNodeSelectorPanelComponent', () => { component.queryBuilderService.userQuery = 'search-term*'; component.currentFolderId = 'my-root-id'; component.restrictRootToCurrentFolderId = true; - component.siteChanged( { entry: { guid: 'my-site-id' } }); + component.siteChanged({ entry: { guid: 'my-site-id' } } as SiteEntry); const expectedQueryBodyWithSiteChange = mockQueryBody; expectedQueryBodyWithSiteChange.filterQueries = [ @@ -799,7 +797,7 @@ describe('ContentNodeSelectorPanelComponent', () => { expect(searchSpy.calls.count()).toBe(1); - component.siteChanged( { entry: { guid: 'namek' } }); + component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry); expect(searchSpy.calls.count()).toBe(2); @@ -833,14 +831,14 @@ describe('ContentNodeSelectorPanelComponent', () => { }) } })) - .toBe(filter( { + .toBe(filter({ node: { entry: new Node({ name: 'impossible-name', id: 'name' }) } - })); + } as ShareDataRow)); }); it('should pass through the excludeSiteContent to the rowFilter of the documentList', () => { @@ -853,7 +851,7 @@ describe('ContentNodeSelectorPanelComponent', () => { expect(documentList.componentInstance.rowFilter).toBeTruthy('Document list should have had a rowFilter'); const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } }); - expect(documentList.componentInstance.rowFilter( { node: { entry: testSiteContent } }, null, null)) + expect(documentList.componentInstance.rowFilter({ node: { entry: testSiteContent } }, null, null)) .toBe(false); }); @@ -948,13 +946,13 @@ describe('ContentNodeSelectorPanelComponent', () => { })); it('should set the folderIdToShow to the default "currentFolderId" if siteId is undefined', (done) => { - component.siteChanged( { entry: { guid: 'Kame-Sennin Muten Roshi' } }); + component.siteChanged({ entry: { guid: 'Kame-Sennin Muten Roshi' } } as SiteEntry); fixture.detectChanges(); let documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]')); expect(documentList.componentInstance.currentFolderId).toBe('Kame-Sennin Muten Roshi'); - component.siteChanged( { entry: { guid: undefined } }); + component.siteChanged({ entry: { guid: undefined } } as SiteEntry); fixture.detectChanges(); documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]')); @@ -990,7 +988,7 @@ describe('ContentNodeSelectorPanelComponent', () => { expect(searchSpy).not.toHaveBeenCalled(); }); - it('should set its loading state to true to perform a new search', async() => { + it('should set its loading state to true to perform a new search', async () => { component.prepareDialogForNewSearch(mockQueryBody); fixture.detectChanges(); await fixture.whenStable(); @@ -1035,18 +1033,16 @@ describe('ContentNodeSelectorPanelComponent', () => { describe('Chosen node', () => { - const entry: Node = { id: 'fakeid'}; - const nodePage: NodePaging = { list: { pagination: {} } }; + const entry: Node = { id: 'fakeid'} as Node; + const nodePage: NodePaging = { list: { pagination: {} } }; let hasAllowableOperations; - const fakeFolderNode = { id: 'fakeNodeId', isFolder: true }; + const fakeFolderNode = { id: 'fakeNodeId', isFolder: true } as Node; - function returnHasPermission(): boolean { - return hasAllowableOperations; - } + const returnHasPermission = (): boolean => hasAllowableOperations; beforeEach(() => { - const schema = [ {}]; - const rows = [ {}, {}]; + const schema = [{}] as DataColumn[]; + const rows = [{}, {}] as DataRow[]; component.documentList.data = new ShareDataTableAdapter(thumbnailService, contentService, schema); spyOn(component.documentList.data, 'getRows').and.returnValue(rows); spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } }))); @@ -1140,7 +1136,7 @@ describe('ContentNodeSelectorPanelComponent', () => { component.documentList.ready.emit(nodePage); }); - it('should NOT be null after clicking on a node (with the right permissions) in the list (onNodeSelect)', async() => { + it('should NOT be null after clicking on a node (with the right permissions) in the list (onNodeSelect)', async () => { hasAllowableOperations = true; component.select.subscribe((nodes) => { @@ -1186,7 +1182,7 @@ describe('ContentNodeSelectorPanelComponent', () => { it('should be empty when the chosenNode is reset', async () => { hasAllowableOperations = true; - component.onCurrentSelection([{ entry: {} }]); + component.onCurrentSelection([{ entry: {} as Node }]); component.select.subscribe((nodes) => { expect(nodes).toBeDefined(); @@ -1235,7 +1231,7 @@ describe('ContentNodeSelectorPanelComponent', () => { it('should be null when the chosenNode is reset', async () => { fixture.detectChanges(); - component.onCurrentSelection([{ entry: {} }]); + component.onCurrentSelection([{ entry: {} as Node }]); component.select.subscribe((nodes) => { expect(nodes).toBeDefined(); @@ -1272,7 +1268,7 @@ describe('ContentNodeSelectorPanelComponent', () => { it('should be null when the chosenNode is reset', async () => { fixture.detectChanges(); - component.onCurrentSelection([{ entry: {} }]); + component.onCurrentSelection([{ entry: {} as Node }]); component.select.subscribe((nodes) => { expect(nodes).toBeDefined(); @@ -1303,7 +1299,7 @@ describe('ContentNodeSelectorPanelComponent', () => { const isUploadingSpy = spyOn(uploadService, 'isUploading').and.returnValue(true); const documentListReloadSpy = spyOn(component.documentList, 'reloadWithoutResettingSelection'); - const fakeFileModels = [new FileModel( { name: 'fake-name', size: 100 }), new FileModel( { name: 'fake-name-2', size: 200 })]; + const fakeFileModels = [new FileModel({ name: 'fake-name', size: 100 } as File), new FileModel({ name: 'fake-name-2', size: 200 } as File)]; const fileUploadCompleteEvent = new FileUploadCompleteEvent(fakeFileModels[0], 1, fakeFileModels[0], 0); uploadService.fileUploadComplete.next(fileUploadCompleteEvent); @@ -1330,8 +1326,8 @@ describe('ContentNodeSelectorPanelComponent', () => { const documentListUnselectRowSpy = spyOn(component.documentList, 'unselectRowFromNodeId'); const documentListReloadSpy = spyOn(component.documentList, 'reloadWithoutResettingSelection'); - const fakeFileModel = new FileModel( { name: 'fake-name', size: 10000000 }); - const fakeNodes = [ { id: 'fakeNodeId' }, { id: 'fakeNodeId2' }]; + const fakeFileModel = new FileModel({ name: 'fake-name', size: 10000000 } as File); + const fakeNodes = [{ id: 'fakeNodeId' }, { id: 'fakeNodeId2' }] as Node[]; fakeFileModel.data = { entry: fakeNodes[0] }; fakeFileModel.status = FileUploadStatus.Deleted; @@ -1375,7 +1371,7 @@ describe('ContentNodeSelectorPanelComponent', () => { contentNodeSelectorPanelService.customModels = undefined; }); - it ('should search panel be collapsed by default and expand when clicking the filter button', async() => { + it ('should search panel be collapsed by default and expand when clicking the filter button', async () => { contentNodeSelectorPanelService.customModels = [mockContentModelTextProperty]; fixture.detectChanges(); diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts index 4f3e09c974f..1698bd2f6df 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts @@ -62,7 +62,7 @@ export const defaultValidation = () => true; templateUrl: './content-node-selector-panel.component.html', styleUrls: ['./content-node-selector-panel.component.scss'], encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-content-node-selector-panel' }, + host: { class: 'adf-content-node-selector-panel' }, providers: [{ provide: SEARCH_QUERY_SERVICE_TOKEN, useClass: SearchQueryBuilderService @@ -70,6 +70,7 @@ export const defaultValidation = () => true; }) export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { + // eslint-disable-next-line @typescript-eslint/naming-convention DEFAULT_PAGINATION: Pagination = new Pagination({ maxItems: 25, skipCount: 0 @@ -418,10 +419,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { if (!filter) { filter = () => true; } - this._rowFilter = (value: ShareDataRow, index: number, array: ShareDataRow[]) => { - return filter(value, index, array) && + this._rowFilter = (value: ShareDataRow, index: number, array: ShareDataRow[]) => filter(value, index, array) && !this.isExcludedSiteContent(value); - }; } private isExcludedSiteContent(row: ShareDataRow): boolean { diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.spec.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.spec.ts index 8374e6c6196..bd55a574fca 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.spec.ts @@ -26,7 +26,6 @@ import { of } from 'rxjs'; import { ContentTestingModule } from '../testing/content.testing.module'; import { DocumentListService } from '../document-list/services/document-list.service'; import { DocumentListComponent } from '../document-list/components/document-list.component'; -import { ShareDataRow } from '../document-list'; import { TranslateModule } from '@ngx-translate/core'; import { UploadModule } from '../upload'; import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component'; @@ -111,19 +110,19 @@ describe('ContentNodeSelectorComponent', () => { fixture.destroy(); }); - function enableLocalUpload() { + const enableLocalUpload = () => { component.data.showLocalUploadButton = true; component.hasAllowableOperations = true; component.showingSearch = false; component.isLoading = false; - } + }; - function selectTabByIndex(tabIndex: number) { + const selectTabByIndex = (tabIndex: number) => { const uploadFromLocalTab = fixture.debugElement.queryAll(By.css('.mat-tab-label'))[tabIndex]; const attributes = uploadFromLocalTab.nativeNode.attributes as NamedNodeMap; const tabPositionInSet = Number(attributes.getNamedItem('aria-posinset').value) - 1; component.onTabSelectionChange(tabPositionInSet); - } + }; describe('Data injecting with the "Material dialog way"', () => { @@ -157,7 +156,7 @@ describe('ContentNodeSelectorComponent', () => { }) } })) - .toBe(data.rowFilter( { + .toBe(data.rowFilter({ node: { entry: new Node({ name: 'impossible-name', @@ -433,7 +432,7 @@ describe('ContentNodeSelectorComponent', () => { }); it('should uploadStarted become true when the first upload gets started', () => { - const fileUploadEvent = new FileUploadEvent(new FileModel( { name: 'fake-name', size: 100 })); + const fileUploadEvent = new FileUploadEvent(new FileModel({ name: 'fake-name', size: 100 } as File)); uploadService.fileUploadStarting.next(fileUploadEvent); expect(component.uploadStarted).toBe(true); diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.ts index 74da77b70fc..14f29250f94 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector.component.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector.component.ts @@ -153,11 +153,11 @@ export class ContentNodeSelectorComponent implements OnInit { this.selectedTabIndex = tabIndex; } - isFileServerTabSelected (): boolean { + isFileServerTabSelected(): boolean { return this.selectedTabIndex === 0; } - isLocalUploadTabSelected (): boolean { + isLocalUploadTabSelected(): boolean { return this.selectedTabIndex === 1; } diff --git a/lib/content-services/src/lib/content-node-selector/name-location-cell/name-location-cell.component.spec.ts b/lib/content-services/src/lib/content-node-selector/name-location-cell/name-location-cell.component.spec.ts index 952277b747e..dbd25a2c6e3 100644 --- a/lib/content-services/src/lib/content-node-selector/name-location-cell/name-location-cell.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/name-location-cell/name-location-cell.component.spec.ts @@ -35,8 +35,8 @@ describe('NameLocationCellComponent', () => { fixture = TestBed.createComponent(NameLocationCellComponent); component = fixture.componentInstance; - rowData = { - getValue(key): any { + rowData = { + getValue: (key): any => { if (key === 'name') { return 'file-name'; } else if (key === 'path') { @@ -44,7 +44,7 @@ describe('NameLocationCellComponent', () => { } return undefined; } - }; + } as DataRow; component.row = rowData; fixture.detectChanges(); }); diff --git a/lib/content-services/src/lib/content-type/content-type-dialog.component.spec.ts b/lib/content-services/src/lib/content-type/content-type-dialog.component.spec.ts index c9e00f7f955..d282e991c14 100644 --- a/lib/content-services/src/lib/content-type/content-type-dialog.component.spec.ts +++ b/lib/content-services/src/lib/content-type/content-type-dialog.component.spec.ts @@ -84,7 +84,7 @@ describe('Content Type Dialog Component', () => { let data: ContentTypeDialogComponentData; beforeEach(async () => { - data = { + data = { title: 'Title', description: 'Description that can be longer or shorter', nodeType: 'fk:fakeNode', diff --git a/lib/content-services/src/lib/dialogs/confirm.dialog.ts b/lib/content-services/src/lib/dialogs/confirm.dialog.ts index e7aec2347f3..bad1c7d8a3a 100644 --- a/lib/content-services/src/lib/dialogs/confirm.dialog.ts +++ b/lib/content-services/src/lib/dialogs/confirm.dialog.ts @@ -32,7 +32,7 @@ export interface ConfirmDialogComponentProps { selector: 'adf-confirm-dialog', templateUrl: './confirm.dialog.html', styleUrls: ['./confirm.dialog.scss'], - host: { 'class': 'adf-confirm-dialog' }, + host: { class: 'adf-confirm-dialog' }, encapsulation: ViewEncapsulation.None }) export class ConfirmDialogComponent { diff --git a/lib/content-services/src/lib/dialogs/folder-name.validators.ts b/lib/content-services/src/lib/dialogs/folder-name.validators.ts index 2e1bf05ac3d..50c2c4a2df2 100644 --- a/lib/content-services/src/lib/dialogs/folder-name.validators.ts +++ b/lib/content-services/src/lib/dialogs/folder-name.validators.ts @@ -19,27 +19,27 @@ import { FormControl } from '@angular/forms'; const I18N_ERRORS_PATH = 'CORE.FOLDER_DIALOG.FOLDER_NAME.ERRORS'; -export function forbidSpecialCharacters({ value }: FormControl) { +export const forbidSpecialCharacters = ({ value }: FormControl) => { const specialCharacters: RegExp = /([\*\"\<\>\\\/\?\:\|])/; const isValid: boolean = !specialCharacters.test(value); return (isValid) ? null : { message: `${I18N_ERRORS_PATH}.SPECIAL_CHARACTERS` }; -} +}; -export function forbidEndingDot({ value }: FormControl) { +export const forbidEndingDot = ({ value }: FormControl) => { const isValid: boolean = ((value || '').trim().split('').pop() !== '.'); return isValid ? null : { message: `${I18N_ERRORS_PATH}.ENDING_DOT` }; -} +}; -export function forbidOnlySpaces({ value }: FormControl) { +export const forbidOnlySpaces = ({ value }: FormControl) => { const isValid: boolean = !!((value || '')).trim(); return isValid ? null : { message: `${I18N_ERRORS_PATH}.ONLY_SPACES` }; -} +}; diff --git a/lib/content-services/src/lib/dialogs/library/library.dialog.spec.ts b/lib/content-services/src/lib/dialogs/library/library.dialog.spec.ts index b0c73c1ea69..6ca00960a7b 100644 --- a/lib/content-services/src/lib/dialogs/library/library.dialog.spec.ts +++ b/lib/content-services/src/lib/dialogs/library/library.dialog.spec.ts @@ -60,9 +60,7 @@ describe('LibraryDialogComponent', () => { it('should set library id automatically on title input', fakeAsync(() => { findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse)); - spyOn(sitesService, 'getSite').and.callFake(() => { - return throwError('error'); - }); + spyOn(sitesService, 'getSite').and.callFake(() => throwError('error')); fixture.detectChanges(); component.form.controls.title.setValue('libraryTitle'); @@ -75,9 +73,7 @@ describe('LibraryDialogComponent', () => { it('should translate library title space character to dash for library id', fakeAsync(() => { findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse)); - spyOn(sitesService, 'getSite').and.callFake(() => { - return throwError('error'); - }); + spyOn(sitesService, 'getSite').and.callFake(() => throwError('error')); fixture.detectChanges(); component.form.controls.title.setValue('library title'); @@ -90,9 +86,7 @@ describe('LibraryDialogComponent', () => { it('should not change custom library id on title input', fakeAsync(() => { findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse)); - spyOn(sitesService, 'getSite').and.callFake(() => { - return throwError('error'); - }); + spyOn(sitesService, 'getSite').and.callFake(() => throwError('error')); fixture.detectChanges(); component.form.controls.id.setValue('custom-id'); @@ -129,9 +123,7 @@ describe('LibraryDialogComponent', () => { spyOn(sitesService, 'createSite').and.returnValue( of({entry: {id: 'fake-id'}} as SiteEntry).pipe(delay(100)) ); - spyOn(sitesService, 'getSite').and.callFake(() => { - return throwError('error'); - }); + spyOn(sitesService, 'getSite').and.callFake(() => throwError('error')); fixture.detectChanges(); component.form.controls.title.setValue('library title'); @@ -196,12 +188,8 @@ describe('LibraryDialogComponent', () => { it('should notify on 409 conflict error (might be in trash)', fakeAsync(() => { findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse)); const error = { message: '{ "error": { "statusCode": 409 } }' }; - spyOn(sitesService, 'createSite').and.callFake(() => { - return throwError(error); - }); - spyOn(sitesService, 'getSite').and.callFake(() => { - return throwError('error'); - }); + spyOn(sitesService, 'createSite').and.callFake(() => throwError(error)); + spyOn(sitesService, 'getSite').and.callFake(() => throwError('error')); fixture.detectChanges(); component.form.controls.title.setValue('test'); @@ -220,9 +208,7 @@ describe('LibraryDialogComponent', () => { it('should not translate library title if value is not a valid id', fakeAsync(() => { findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse)); - spyOn(sitesService, 'getSite').and.callFake(() => { - return throwError('error'); - }); + spyOn(sitesService, 'getSite').and.callFake(() => throwError('error')); fixture.detectChanges(); component.form.controls.title.setValue('@@@####'); @@ -235,9 +221,7 @@ describe('LibraryDialogComponent', () => { it('should translate library title partially for library id', fakeAsync(() => { findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse)); - spyOn(sitesService, 'getSite').and.callFake(() => { - return throwError('error'); - }); + spyOn(sitesService, 'getSite').and.callFake(() => throwError('error')); fixture.detectChanges(); component.form.controls.title.setValue('@@@####library'); @@ -250,9 +234,7 @@ describe('LibraryDialogComponent', () => { it('should translate library title multiple space character to one dash for library id', fakeAsync(() => { findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse)); - spyOn(sitesService, 'getSite').and.callFake(() => { - return throwError('error'); - }); + spyOn(sitesService, 'getSite').and.callFake(() => throwError('error')); fixture.detectChanges(); component.form.controls.title.setValue('library title'); @@ -265,9 +247,7 @@ describe('LibraryDialogComponent', () => { it('should invalidate library title if is too short', fakeAsync(() => { findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse)); - spyOn(sitesService, 'getSite').and.callFake(() => { - return throwError('error'); - }); + spyOn(sitesService, 'getSite').and.callFake(() => throwError('error')); fixture.detectChanges(); component.form.controls.title.setValue('l'); diff --git a/lib/content-services/src/lib/dialogs/library/library.dialog.ts b/lib/content-services/src/lib/dialogs/library/library.dialog.ts index 1536aec73a7..6ad22250a17 100644 --- a/lib/content-services/src/lib/dialogs/library/library.dialog.ts +++ b/lib/content-services/src/lib/dialogs/library/library.dialog.ts @@ -177,12 +177,12 @@ export class LibraryDialogComponent implements OnInit, OnDestroy { private create(): Observable { const { title, id, description, visibility } = this; - const siteBody = { + const siteBody = { id, title, description, visibility - }; + } as SiteBodyCreate; return this.sitesService.createSite(siteBody); } @@ -206,8 +206,7 @@ export class LibraryDialogComponent implements OnInit, OnDestroy { message: 'LIBRARY.ERRORS.CONFLICT' }); } - } catch (error) { - + } catch { } return error; @@ -274,12 +273,10 @@ export class LibraryDialogComponent implements OnInit, OnDestroy { } return new Promise((resolve) => { - timer = setTimeout(() => { - return this.sitesService.getSite(control.value).subscribe( - () => resolve({ message: 'LIBRARY.ERRORS.EXISTENT_SITE' }), - () => resolve(null) - ); - }, 300); + timer = setTimeout(() => this.sitesService.getSite(control.value).subscribe( + () => resolve({ message: 'LIBRARY.ERRORS.EXISTENT_SITE' }), + () => resolve(null) + ), 300); }); }; } diff --git a/lib/content-services/src/lib/dialogs/node-lock.dialog.ts b/lib/content-services/src/lib/dialogs/node-lock.dialog.ts index 17037dc7bab..dcbbdd7a2d1 100644 --- a/lib/content-services/src/lib/dialogs/node-lock.dialog.ts +++ b/lib/content-services/src/lib/dialogs/node-lock.dialog.ts @@ -74,9 +74,9 @@ export class NodeLockDialogComponent implements OnInit { private get nodeBodyLock(): NodeBodyLock { return new NodeBodyLock({ - 'timeToExpire': this.lockTimeInSeconds, - 'type': this.form.value.allowOwner ? 'ALLOW_OWNER_CHANGES' : 'FULL', - 'lifetime': 'PERSISTENT' + timeToExpire: this.lockTimeInSeconds, + type: this.form.value.allowOwner ? 'ALLOW_OWNER_CHANGES' : 'FULL', + lifetime: 'PERSISTENT' }); } diff --git a/lib/content-services/src/lib/directives/node-lock.directive.spec.ts b/lib/content-services/src/lib/directives/node-lock.directive.spec.ts index 4786004b2ae..2c928b5b212 100644 --- a/lib/content-services/src/lib/directives/node-lock.directive.spec.ts +++ b/lib/content-services/src/lib/directives/node-lock.directive.spec.ts @@ -26,11 +26,11 @@ import { setupTestBed } from '@alfresco/adf-core'; import { ContentTestingModule } from '../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; -const fakeNode: Node = { +const fakeNode = { id: 'fake', isFile: true, isLocked: false -}; +} as Node; @Component({ template: '
' diff --git a/lib/content-services/src/lib/document-list/components/content-action/content-action-list.component.ts b/lib/content-services/src/lib/document-list/components/content-action/content-action-list.component.ts index 2206dd306d1..9459ed2fccd 100644 --- a/lib/content-services/src/lib/document-list/components/content-action/content-action-list.component.ts +++ b/lib/content-services/src/lib/document-list/components/content-action/content-action-list.component.ts @@ -33,6 +33,7 @@ export class ContentActionListComponent { /** * Registers action handler within the parent document list component. + * * @param action Action model to register. */ registerAction(action: ContentActionModel): boolean { diff --git a/lib/content-services/src/lib/document-list/components/content-action/content-action.component.spec.ts b/lib/content-services/src/lib/document-list/components/content-action/content-action.component.spec.ts index 3567199c19b..06b0a38c7ab 100644 --- a/lib/content-services/src/lib/document-list/components/content-action/content-action.component.spec.ts +++ b/lib/content-services/src/lib/document-list/components/content-action/content-action.component.spec.ts @@ -94,16 +94,14 @@ describe('ContentAction', () => { action.visible = false; action.ngOnChanges({ - 'visible': new SimpleChange(true, false, false) + visible: new SimpleChange(true, false, false) }); expect(action.documentActionModel.visible).toBeFalsy(); }); it('should get action handler from document actions service', () => { - - const handler = function () { - }; + const handler = () => {}; spyOn(documentActions, 'getHandler').and.returnValue(handler); const action = new ContentActionComponent(actionList, documentActions, null); @@ -119,8 +117,7 @@ describe('ContentAction', () => { }); it('should get action handler from folder actions service', () => { - const handler = function () { - }; + const handler = () => {}; spyOn(folderActions, 'getHandler').and.returnValue(handler); const action = new ContentActionComponent(actionList, null, folderActions); diff --git a/lib/content-services/src/lib/document-list/components/content-action/content-action.component.ts b/lib/content-services/src/lib/document-list/components/content-action/content-action.component.ts index b913f0a66ac..ed6e8d78611 100644 --- a/lib/content-services/src/lib/document-list/components/content-action/content-action.component.ts +++ b/lib/content-services/src/lib/document-list/components/content-action/content-action.component.ts @@ -163,7 +163,7 @@ export class ContentActionComponent implements OnInit, OnChanges, OnDestroy { icon: this.icon, permission: this.permission, disableWithNoPermission: this.disableWithNoPermission, - target: target, + target, disabled: this.disabled, visible: this.visible }); diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts index e6285385821..dfc25ddbf99 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts @@ -86,8 +86,7 @@ describe('DocumentList', () => { beforeEach(() => { eventMock = { - preventDefault: function () { - } + preventDefault: () => {} }; fixture = TestBed.createComponent(DocumentListComponent); @@ -237,7 +236,7 @@ describe('DocumentList', () => { const resetSelectionSpy = spyOn(documentList, 'resetSelection').and.callThrough(); documentList.selection = [{ entry: mockNode3 }]; const changes: SimpleChanges = { - 'preselectNodes': { + preselectNodes: { previousValue: undefined, currentValue: mockPreselectedNodes, firstChange: true, @@ -256,7 +255,7 @@ describe('DocumentList', () => { const resetSelectionSpy = spyOn(documentList, 'resetSelection').and.callThrough(); documentList.selection = [{ entry: mockNode3 }]; const changes: SimpleChanges = { - 'mockChange': { + mockChange: { previousValue: undefined, currentValue: ['mockChangeValue'], firstChange: true, @@ -303,14 +302,14 @@ describe('DocumentList', () => { it('should add the custom columns', () => { fixture.detectChanges(); - const column = { + const column = { title: 'title', key: 'source', cssClass: 'css', srTitle: '', type: 'text', format: '' - }; + } as DataColumn; const columns = documentList.data.getColumns(); columns.push(column); @@ -456,8 +455,7 @@ describe('DocumentList', () => { it('should not execute action without node provided', () => { const action = new ContentActionModel(); - action.handler = function () { - }; + action.handler = () => {}; spyOn(action, 'handler').and.stub(); documentList.executeContentAction(null, action); @@ -1167,7 +1165,7 @@ describe('DocumentList', () => { it('should set row filter and reload contents if currentFolderId is set when setting rowFilter', () => { fixture.detectChanges(); - const filter = {}; + const filter = {} as RowFilter; documentList.currentFolderId = 'id'; spyOn(documentList.data, 'setFilter').and.callThrough(); @@ -1181,14 +1179,14 @@ describe('DocumentList', () => { spyFolder.calls.reset(); documentList.currentFolderId = null; - documentList.ngOnChanges({ rowFilter: new SimpleChange(null, {}, true) }); + documentList.ngOnChanges({ rowFilter: new SimpleChange(null, {} as RowFilter, true) }); expect(spyFolder).not.toHaveBeenCalled(); }); it('should set image resolver for underlying adapter', () => { fixture.detectChanges(); - const resolver = {}; + const resolver = {} as ImageResolver; spyOn(documentList.data, 'setImageResolver').and.callThrough(); documentList.ngOnChanges({ imageResolver: new SimpleChange(null, resolver, true) }); @@ -1324,9 +1322,7 @@ describe('DocumentList', () => { }); it('should allow to perform navigation for virtual sources', () => { - spyFolderNode = spyOn(documentListService, 'loadFolderByNodeId').and.callFake(() => { - return of(new DocumentLoaderNode(null, { list: { pagination: {} } })); - }); + spyFolderNode = spyOn(documentListService, 'loadFolderByNodeId').and.callFake(() => of(new DocumentLoaderNode(null, { list: { pagination: {} } }))); const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-']; const node = new FolderNode('folder'); @@ -1725,18 +1721,18 @@ describe('DocumentList', () => { const fakeDatatableRows = [new ShareDataRow(mockPreselectedNodes[0], contentService, null), new ShareDataRow(mockPreselectedNodes[1], contentService, null)]; fakeDatatableRows[0].isSelected = true; documentList.data.setRows(fakeDatatableRows); - let selectedRows = documentList.data.getSelectedRows(); + let selection = documentList.data.getSelectedRows(); - expect(selectedRows.length).toEqual(1); + expect(selection.length).toEqual(1); documentList.unselectRowFromNodeId(mockPreselectedNodes[0].entry.id); - selectedRows = documentList.data.getSelectedRows(); + selection = documentList.data.getSelectedRows() as ShareDataRow[]; - expect(selectedRows).toEqual([]); + expect(selection).toEqual([]); expect(getSelectionSpy).toHaveBeenCalled(); expect(getRowByNodeIdSpy).toHaveBeenCalledWith(mockPreselectedNodes[0].entry.id); expect(datatableSelectRowSpy).toHaveBeenCalledWith(fakeDatatableRows[0], false); - expect(onNodeUnselectSpy).toHaveBeenCalledWith({ row: undefined, selection: selectedRows }); + expect(onNodeUnselectSpy).toHaveBeenCalledWith({ row: undefined, selection }); }); it('should preselect the rows of the preselected nodes', () => { @@ -1782,16 +1778,16 @@ describe('DocumentList', () => { documentList.selectionMode = 'multiple'; documentList.preselectNodes = mockPreselectedNodes; documentList.onPreselectNodes(); - const selectedRows = documentList.data.getSelectedRows(); + const selection = documentList.data.getSelectedRows() as ShareDataRow[]; expect(hasPreselectedNodesSpy).toHaveBeenCalled(); expect(preselectRowsOfPreselectedNodesSpy).toHaveBeenCalled(); expect(getPreselectedRowsBasedOnSelectionModeSpy).toHaveBeenCalled(); - expect(selectedRows.length).toEqual(3); - expect(selectedRows[0].id).toEqual(mockNode1.id); - expect(selectedRows[1].id).toEqual(mockNode2.id); - expect(selectedRows[2].id).toEqual(mockNode3.id); - expect(onNodeSelectSpy).toHaveBeenCalledWith({ row: undefined, selection: selectedRows }); + expect(selection.length).toEqual(3); + expect(selection[0].id).toEqual(mockNode1.id); + expect(selection[1].id).toEqual(mockNode2.id); + expect(selection[2].id).toEqual(mockNode3.id); + expect(onNodeSelectSpy).toHaveBeenCalledWith({ row: undefined, selection }); }); }); }); diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.ts b/lib/content-services/src/lib/document-list/components/document-list.component.ts index cc6e3a99c00..457d5a13eea 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.ts @@ -16,6 +16,7 @@ */ /* eslint-disable rxjs/no-subject-value */ +/* eslint-disable @typescript-eslint/naming-convention */ import { AfterContentInit, Component, ContentChild, ElementRef, EventEmitter, HostListener, Input, NgZone, @@ -371,13 +372,11 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte if (node && node.entry) { const actions = this.getNodeActions(node); if (actions && actions.length > 0) { - return actions.map((currentAction: ContentActionModel) => { - return { - model: currentAction, - node: node, - subject: this.contextActionHandler - }; - }); + return actions.map((currentAction: ContentActionModel) => ({ + model: currentAction, + node, + subject: this.contextActionHandler + })); } } return null; @@ -447,7 +446,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte let schema: DataColumn[] = []; if (this.hasCustomLayout) { - schema = this.columnList.columns.map((c) => c); + schema = this.columnList.columns.map((c) => c as DataColumn); } if (!this.data) { @@ -614,14 +613,14 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte if (typeof node === 'string') { this.resetNewFolderPagination(); this.currentFolderId = node; - this.folderChange.emit(new NodeEntryEvent( { id: node })); + this.folderChange.emit(new NodeEntryEvent({ id: node } as Node)); this.reload(); return true; } else { if (this.canNavigateFolder(node)) { this.resetNewFolderPagination(); this.currentFolderId = this.getNodeFolderDestinationId(node); - this.folderChange.emit(new NodeEntryEvent( { id: this.currentFolderId })); + this.folderChange.emit(new NodeEntryEvent({ id: this.currentFolderId } as Node)); this.reload(); return true; } @@ -644,6 +643,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte /** * Invoked when executing content action for a document or folder. + * * @param node Node to be the context of the execution. * @param action Action to be executed against the context. */ @@ -845,7 +845,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte onShowRowContextMenu(event: DataCellEvent) { if (this.contextMenuActions) { const args = event.value; - const node = ( args.row).node; + const node = args.row.node; if (node) { args.actions = this.getContextActions(node) || []; } @@ -855,7 +855,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte onShowRowActionsMenu(event: DataCellEvent) { if (this.contentActions) { const args = event.value; - const node = ( args.row).node; + const node = args.row.node; if (node) { args.actions = this.getNodeActions(node) || []; } @@ -865,8 +865,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte onExecuteRowAction(event: DataRowActionEvent) { if (this.contentActions) { const args = event.value; - const node = ( args.row).node; - const action = ( args.action); + const node = args.row.node; + const action = args.action; this.executeContentAction(node, action); } } @@ -952,12 +952,12 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte if (this.hasPreselectedNodes()) { this.preselectRowsOfPreselectedNodes(); const preselectedRows = this.getPreselectedRowsBasedOnSelectionMode(); - const selectedNodes = this.data.getSelectedRows(); + const selection = this.data.getSelectedRows() as ShareDataRow[]; for (const node of preselectedRows) { this.dataTable.selectRow(node, true); } - this.onNodeSelect({ row: undefined, selection: selectedNodes }); + this.onNodeSelect({ row: undefined, selection }); } } @@ -990,8 +990,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte if (rowToUnselect?.isSelected) { rowToUnselect.isSelected = false; this.dataTable.selectRow(rowToUnselect, false); - const selection = this.getSelectionBasedOnSelectionMode(); - this.onNodeUnselect({ row: undefined, selection: selection }); + const selection = this.getSelectionBasedOnSelectionMode() as ShareDataRow[]; + this.onNodeUnselect({ row: undefined, selection }); } } diff --git a/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.spec.ts b/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.spec.ts index 20bff33a15b..a9519d090e7 100644 --- a/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.spec.ts +++ b/lib/content-services/src/lib/document-list/components/filter-header/filter-header.component.spec.ts @@ -36,7 +36,7 @@ describe('FilterHeaderComponent', () => { dataLoaded: new Subject() }; - const paginationMock = { maxItems: 10, skipCount: 0 }; + const paginationMock = { maxItems: 10, skipCount: 0 }; const documentListMock = { node: 'my-node', diff --git a/lib/content-services/src/lib/document-list/components/library-name-column/library-name-column.component.spec.ts b/lib/content-services/src/lib/document-list/components/library-name-column/library-name-column.component.spec.ts index e417a59edf5..a49469f1e8c 100644 --- a/lib/content-services/src/lib/document-list/components/library-name-column/library-name-column.component.spec.ts +++ b/lib/content-services/src/lib/document-list/components/library-name-column/library-name-column.component.spec.ts @@ -36,7 +36,7 @@ describe('LibraryNameColumnComponent', () => { }); beforeEach(() => { - node = { + node = { id: 'nodeId', path: { elements: [] @@ -76,8 +76,8 @@ describe('LibraryNameColumnComponent', () => { node.title = 'title'; const rows = [ - { node: { entry: { id: 'some-id', title: 'title' } } } - ]; + { node: { entry: { id: 'some-id', title: 'title' } } } + ] as any[]; const title = component.makeLibraryTitle(node, rows); expect(title).toContain('nodeId'); @@ -87,10 +87,10 @@ describe('LibraryNameColumnComponent', () => { node.title = 'title'; const rows = [ - { + { node: { entry: { id: 'some-id', title: 'title-some-id' } } } - ]; + ] as any[]; const title = component.makeLibraryTitle(node, rows); diff --git a/lib/content-services/src/lib/document-list/components/library-name-column/library-name-column.component.ts b/lib/content-services/src/lib/document-list/components/library-name-column/library-name-column.component.ts index 1c66e8d355a..e89f4be40ae 100644 --- a/lib/content-services/src/lib/document-list/components/library-name-column/library-name-column.component.ts +++ b/lib/content-services/src/lib/document-list/components/library-name-column/library-name-column.component.ts @@ -89,7 +89,7 @@ export class LibraryNameColumnComponent implements OnInit, OnDestroy { const rows: Array = this.context.data.rows || []; if (this.node && this.node.entry) { this.displayText$.next( - this.makeLibraryTitle( this.node.entry, rows) + this.makeLibraryTitle(this.node.entry as any, rows) ); this.displayTooltip$.next(this.makeLibraryTooltip(this.node.entry)); } @@ -119,9 +119,7 @@ export class LibraryNameColumnComponent implements OnInit, OnDestroy { let isDuplicate = false; if (entries) { - isDuplicate = entries.some((entry: any) => { - return entry.id !== id && entry.title === title; - }); + isDuplicate = entries.some((entry: any) => entry.id !== id && entry.title === title); } return isDuplicate ? `${title} (${id})` : `${title}`; diff --git a/lib/content-services/src/lib/document-list/components/name-column/name-column.component.spec.ts b/lib/content-services/src/lib/document-list/components/name-column/name-column.component.spec.ts index 8acb0c5b19e..0a5c46153c4 100644 --- a/lib/content-services/src/lib/document-list/components/name-column/name-column.component.spec.ts +++ b/lib/content-services/src/lib/document-list/components/name-column/name-column.component.spec.ts @@ -39,9 +39,7 @@ describe('NameColumnComponent', () => { context = { row: { node: {entry: {}}, - getValue(key) { - return key; - } + getValue: (key) => key } }; diff --git a/lib/content-services/src/lib/document-list/components/trashcan-name-column/trashcan-name-column.component.ts b/lib/content-services/src/lib/document-list/components/trashcan-name-column/trashcan-name-column.component.ts index 34446dbbf38..c42e7bed3c0 100644 --- a/lib/content-services/src/lib/document-list/components/trashcan-name-column/trashcan-name-column.component.ts +++ b/lib/content-services/src/lib/document-list/components/trashcan-name-column/trashcan-name-column.component.ts @@ -75,9 +75,7 @@ export class TrashcanNameColumnComponent implements OnInit { let isDuplicate = false; if (entries) { - isDuplicate = entries.some((entry: any) => { - return entry.id !== id && entry.properties['cm:title'] === title; - }); + isDuplicate = entries.some((entry: any) => entry.id !== id && entry.properties['cm:title'] === title); } return isDuplicate diff --git a/lib/content-services/src/lib/document-list/data/share-data-row.model.ts b/lib/content-services/src/lib/document-list/data/share-data-row.model.ts index 0d856ff723e..b418617e807 100644 --- a/lib/content-services/src/lib/document-list/data/share-data-row.model.ts +++ b/lib/content-services/src/lib/document-list/data/share-data-row.model.ts @@ -19,10 +19,9 @@ import { DataRow, ObjectUtils, ThumbnailService, ContentService } from '@alfresc import { MinimalNode, NodeEntry } from '@alfresco/js-api'; import { PermissionStyleModel } from './../models/permissions-style.model'; -export class ShareDataRow implements DataRow { - - static ERR_OBJECT_NOT_FOUND: string = 'Object source not found'; +export const ERR_OBJECT_NOT_FOUND: string = 'Object source not found'; +export class ShareDataRow implements DataRow { cache: { [key: string]: any } = {}; isSelected: boolean = false; isDropTarget: boolean; @@ -44,7 +43,7 @@ export class ShareDataRow implements DataRow { private thumbnailService?: ThumbnailService, private allowDropFiles?: boolean) { if (!obj) { - throw new Error(ShareDataRow.ERR_OBJECT_NOT_FOUND); + throw new Error(ERR_OBJECT_NOT_FOUND); } this.isDropTarget = allowDropFiles !== undefined ? this.allowDropFiles && this.checkNodeTypeAndPermissions(obj) : this.checkNodeTypeAndPermissions(obj); diff --git a/lib/content-services/src/lib/document-list/data/share-datatable-adapter.spec.ts b/lib/content-services/src/lib/document-list/data/share-datatable-adapter.spec.ts index 7abd906cc62..5b14c65144f 100644 --- a/lib/content-services/src/lib/document-list/data/share-datatable-adapter.spec.ts +++ b/lib/content-services/src/lib/document-list/data/share-datatable-adapter.spec.ts @@ -17,8 +17,8 @@ import { DataColumn, DataRow, DataSorting, ContentService, ThumbnailService, setupTestBed } from '@alfresco/adf-core'; import { FileNode, FolderNode, SmartFolderNode, RuleFolderNode, LinkFolderNode } from './../../mock'; -import { ShareDataRow } from './share-data-row.model'; -import { ShareDataTableAdapter } from './share-datatable-adapter'; +import { ERR_OBJECT_NOT_FOUND, ShareDataRow } from './share-data-row.model'; +import { ERR_COL_NOT_FOUND, ERR_ROW_NOT_FOUND, ShareDataTableAdapter } from './share-datatable-adapter'; import { ContentTestingModule } from '../../testing/content.testing.module'; import { TestBed } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; @@ -70,7 +70,7 @@ describe('ShareDataTableAdapter', () => { }); it('should setup rows and columns with constructor', () => { - const schema = [ {}]; + const schema = [{}] as DataColumn[]; const adapter = new ShareDataTableAdapter(thumbnailService, contentService, schema); expect(adapter.getRows()).toEqual([]); @@ -83,14 +83,14 @@ describe('ShareDataTableAdapter', () => { }); it('should set new columns', () => { - const columns = [ {}, {}]; + const columns = [{}, {}] as DataColumn[]; const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); adapter.setColumns(columns); expect(adapter.getColumns()).toEqual(columns); }); it('should reset columns', () => { - const columns = [ {}, {}]; + const columns = [{} as DataColumn, {} as DataColumn]; const adapter = new ShareDataTableAdapter(thumbnailService, contentService, columns); expect(adapter.getColumns()).toEqual(columns); @@ -99,7 +99,7 @@ describe('ShareDataTableAdapter', () => { }); it('should set new rows', () => { - const rows = [ {}, {}]; + const rows = [{}, {}] as DataRow[]; const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); expect(adapter.getRows()).toEqual([]); @@ -108,7 +108,7 @@ describe('ShareDataTableAdapter', () => { }); it('should reset rows', () => { - const rows = [ {}, {}]; + const rows = [{}, {}] as DataRow[]; const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); adapter.setRows(rows); @@ -122,7 +122,7 @@ describe('ShareDataTableAdapter', () => { const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); spyOn(adapter, 'sort').and.callThrough(); - const rows = [ {}]; + const rows = [{}] as DataRow[]; adapter.setRows(rows); expect(adapter.sort).toHaveBeenCalled(); @@ -130,18 +130,14 @@ describe('ShareDataTableAdapter', () => { it('should fail when getting value for missing row', () => { const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); - const check = () => { - return adapter.getValue(null, {}); - }; - expect(check).toThrowError(adapter.ERR_ROW_NOT_FOUND); + const check = () => adapter.getValue(null, {} as DataColumn); + expect(check).toThrowError(ERR_ROW_NOT_FOUND); }); it('should fail when getting value for missing column', () => { const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); - const check = () => { - return adapter.getValue( {}, null); - }; - expect(check).toThrowError(adapter.ERR_COL_NOT_FOUND); + const check = () => adapter.getValue({} as DataRow, null); + expect(check).toThrowError(ERR_COL_NOT_FOUND); }); it('should return date value as string', () => { @@ -150,10 +146,10 @@ describe('ShareDataTableAdapter', () => { const file = new FileNode(); file.entry.createdAt = rawValue; - const col = { + const col = { key: 'createdAt', type: 'text' - }; + } as DataColumn; const row = new ShareDataRow(file, contentService, null); const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); @@ -171,7 +167,7 @@ describe('ShareDataTableAdapter', () => { file.entry.content.mimeType = null; const row = new ShareDataRow(file, contentService, null); - const col = { type: 'image', key: '$thumbnail' }; + const col = { type: 'image', key: '$thumbnail' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toContain(`assets/images/ft_ic_miscellaneous`); @@ -187,7 +183,7 @@ describe('ShareDataTableAdapter', () => { file.entry.content = null; const row = new ShareDataRow(file, contentService, null); - const col = { type: 'image', key: '$thumbnail' }; + const col = { type: 'image', key: '$thumbnail' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toContain(`assets/images/ft_ic_miscellaneous`); @@ -202,7 +198,7 @@ describe('ShareDataTableAdapter', () => { const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); const row = new ShareDataRow(file, contentService, null); - const col = { type: 'image', key: 'icon' }; + const col = { type: 'image', key: 'icon' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toBe(imageUrl); @@ -214,7 +210,7 @@ describe('ShareDataTableAdapter', () => { const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); const row = new ShareDataRow(new FolderNode(), contentService, null); - const col = { type: 'image', key: '$thumbnail' }; + const col = { type: 'image', key: '$thumbnail' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toContain(`assets/images/ft_ic_folder`); @@ -227,7 +223,7 @@ describe('ShareDataTableAdapter', () => { const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); const row = new ShareDataRow(new SmartFolderNode(), contentService, null); - const col = { type: 'text', key: '$thumbnail' }; + const col = { type: 'text', key: '$thumbnail' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toContain(`assets/images/ft_ic_smart_folder`); @@ -240,7 +236,7 @@ describe('ShareDataTableAdapter', () => { const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); const row = new ShareDataRow(new LinkFolderNode(), contentService, null); - const col = { type: 'text', key: '$thumbnail' }; + const col = { type: 'text', key: '$thumbnail' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toContain(`assets/images/ft_ic_folder_shortcut_link`); @@ -253,7 +249,7 @@ describe('ShareDataTableAdapter', () => { const adapter = new ShareDataTableAdapter(thumbnailService, contentService, null); const row = new ShareDataRow(new RuleFolderNode(), contentService, null); - const col = { type: 'text', key: '$thumbnail' }; + const col = { type: 'text', key: '$thumbnail' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toContain(`assets/images/ft_ic_folder_rule`); @@ -267,7 +263,7 @@ describe('ShareDataTableAdapter', () => { const file = new FileNode(); const row = new ShareDataRow(file, contentService, null); - const col = { type: 'image', key: '$thumbnail' }; + const col = { type: 'image', key: '$thumbnail' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toBe(imageUrl); @@ -285,7 +281,7 @@ describe('ShareDataTableAdapter', () => { file.entry.content = null; const row = new ShareDataRow(file, contentService, null); - const col = { type: 'image', key: '$thumbnail' }; + const col = { type: 'image', key: '$thumbnail' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toContain(`assets/images/ft_ic_miscellaneous`); @@ -302,7 +298,7 @@ describe('ShareDataTableAdapter', () => { file.entry.content.mimeType = 'image/png'; const row = new ShareDataRow(file, contentService, null); - const col = { type: 'image', key: '$thumbnail' }; + const col = { type: 'image', key: '$thumbnail' } as DataColumn; const value = adapter.getValue(row, col); expect(value).toContain(`assets/images/ft_ic_raster_image`); @@ -314,7 +310,7 @@ describe('ShareDataTableAdapter', () => { const file2 = new FileNode('file2'); const folder = new FolderNode(); - const col = { key: 'name' }; + const col = { key: 'name' } as DataColumn; const adapter = new ShareDataTableAdapter(thumbnailService, contentService, [col]); adapter.setSorting(new DataSorting('name', 'asc')); @@ -325,9 +321,9 @@ describe('ShareDataTableAdapter', () => { ]); const sorted = adapter.getRows(); - expect(( sorted[0]).node).toBe(folder); - expect(( sorted[1]).node).toBe(file1); - expect(( sorted[2]).node).toBe(file2); + expect((sorted[0]).node).toBe(folder); + expect((sorted[1]).node).toBe(file1); + expect((sorted[2]).node).toBe(file2); }); it('should sort by dates up to ms', () => { @@ -337,7 +333,7 @@ describe('ShareDataTableAdapter', () => { const file2 = new FileNode('file2'); file2.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 2); - const col = { key: 'dateProp' }; + const col = { key: 'dateProp' } as DataColumn; const adapter = new ShareDataTableAdapter(thumbnailService, contentService, [col]); adapter.setRows([ @@ -348,12 +344,12 @@ describe('ShareDataTableAdapter', () => { adapter.sort('dateProp', 'asc'); const rows = adapter.getRows(); - expect(( rows[0]).node).toBe(file1); - expect(( rows[1]).node).toBe(file2); + expect((rows[0]).node).toBe(file1); + expect((rows[1]).node).toBe(file2); adapter.sort('dateProp', 'desc'); - expect(( rows[0]).node).toBe(file2); - expect(( rows[1]).node).toBe(file1); + expect((rows[0]).node).toBe(file2); + expect((rows[1]).node).toBe(file1); }); it('should sort by file size', () => { @@ -367,7 +363,7 @@ describe('ShareDataTableAdapter', () => { file3.entry.content.sizeInBytes = 4224120; // 4.03 MB file4.entry.content.sizeInBytes = 2852791665; // 2.66 GB - const col = { key: 'content.sizeInBytes' }; + const col = { key: 'content.sizeInBytes' } as DataColumn; const adapter = new ShareDataTableAdapter(thumbnailService, contentService, [col]); adapter.setRows([ @@ -380,16 +376,16 @@ describe('ShareDataTableAdapter', () => { adapter.sort('content.sizeInBytes', 'asc'); const rows = adapter.getRows(); - expect(( rows[0]).node).toBe(file1); - expect(( rows[1]).node).toBe(file2); - expect(( rows[2]).node).toBe(file3); - expect(( rows[3]).node).toBe(file4); + expect((rows[0]).node).toBe(file1); + expect((rows[1]).node).toBe(file2); + expect((rows[2]).node).toBe(file3); + expect((rows[3]).node).toBe(file4); adapter.sort('content.sizeInBytes', 'desc'); - expect(( rows[0]).node).toBe(file4); - expect(( rows[1]).node).toBe(file3); - expect(( rows[2]).node).toBe(file2); - expect(( rows[3]).node).toBe(file1); + expect((rows[0]).node).toBe(file4); + expect((rows[1]).node).toBe(file3); + expect((rows[2]).node).toBe(file2); + expect((rows[3]).node).toBe(file1); }); it('should sort by name', () => { @@ -400,7 +396,7 @@ describe('ShareDataTableAdapter', () => { const file5 = new FileNode('a'); const file6 = new FileNode('b'); - const col = { key: 'name' }; + const col = { key: 'name' } as DataColumn; const adapter = new ShareDataTableAdapter(thumbnailService, contentService, [col]); adapter.setRows([ @@ -415,20 +411,20 @@ describe('ShareDataTableAdapter', () => { adapter.sort('name', 'asc'); const rows = adapter.getRows(); - expect(( rows[0]).node).toBe(file5); - expect(( rows[1]).node).toBe(file6); - expect(( rows[2]).node).toBe(file1); - expect(( rows[3]).node).toBe(file2); - expect(( rows[4]).node).toBe(file4); - expect(( rows[5]).node).toBe(file3); + expect((rows[0]).node).toBe(file5); + expect((rows[1]).node).toBe(file6); + expect((rows[2]).node).toBe(file1); + expect((rows[3]).node).toBe(file2); + expect((rows[4]).node).toBe(file4); + expect((rows[5]).node).toBe(file3); adapter.sort('name', 'desc'); - expect(( rows[0]).node).toBe(file3); - expect(( rows[1]).node).toBe(file4); - expect(( rows[2]).node).toBe(file2); - expect(( rows[3]).node).toBe(file1); - expect(( rows[4]).node).toBe(file6); - expect(( rows[5]).node).toBe(file5); + expect((rows[0]).node).toBe(file3); + expect((rows[1]).node).toBe(file4); + expect((rows[2]).node).toBe(file2); + expect((rows[3]).node).toBe(file1); + expect((rows[4]).node).toBe(file6); + expect((rows[5]).node).toBe(file5); }); describe('ShareDataRow', () => { @@ -440,9 +436,7 @@ describe('ShareDataTableAdapter', () => { }); it('should require object source', () => { - expect(() => { - return new ShareDataRow(null, contentService, null); - }).toThrowError(ShareDataRow.ERR_OBJECT_NOT_FOUND); + expect(() => new ShareDataRow(null, contentService, null)).toThrowError(ERR_OBJECT_NOT_FOUND); }); it('should resolve value from node entry', () => { diff --git a/lib/content-services/src/lib/document-list/data/share-datatable-adapter.ts b/lib/content-services/src/lib/document-list/data/share-datatable-adapter.ts index 9c6e880b9a7..0b14b22cd72 100644 --- a/lib/content-services/src/lib/document-list/data/share-datatable-adapter.ts +++ b/lib/content-services/src/lib/document-list/data/share-datatable-adapter.ts @@ -28,11 +28,10 @@ import { PermissionStyleModel } from './../models/permissions-style.model'; import { ShareDataRow } from './share-data-row.model'; import { RowFilter } from './row-filter.model'; -export class ShareDataTableAdapter implements DataTableAdapter { - - ERR_ROW_NOT_FOUND: string = 'Row not found'; - ERR_COL_NOT_FOUND: string = 'Column not found'; +export const ERR_ROW_NOT_FOUND: string = 'Row not found'; +export const ERR_COL_NOT_FOUND: string = 'Column not found'; +export class ShareDataTableAdapter implements DataTableAdapter { private _sortingMode: string; private sorting: DataSorting; private rows: DataRow[]; @@ -91,12 +90,12 @@ export class ShareDataTableAdapter implements DataTableAdapter { getValue(row: DataRow, col: DataColumn): any { if (!row) { - throw new Error(this.ERR_ROW_NOT_FOUND); + throw new Error(ERR_ROW_NOT_FOUND); } if (!col) { - throw new Error(this.ERR_COL_NOT_FOUND); + throw new Error(ERR_COL_NOT_FOUND); } - const dataRow: ShareDataRow = row; + const dataRow = row as ShareDataRow; const value: any = row.getValue(col.key); if (dataRow.cache[col.key] !== undefined) { return dataRow.cache[col.key]; @@ -111,7 +110,7 @@ export class ShareDataTableAdapter implements DataTableAdapter { } } - const node = ( row).node; + const node = row.node; if (node.entry.isFolder) { return this.getFolderIcon(node); @@ -280,9 +279,7 @@ export class ShareDataTableAdapter implements DataTableAdapter { if (merge) { const listPrunedDuplicate = shareDataRows.filter((elementToFilter: any) => { - const isPresent = this.rows.find((currentRow: any) => { - return currentRow.obj.entry.id === elementToFilter.obj.entry.id; - }); + const isPresent = this.rows.find((currentRow: any) => currentRow.obj.entry.id === elementToFilter.obj.entry.id); return !isPresent; }); diff --git a/lib/content-services/src/lib/document-list/models/content-action.model.ts b/lib/content-services/src/lib/document-list/models/content-action.model.ts index 5b28b35a657..bb593351166 100644 --- a/lib/content-services/src/lib/document-list/models/content-action.model.ts +++ b/lib/content-services/src/lib/document-list/models/content-action.model.ts @@ -15,6 +15,9 @@ * limitations under the License. */ +/* eslint-disable no-shadow */ +/* eslint-disable @typescript-eslint/naming-convention */ + export class ContentActionModel { icon: string; title: string; diff --git a/lib/content-services/src/lib/document-list/models/node-action.enum.ts b/lib/content-services/src/lib/document-list/models/node-action.enum.ts index c426a4b9029..25f7aacd110 100644 --- a/lib/content-services/src/lib/document-list/models/node-action.enum.ts +++ b/lib/content-services/src/lib/document-list/models/node-action.enum.ts @@ -15,6 +15,9 @@ * limitations under the License. */ +/* eslint-disable no-shadow */ +/* eslint-disable @typescript-eslint/naming-convention */ + export enum NodeAction { ATTACH = 'ATTACH', CHOOSE = 'CHOOSE', diff --git a/lib/content-services/src/lib/document-list/models/preset.model.ts b/lib/content-services/src/lib/document-list/models/preset.model.ts index 38bab3cc590..83780822bff 100644 --- a/lib/content-services/src/lib/document-list/models/preset.model.ts +++ b/lib/content-services/src/lib/document-list/models/preset.model.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let presetsDefaultModel = { +export const presetsDefaultModel = { '-trashcan-': [ { key: '$thumbnail', @@ -220,7 +220,7 @@ export let presetsDefaultModel = { sortable: true } ], - 'default': [ + default: [ { key: '$thumbnail', type: 'image', diff --git a/lib/content-services/src/lib/document-list/services/custom-resources.service.ts b/lib/content-services/src/lib/document-list/services/custom-resources.service.ts index 451969e3077..8f3ca415ec7 100644 --- a/lib/content-services/src/lib/document-list/services/custom-resources.service.ts +++ b/lib/content-services/src/lib/document-list/services/custom-resources.service.ts @@ -36,48 +36,48 @@ import { Injectable } from '@angular/core'; import { Observable, from, of, throwError } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; +const CREATE_PERMISSION: string = 'create'; + @Injectable({ providedIn: 'root' }) export class CustomResourcesService { - private CREATE_PERMISSION = 'create'; - - _peopleApi: PeopleApi; + private _peopleApi: PeopleApi; get peopleApi(): PeopleApi { this._peopleApi = this._peopleApi ?? new PeopleApi(this.apiService.getInstance()); return this._peopleApi; } - _sitesApi: SitesApi; + private _sitesApi: SitesApi; get sitesApi(): SitesApi { this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance()); return this._sitesApi; } - _trashcanApi: TrashcanApi; + private _trashcanApi: TrashcanApi; get trashcanApi(): TrashcanApi { this._trashcanApi = this._trashcanApi ?? new TrashcanApi(this.apiService.getInstance()); return this._trashcanApi; } - _searchApi: SearchApi; + private _searchApi: SearchApi; get searchApi(): SearchApi { this._searchApi = this._searchApi ?? new SearchApi(this.apiService.getInstance()); return this._searchApi; } - _sharedLinksApi: SharedlinksApi; + private _sharedLinksApi: SharedlinksApi; get sharedLinksApi(): SharedlinksApi { this._sharedLinksApi = this._sharedLinksApi ?? new SharedlinksApi(this.apiService.getInstance()); return this._sharedLinksApi; } - _favoritesApi: FavoritesApi; + private _favoritesApi: FavoritesApi; get favoritesApi(): FavoritesApi { this._favoritesApi = this._favoritesApi ?? new FavoritesApi(this.apiService.getInstance()); return this._favoritesApi; } - _nodesApi: NodesApi; + private _nodesApi: NodesApi; get nodesApi(): NodesApi { this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance()); return this._nodesApi; @@ -88,6 +88,7 @@ export class CustomResourcesService { /** * Gets files recently accessed by a user. + * * @param personId ID of the user * @param pagination Specifies how to paginate the results * @param filters Specifies additional filters to apply (joined with **AND**) @@ -169,6 +170,7 @@ export class CustomResourcesService { /** * Gets favorite files for the current user. + * * @param pagination Specifies how to paginate the results * @param includeFields List of data field names to include in the results * @param where A string to restrict the returned objects by using a predicate @@ -221,6 +223,7 @@ export class CustomResourcesService { /** * Gets sites that the current user is a member of. + * * @param pagination Specifies how to paginate the results * @param where A string to restrict the returned objects by using a predicate * @returns List of sites @@ -240,7 +243,7 @@ export class CustomResourcesService { list: { entries: result.list.entries .map(({ entry: { site } }: any) => { - site.allowableOperations = site.allowableOperations ? site.allowableOperations : [this.CREATE_PERMISSION]; + site.allowableOperations = site.allowableOperations ? site.allowableOperations : [CREATE_PERMISSION]; site.name = site.name || site.title; return { entry: site @@ -262,6 +265,7 @@ export class CustomResourcesService { /** * Gets all sites in the repository. + * * @param pagination Specifies how to paginate the results * @param where A string to restrict the returned objects by using a predicate * @returns List of sites @@ -297,6 +301,7 @@ export class CustomResourcesService { /** * Gets all items currently in the trash. + * * @param pagination Specifies how to paginate the results * @param includeFields List of data field names to include in the results * @returns List of deleted items @@ -317,6 +322,7 @@ export class CustomResourcesService { /** * Gets shared links for the current user. + * * @param pagination Specifies how to paginate the results * @param includeFields List of data field names to include in the results * @param where A string to restrict the returned objects by using a predicate @@ -338,6 +344,7 @@ export class CustomResourcesService { /** * Is the folder ID one of the well-known aliases? + * * @param folderId Folder ID name to check * @returns True if the ID is a well-known name, false otherwise */ @@ -354,6 +361,7 @@ export class CustomResourcesService { /** * Is the folder ID a "-my", "-root-", or "-shared-" alias? + * * @param folderId Folder ID name to check * @returns True if the ID is one of the supported sources, false otherwise */ @@ -370,6 +378,7 @@ export class CustomResourcesService { /** * Gets a folder's contents. + * * @param nodeId ID of the target folder node * @param pagination Specifies how to paginate the results * @param includeFields List of data field names to include in the results @@ -396,6 +405,7 @@ export class CustomResourcesService { /** * Gets the contents of one of the well-known aliases in the form of node ID strings. + * * @param nodeId ID of the target folder node * @param pagination Specifies how to paginate the results * @returns List of node IDs @@ -404,9 +414,7 @@ export class CustomResourcesService { if (this.isCustomSource(nodeId)) { return this.loadFolderByNodeId(nodeId, pagination) - .pipe(map((result: any): string[] => { - return result.list.entries.map((node: any): string => this.getIdFromEntry(node, nodeId)); - })); + .pipe(map((result: any): string[] => result.list.entries.map((node: any): string => this.getIdFromEntry(node, nodeId)))); } else if (nodeId) { // cases when nodeId is '-my-', '-root-' or '-shared-' @@ -419,6 +427,7 @@ export class CustomResourcesService { /** * Chooses the correct ID for a node entry. + * * @param node Node object * @param nodeId ID of the node object * @returns ID value @@ -437,6 +446,7 @@ export class CustomResourcesService { /** * Does the well-known alias have a corresponding node ID? + * * @param nodeId Node to check * @returns True if the alias has a corresponding node ID, false otherwise */ diff --git a/lib/content-services/src/lib/document-list/services/document-actions.service.spec.ts b/lib/content-services/src/lib/document-list/services/document-actions.service.spec.ts index 20cd687c912..1ead6fa4e3f 100644 --- a/lib/content-services/src/lib/document-list/services/document-actions.service.spec.ts +++ b/lib/content-services/src/lib/document-list/services/document-actions.service.spec.ts @@ -51,8 +51,7 @@ describe('DocumentActionsService', () => { }); it('should register custom action handler', () => { - const handler: ContentActionHandler = function () { - }; + const handler: ContentActionHandler = () => {}; service.setHandler('', handler); expect(service.getHandler('')).toBe(handler); }); @@ -62,8 +61,7 @@ describe('DocumentActionsService', () => { }); it('should be case insensitive for keys', () => { - const handler: ContentActionHandler = function () { - }; + const handler: ContentActionHandler = () => {}; service.setHandler('', handler); expect(service.getHandler('')).toBe(handler); }); @@ -88,8 +86,7 @@ describe('DocumentActionsService', () => { }); it('should set new handler only by key', () => { - const handler: ContentActionHandler = function () { - }; + const handler: ContentActionHandler = () => {}; expect(service.setHandler(null, handler)).toBeFalsy(); expect(service.setHandler('', handler)).toBeFalsy(); expect(service.setHandler('my-handler', handler)).toBeTruthy(); diff --git a/lib/content-services/src/lib/document-list/services/document-actions.service.ts b/lib/content-services/src/lib/document-list/services/document-actions.service.ts index e917ee3fb77..6b38abf966c 100644 --- a/lib/content-services/src/lib/document-list/services/document-actions.service.ts +++ b/lib/content-services/src/lib/document-list/services/document-actions.service.ts @@ -46,6 +46,7 @@ export class DocumentActionsService { /** * Gets the handler for an action. + * * @param key Identifier of the action * @returns The handler for the action */ @@ -59,6 +60,7 @@ export class DocumentActionsService { /** * Sets a new handler for an action. + * * @param key Identifier of the action * @param handler Handler for the action * @returns False if the key was an empty/null string, true otherwise @@ -74,6 +76,7 @@ export class DocumentActionsService { /** * Checks if actions can be executed for an item. + * * @param nodeEntry Item to receive an action * @returns True if the action can be executed on this item, false otherwise */ @@ -134,7 +137,7 @@ export class DocumentActionsService { this.permissionEvent.next(new PermissionModel({ type: 'content', action: 'delete', - permission: permission + permission })); return throwError(new Error('No permission to delete')); } diff --git a/lib/content-services/src/lib/document-list/services/document-list.service.spec.ts b/lib/content-services/src/lib/document-list/services/document-list.service.spec.ts index 35daf7ed11d..1a15b90abb3 100644 --- a/lib/content-services/src/lib/document-list/services/document-list.service.spec.ts +++ b/lib/content-services/src/lib/document-list/services/document-list.service.spec.ts @@ -28,34 +28,34 @@ describe('DocumentListService', () => { let service: DocumentListService; const fakeFolder = { - 'list': { - 'pagination': { 'count': 1, 'hasMoreItems': false, 'totalItems': 1, 'skipCount': 0, 'maxItems': 20 }, - 'entries': [{ - 'entry': { - 'createdAt': '2016-12-06T13:03:14.880+0000', - 'path': { - 'name': '/Company Home/Sites/swsdp/documentLibrary/empty', - 'isComplete': true, - 'elements': [{ - 'id': 'ed7ab80e-b398-4bed-b38d-139ae4cc592a', - 'name': 'Company Home' - }, { 'id': '99e1368f-e816-47fc-a8bf-3b358feaf31e', 'name': 'Sites' }, { - 'id': 'b4cff62a-664d-4d45-9302-98723eac1319', - 'name': 'swsdp' + list: { + pagination: { count: 1, hasMoreItems: false, totalItems: 1, skipCount: 0, maxItems: 20 }, + entries: [{ + entry: { + createdAt: '2016-12-06T13:03:14.880+0000', + path: { + name: '/Company Home/Sites/swsdp/documentLibrary/empty', + isComplete: true, + elements: [{ + id: 'ed7ab80e-b398-4bed-b38d-139ae4cc592a', + name: 'Company Home' + }, { id: '99e1368f-e816-47fc-a8bf-3b358feaf31e', name: 'Sites' }, { + id: 'b4cff62a-664d-4d45-9302-98723eac1319', + name: 'swsdp' }, { - 'id': '8f2105b4-daaf-4874-9e8a-2152569d109b', - 'name': 'documentLibrary' - }, { 'id': '17fa78d2-4d6b-4a46-876b-4b0ea07f7f32', 'name': 'empty' }] + id: '8f2105b4-daaf-4874-9e8a-2152569d109b', + name: 'documentLibrary' + }, { id: '17fa78d2-4d6b-4a46-876b-4b0ea07f7f32', name: 'empty' }] }, - 'isFolder': true, - 'isFile': false, - 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'modifiedAt': '2016-12-06T13:03:14.880+0000', - 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'name': 'fake-name', - 'id': 'aac546f6-1525-46ff-bf6b-51cb85f3cda7', - 'nodeType': 'cm:folder', - 'parentId': '17fa78d2-4d6b-4a46-876b-4b0ea07f7f32' + isFolder: true, + isFile: false, + createdByUser: { id: 'admin', displayName: 'Administrator' }, + modifiedAt: '2016-12-06T13:03:14.880+0000', + modifiedByUser: { id: 'admin', displayName: 'Administrator' }, + name: 'fake-name', + id: 'aac546f6-1525-46ff-bf6b-51cb85f3cda7', + nodeType: 'cm:folder', + parentId: '17fa78d2-4d6b-4a46-876b-4b0ea07f7f32' } }] } diff --git a/lib/content-services/src/lib/document-list/services/document-list.service.ts b/lib/content-services/src/lib/document-list/services/document-list.service.ts index 2e1f9ba7f1c..28ac5503a50 100644 --- a/lib/content-services/src/lib/document-list/services/document-list.service.ts +++ b/lib/content-services/src/lib/document-list/services/document-list.service.ts @@ -27,14 +27,14 @@ import { catchError, map } from 'rxjs/operators'; import { DocumentListLoader } from '../interfaces/document-list-loader.interface'; import { CustomResourcesService } from './custom-resources.service'; +const ROOT_ID = '-root-'; + @Injectable({ providedIn: 'root' }) export class DocumentListService implements DocumentListLoader { - static ROOT_ID = '-root-'; - - _nodesApi: NodesApi; + private _nodesApi: NodesApi; get nodes(): NodesApi { this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance()); return this._nodesApi; @@ -48,6 +48,7 @@ export class DocumentListService implements DocumentListLoader { /** * Deletes a node. + * * @param nodeId ID of the node to delete * @returns Empty response when the operation is complete */ @@ -83,13 +84,14 @@ export class DocumentListService implements DocumentListLoader { /** * Gets the folder node with the specified relative name path below the root node. + * * @param folder Path to folder. * @param opts Options. * @param includeFields Extra information to include (available options are "aspectNames", "isLink" and "association") * @returns Details of the folder */ getFolder(folder: string, opts?: any, includeFields: string[] = []): Observable { - let rootNodeId = DocumentListService.ROOT_ID; + let rootNodeId = ROOT_ID; if (opts && opts.rootFolderId) { rootNodeId = opts.rootFolderId; } @@ -128,6 +130,7 @@ export class DocumentListService implements DocumentListLoader { /** * Gets a node via its node ID. + * * @param nodeId ID of the target node * @param includeFields Extra information to include (available options are "aspectNames", "isLink" and "association") * @returns Details of the folder @@ -146,6 +149,7 @@ export class DocumentListService implements DocumentListLoader { /** * Gets a folder node via its node ID. + * * @param nodeId ID of the folder node * @param includeFields Extra information to include (available options are "aspectNames", "isLink" and "association") * @returns Details of the folder @@ -170,6 +174,7 @@ export class DocumentListService implements DocumentListLoader { /** * Load a folder by Node Id. + * * @param nodeId ID of the folder node * @param pagination * @param includeFields List of data field names to include in the results @@ -193,9 +198,9 @@ export class DocumentListService implements DocumentListLoader { this.getFolder(null, { maxItems: pagination.maxItems, skipCount: pagination.skipCount, - orderBy: orderBy, + orderBy, rootFolderId: nodeId, - where: where + where }, includeFields)]).pipe( map((results) => new DocumentLoaderNode(results[0], results[1])) ); diff --git a/lib/content-services/src/lib/document-list/services/folder-actions.service.spec.ts b/lib/content-services/src/lib/document-list/services/folder-actions.service.spec.ts index 46ea4daaacc..4a02ce48cc2 100644 --- a/lib/content-services/src/lib/document-list/services/folder-actions.service.spec.ts +++ b/lib/content-services/src/lib/document-list/services/folder-actions.service.spec.ts @@ -46,8 +46,7 @@ describe('FolderActionsService', () => { }); it('should register custom action handler', () => { - const handler: ContentActionHandler = function () { - }; + const handler: ContentActionHandler = () => {}; service.setHandler('', handler); expect(service.getHandler('')).toBe(handler); }); @@ -57,8 +56,7 @@ describe('FolderActionsService', () => { }); it('should be case insensitive for keys', () => { - const handler: ContentActionHandler = function () { - }; + const handler: ContentActionHandler = () => {}; service.setHandler('', handler); expect(service.getHandler('')).toBe(handler); }); @@ -80,8 +78,7 @@ describe('FolderActionsService', () => { }); it('should set new handler only by key', () => { - const handler: ContentActionHandler = function () { - }; + const handler: ContentActionHandler = () => {}; expect(service.setHandler(null, handler)).toBeFalsy(); expect(service.setHandler('', handler)).toBeFalsy(); expect(service.setHandler('my-handler', handler)).toBeTruthy(); @@ -106,12 +103,10 @@ describe('FolderActionsService', () => { }); it('should delete the folder node if there is the delete permission', () => { - spyOn(documentListService, 'deleteNode').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); const permission = 'delete'; const folder = new FolderNode(); @@ -124,12 +119,10 @@ describe('FolderActionsService', () => { }); it('should not delete the folder node if there is no delete permission', (done) => { - spyOn(documentListService, 'deleteNode').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); service.permissionEvent.subscribe((permission) => { expect(permission).toBeDefined(); @@ -145,12 +138,10 @@ describe('FolderActionsService', () => { }); it('should call the error on the returned Observable if there is no delete permission', (done) => { - spyOn(documentListService, 'deleteNode').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); const folder = new FolderNode(); const folderWithPermission: any = folder; @@ -166,12 +157,10 @@ describe('FolderActionsService', () => { }); it('should delete the folder node if there is the delete and others permission ', () => { - spyOn(documentListService, 'deleteNode').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); const permission = 'delete'; const folder = new FolderNode(); @@ -183,12 +172,10 @@ describe('FolderActionsService', () => { }); it('should support deletion only folder node', () => { - spyOn(documentListService, 'deleteNode').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); const permission = 'delete'; const file = new FileNode(); @@ -203,12 +190,10 @@ describe('FolderActionsService', () => { }); it('should require node id to delete', () => { - spyOn(documentListService, 'deleteNode').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); const folder = new FolderNode(); folder.entry.id = null; @@ -218,12 +203,10 @@ describe('FolderActionsService', () => { }); it('should reload target upon node deletion', (done) => { - spyOn(documentListService, 'deleteNode').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); const permission = 'delete'; const target = jasmine.createSpyObj('obj', ['reload']); @@ -242,12 +225,10 @@ describe('FolderActionsService', () => { }); it('should emit success event upon node deletion', (done) => { - spyOn(documentListService, 'deleteNode').and.callFake(() => { - return new Observable((observer) => { - observer.next(); - observer.complete(); - }); - }); + spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable((observer) => { + observer.next(); + observer.complete(); + })); service.success.subscribe((nodeId) => { expect(nodeId).not.toBeNull(); diff --git a/lib/content-services/src/lib/document-list/services/folder-actions.service.ts b/lib/content-services/src/lib/document-list/services/folder-actions.service.ts index 6bd5c2f59ef..b87c475b852 100644 --- a/lib/content-services/src/lib/document-list/services/folder-actions.service.ts +++ b/lib/content-services/src/lib/document-list/services/folder-actions.service.ts @@ -44,6 +44,7 @@ export class FolderActionsService { /** * Gets the handler function for an action. + * * @param key Identifier for the action * @returns The handler function */ @@ -57,6 +58,7 @@ export class FolderActionsService { /** * Sets a new handler function for an action. + * * @param key Identifier for the action * @param handler The new handler function * @returns True if the key was a valid action identifier, false otherwise @@ -72,6 +74,7 @@ export class FolderActionsService { /** * Checks if an action is available for a particular item. + * * @param nodeEntry Item to check * @returns True if the action is available, false otherwise */ @@ -132,7 +135,7 @@ export class FolderActionsService { return handlerObservable; } else { - this.permissionEvent.next(new PermissionModel({type: 'folder', action: 'delete', permission: permission})); + this.permissionEvent.next(new PermissionModel({type: 'folder', action: 'delete', permission})); return throwError(new Error('No permission to delete')); } } diff --git a/lib/content-services/src/lib/document-list/services/node-actions.service.spec.ts b/lib/content-services/src/lib/document-list/services/node-actions.service.spec.ts index 711dceda8a4..e5b4fb650ad 100644 --- a/lib/content-services/src/lib/document-list/services/node-actions.service.spec.ts +++ b/lib/content-services/src/lib/document-list/services/node-actions.service.spec.ts @@ -26,9 +26,9 @@ import { MatDialogRef } from '@angular/material/dialog'; import { ContentTestingModule } from '../../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; -const fakeNode: Node = { +const fakeNode: Node = { id: 'fake' -}; +} as Node; describe('NodeActionsService', () => { diff --git a/lib/content-services/src/lib/folder-directive/folder-create.directive.spec.ts b/lib/content-services/src/lib/folder-directive/folder-create.directive.spec.ts index daafa113ef4..649632e6aa1 100644 --- a/lib/content-services/src/lib/folder-directive/folder-create.directive.spec.ts +++ b/lib/content-services/src/lib/folder-directive/folder-create.directive.spec.ts @@ -113,7 +113,7 @@ describe('FolderCreateDirective', () => { }); it('should emit success event with node if the folder creation was successful', async () => { - const testNode = {}; + const testNode = {}; element.triggerEventHandler('click', event); dialogRefMock.componentInstance.success.next(testNode); diff --git a/lib/content-services/src/lib/folder-directive/folder-create.directive.ts b/lib/content-services/src/lib/folder-directive/folder-create.directive.ts index 48cd1a499aa..7b77453e710 100644 --- a/lib/content-services/src/lib/folder-directive/folder-create.directive.ts +++ b/lib/content-services/src/lib/folder-directive/folder-create.directive.ts @@ -24,13 +24,12 @@ import { FolderDialogComponent } from '../dialogs/folder.dialog'; import { ContentService } from '@alfresco/adf-core'; const DEFAULT_FOLDER_PARENT_ID = '-my-'; +const DIALOG_WIDTH: number = 400; @Directive({ selector: '[adf-create-folder]' }) export class FolderCreateDirective { - static DIALOG_WIDTH: number = 400; - /** Parent folder where the new folder will be located after creation. */ @Input('adf-create-folder') parentNodeId: string = DEFAULT_FOLDER_PARENT_ID; @@ -63,12 +62,11 @@ export class FolderCreateDirective { ) {} private get dialogConfig() { - const { DIALOG_WIDTH: width } = FolderCreateDirective; const { parentNodeId, title: createTitle, nodeType } = this; return { data: { parentNodeId, createTitle, nodeType }, - width: `${width}px` + width: `${DIALOG_WIDTH}px` }; } diff --git a/lib/content-services/src/lib/folder-directive/folder-edit.directive.spec.ts b/lib/content-services/src/lib/folder-directive/folder-edit.directive.spec.ts index f736b499043..dc62de33451 100644 --- a/lib/content-services/src/lib/folder-directive/folder-edit.directive.spec.ts +++ b/lib/content-services/src/lib/folder-directive/folder-edit.directive.spec.ts @@ -93,7 +93,7 @@ describe('FolderEditDirective', () => { it('should emit success event with node if the folder creation was successful', async () => { fixture.detectChanges(); - const testNode = {}; + const testNode: any = {}; element.triggerEventHandler('click', event); dialogRefMock.componentInstance.success.next(testNode); diff --git a/lib/content-services/src/lib/folder-directive/folder-edit.directive.ts b/lib/content-services/src/lib/folder-directive/folder-edit.directive.ts index 0073d18ffc8..bddd5e68a62 100644 --- a/lib/content-services/src/lib/folder-directive/folder-edit.directive.ts +++ b/lib/content-services/src/lib/folder-directive/folder-edit.directive.ts @@ -19,25 +19,23 @@ import { Directive, ElementRef, HostListener, Input, Output, EventEmitter } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; - import { Node } from '@alfresco/js-api'; - import { FolderDialogComponent } from '../dialogs/folder.dialog'; import { ContentService } from '@alfresco/adf-core'; +const DIALOG_WIDTH: number = 400; + @Directive({ selector: '[adf-edit-folder]' }) export class FolderEditDirective { - static DIALOG_WIDTH: number = 400; - /** Folder node to edit. */ @Input('adf-edit-folder') folder: Node; /** Emitted when an error occurs (eg, a folder with same name already exists). */ @Output() - error: EventEmitter = new EventEmitter(); + error = new EventEmitter(); /** Title of folder edit dialog. */ @Input() @@ -45,7 +43,7 @@ export class FolderEditDirective { /** Emitted when the folder has been edited successfully. */ @Output() - success: EventEmitter = new EventEmitter(); + success = new EventEmitter(); @HostListener('click', [ '$event' ]) onClick(event) { @@ -62,7 +60,6 @@ export class FolderEditDirective { ) {} private get dialogConfig() { - const { DIALOG_WIDTH: width } = FolderEditDirective; const { folder } = this; return { @@ -70,7 +67,7 @@ export class FolderEditDirective { folder, editTitle: this.title }, - width: `${width}px` + width: `${DIALOG_WIDTH}px` }; } diff --git a/lib/content-services/src/lib/mock/add-permission.component.mock.ts b/lib/content-services/src/lib/mock/add-permission.component.mock.ts index 62deeb9b5dc..ddbeaa6cd67 100644 --- a/lib/content-services/src/lib/mock/add-permission.component.mock.ts +++ b/lib/content-services/src/lib/mock/add-permission.component.mock.ts @@ -18,48 +18,48 @@ /* spellchecker: disable */ export const fakeAuthorityResults: any[] = [{ - 'entry': { - 'aspectNames': [ + entry: { + aspectNames: [ 'cm:personDisabled', 'cm:ownable', 'cm:preferences' ], - 'isFolder': false, - 'search': { - 'score': 4.014668 + isFolder: false, + search: { + score: 4.014668 }, - 'isFile': false, - 'name': 'dc103838-645f-43c1-8a2a-bc187e13c343', - 'location': 'nodes', - 'id': 'dc103838-645f-43c1-8a2a-bc187e13c343', - 'nodeType': 'cm:person', - 'properties': { + isFile: false, + name: 'dc103838-645f-43c1-8a2a-bc187e13c343', + location: 'nodes', + id: 'dc103838-645f-43c1-8a2a-bc187e13c343', + nodeType: 'cm:person', + properties: { 'cm:location': 'Tilbury, UK', 'cm:persondescription': { - 'contentUrl': 'store://2018/4/18/9/30/514bb261-bc61-4502-ad2f-dfafec9ae4eb.bin', - 'mimetype': 'application/octet-stream', - 'size': 55, - 'encoding': 'UTF-8', - 'locale': 'en_US', - 'id': 148, - 'infoUrl': 'contentUrl=store://2018/4/18/9/30/514bb261-bc61-4502-ad2f-dfafec9ae4eb.bin|mimetype=application/octet-stream|size=55|encoding=UTF-8|locale=en_US_' + contentUrl: 'store://2018/4/18/9/30/514bb261-bc61-4502-ad2f-dfafec9ae4eb.bin', + mimetype: 'application/octet-stream', + size: 55, + encoding: 'UTF-8', + locale: 'en_US', + id: 148, + infoUrl: 'contentUrl=store://2018/4/18/9/30/514bb261-bc61-4502-ad2f-dfafec9ae4eb.bin|mimetype=application/octet-stream|size=55|encoding=UTF-8|locale=en_US_' }, 'cm:owner': { - 'id': 'abeecher', - 'displayName': 'Alice Beecher' + id: 'abeecher', + displayName: 'Alice Beecher' }, 'cm:companyaddress2': 'Tilbury', 'cm:userStatus': 'Helping to design the look and feel of the new web site', 'cm:companyaddress1': '200 Butterwick Street', 'cm:telephone': '0112211001100', 'cm:preferenceValues': { - 'contentUrl': 'store://2018/4/18/9/30/afc39bc9-6bac-4f24-8730-9d9f617a322e.bin', - 'mimetype': 'text/plain', - 'size': 709, - 'encoding': 'UTF-8', - 'locale': 'en_US', - 'id': 147, - 'infoUrl': 'contentUrl=store://2018/4/18/9/30/afc39bc9-6bac-4f24-8730-9d9f617a322e.bin|mimetype=text/plain|size=709|encoding=UTF-8|locale=en_US_' + contentUrl: 'store://2018/4/18/9/30/afc39bc9-6bac-4f24-8730-9d9f617a322e.bin', + mimetype: 'text/plain', + size: 709, + encoding: 'UTF-8', + locale: 'en_US', + id: 147, + infoUrl: 'contentUrl=store://2018/4/18/9/30/afc39bc9-6bac-4f24-8730-9d9f617a322e.bin|mimetype=text/plain|size=709|encoding=UTF-8|locale=en_US_' }, 'cm:userName': 'abeecher', 'cm:companyaddress3': 'UK', @@ -79,34 +79,34 @@ export const fakeAuthorityResults: any[] = [{ 'cm:organization': 'Moresby, Garland and Wedge', 'cm:companypostcode': 'ALF1 SAM1' }, - 'parentId': '063f5d48-a0b3-4cbf-826c-88a4fbfa3336' + parentId: '063f5d48-a0b3-4cbf-826c-88a4fbfa3336' } }, { - 'entry': { - 'aspectNames': [ + entry: { + aspectNames: [ 'cm:ownable', 'cm:preferences' ], - 'isFolder': false, - 'search': { - 'score': 4.014668 + isFolder: false, + search: { + score: 4.014668 }, - 'isFile': false, - 'name': 'e320c16b-a763-4a4e-9f22-286ff5d8dca2', - 'location': 'nodes', - 'id': 'e320c16b-a763-4a4e-9f22-286ff5d8dca2', - 'nodeType': 'cm:person', - 'properties': { + isFile: false, + name: 'e320c16b-a763-4a4e-9f22-286ff5d8dca2', + location: 'nodes', + id: 'e320c16b-a763-4a4e-9f22-286ff5d8dca2', + nodeType: 'cm:person', + properties: { 'cm:homeFolderProvider': 'bootstrapHomeFolderProvider', 'cm:preferenceValues': { - 'contentUrl': 'store://2018/4/23/14/42/92bb4aa9-db27-41a4-9804-ddab3cc83d3e.bin', - 'mimetype': 'text/plain', - 'size': 102, - 'encoding': 'UTF-8', - 'locale': 'en', - 'id': 313, - 'infoUrl': 'contentUrl=store://2018/4/23/14/42/92bb4aa9-db27-41a4-9804-ddab3cc83d3e.bin|mimetype=text/plain|size=102|encoding=UTF-8|locale=en_' + contentUrl: 'store://2018/4/23/14/42/92bb4aa9-db27-41a4-9804-ddab3cc83d3e.bin', + mimetype: 'text/plain', + size: 102, + encoding: 'UTF-8', + locale: 'en', + id: 313, + infoUrl: 'contentUrl=store://2018/4/23/14/42/92bb4aa9-db27-41a4-9804-ddab3cc83d3e.bin|mimetype=text/plain|size=102|encoding=UTF-8|locale=en_' }, 'cm:authorizationStatus': 'AUTHORIZED', 'cm:homeFolder': 'a20cd541-4ada-4525-9807-9fa0a047d9f4', @@ -115,72 +115,72 @@ export const fakeAuthorityResults: any[] = [{ 'cm:email': 'admin@alfresco.com', 'cm:firstName': 'Administrator', 'cm:owner': { - 'id': 'admin', - 'displayName': 'Administrator' + id: 'admin', + displayName: 'Administrator' } }, - 'parentId': '063f5d48-a0b3-4cbf-826c-88a4fbfa3336' + parentId: '063f5d48-a0b3-4cbf-826c-88a4fbfa3336' } }, { - 'entry': { - 'isFolder': false, - 'search': { - 'score': 0.3541112 + entry: { + isFolder: false, + search: { + score: 0.3541112 }, - 'isFile': false, - 'name': 'GROUP_ALFRESCO_ADMINISTRATORS', - 'location': 'nodes', - 'id': 'GROUP_ALFRESCO_ADMINISTRATORS', - 'nodeType': 'cm:authorityContainer', - 'properties': { + isFile: false, + name: 'GROUP_ALFRESCO_ADMINISTRATORS', + location: 'nodes', + id: 'GROUP_ALFRESCO_ADMINISTRATORS', + nodeType: 'cm:authorityContainer', + properties: { 'cm:authorityName': 'GROUP_ALFRESCO_ADMINISTRATORS' }, - 'parentId': '030d833e-da8e-4f5c-8ef9-d809638bd04b' + parentId: '030d833e-da8e-4f5c-8ef9-d809638bd04b' } }]; export const fakeAuthorityListResult: any = { - 'list': { - 'pagination': { - 'count': 0, - 'hasMoreItems': false, - 'totalItems': 0, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 0, + hasMoreItems: false, + totalItems: 0, + skipCount: 0, + maxItems: 100 }, - 'context': {}, - 'entries': fakeAuthorityResults + context: {}, + entries: fakeAuthorityResults } }; export const fakeNameListResult: any = { - 'list': { - 'pagination': { - 'count': 2, - 'hasMoreItems': false, - 'totalItems': 2, - 'skipCount': 0, - 'maxItems': 20 + list: { + pagination: { + count: 2, + hasMoreItems: false, + totalItems: 2, + skipCount: 0, + maxItems: 20 }, - 'context': { - 'consistency': { - 'lastTxId': 5496 + context: { + consistency: { + lastTxId: 5496 } }, - 'entries': [{ - 'entry': { - 'aspectNames': ['cm:ownable'], - 'isFolder': false, - 'search': { - 'score': 1.0 + entries: [{ + entry: { + aspectNames: ['cm:ownable'], + isFolder: false, + search: { + score: 1.0 }, - 'isFile': false, - 'name': '730cd9b0-5617-4865-aee8-90de1d596997', - 'location': 'nodes', - 'id': '730cd9b0-5617-4865-aee8-90de1d596997', - 'nodeType': 'cm:person', - 'properties': { + isFile: false, + name: '730cd9b0-5617-4865-aee8-90de1d596997', + location: 'nodes', + id: '730cd9b0-5617-4865-aee8-90de1d596997', + nodeType: 'cm:person', + properties: { 'cm:homeFolderProvider': 'userHomesHomeFolderProvider', 'cm:authorizationStatus': 'NEVER_AUTHORIZED', 'cm:homeFolder': '277f505d-6526-45b1-a7b3-c9bdd66f17f6', @@ -191,25 +191,25 @@ export const fakeNameListResult: any = { 'cm:sizeQuota': 1073741824, 'cm:firstName': 'firstName', 'cm:owner': { - 'id': 'test1', - 'displayName': 'firstName lastName1' + id: 'test1', + displayName: 'firstName lastName1' } }, - 'parentId': '3e9ce910-a4a0-4531-8f80-7734bece6342' + parentId: '3e9ce910-a4a0-4531-8f80-7734bece6342' } }, { - 'entry': { - 'aspectNames': ['cm:ownable'], - 'isFolder': false, - 'search': { - 'score': 1.0 + entry: { + aspectNames: ['cm:ownable'], + isFolder: false, + search: { + score: 1.0 }, - 'isFile': false, - 'name': '3d1e9e57-505f-431e-bb2b-38ad8d5d2d15', - 'location': 'nodes', - 'id': '3d1e9e57-505f-431e-bb2b-38ad8d5d2d15', - 'nodeType': 'cm:person', - 'properties': { + isFile: false, + name: '3d1e9e57-505f-431e-bb2b-38ad8d5d2d15', + location: 'nodes', + id: '3d1e9e57-505f-431e-bb2b-38ad8d5d2d15', + nodeType: 'cm:person', + properties: { 'cm:homeFolderProvider': 'userHomesHomeFolderProvider', 'cm:authorizationStatus': 'NEVER_AUTHORIZED', 'cm:homeFolder': '81a07ff0-82fb-4bbb-b869-d5fd92e71e17', @@ -220,11 +220,11 @@ export const fakeNameListResult: any = { 'cm:sizeQuota': -1, 'cm:firstName': 'firstName', 'cm:owner': { - 'id': 'test11', - 'displayName': 'firstName lastName2' + id: 'test11', + displayName: 'firstName lastName2' } }, - 'parentId': '3e9ce910-a4a0-4531-8f80-7734bece6342' + parentId: '3e9ce910-a4a0-4531-8f80-7734bece6342' } }] } diff --git a/lib/content-services/src/lib/mock/document-list.component.mock.ts b/lib/content-services/src/lib/mock/document-list.component.mock.ts index 5c79b529990..f4bcb4a7311 100644 --- a/lib/content-services/src/lib/mock/document-list.component.mock.ts +++ b/lib/content-services/src/lib/mock/document-list.component.mock.ts @@ -64,131 +64,131 @@ export const fakeNodeWithNoPermission = new Node({ }); export const fakeNodeAnswerWithEntries = { - 'list': { - 'pagination': { - 'count': 4, - 'hasMoreItems': false, - 'totalItems': 14, - 'skipCount': 10, - 'maxItems': 10 + list: { + pagination: { + count: 4, + hasMoreItems: false, + totalItems: 14, + skipCount: 10, + maxItems: 10 }, - 'entries': [{ - 'entry': { - 'isFile': true, - 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'modifiedAt': '2017-05-24T15:08:55.640Z', - 'nodeType': 'cm:content', - 'content': { - 'mimeType': 'application/rtf', - 'mimeTypeName': 'Rich Text Format', - 'sizeInBytes': 14530, - 'encoding': 'UTF-8' + entries: [{ + entry: { + isFile: true, + createdByUser: { id: 'admin', displayName: 'Administrator' }, + modifiedAt: '2017-05-24T15:08:55.640Z', + nodeType: 'cm:content', + content: { + mimeType: 'application/rtf', + mimeTypeName: 'Rich Text Format', + sizeInBytes: 14530, + encoding: 'UTF-8' }, - 'parentId': 'd124de26-6ba0-4f40-8d98-4907da2d337a', - 'createdAt': '2017-05-24T15:08:55.640Z', - 'path': { - 'name': '/Company Home/Guest Home', - 'isComplete': true, - 'elements': [{ - 'id': '94acfc73-7014-4475-9bd9-93a2162f0f8c', - 'name': 'Company Home' - }, { 'id': 'd124de26-6ba0-4f40-8d98-4907da2d337a', 'name': 'Guest Home' }] + parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a', + createdAt: '2017-05-24T15:08:55.640Z', + path: { + name: '/Company Home/Guest Home', + isComplete: true, + elements: [{ + id: '94acfc73-7014-4475-9bd9-93a2162f0f8c', + name: 'Company Home' + }, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }] }, - 'isFolder': false, - 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'name': 'b_txt_file.rtf', - 'id': '67b80f77-dbca-4f58-be6c-71b9dd61ea53', - 'properties': { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }, - 'allowableOperations': ['delete', 'update'] + isFolder: false, + modifiedByUser: { id: 'admin', displayName: 'Administrator' }, + name: 'b_txt_file.rtf', + id: '67b80f77-dbca-4f58-be6c-71b9dd61ea53', + properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }, + allowableOperations: ['delete', 'update'] } }] } }; export const fakeNodeAnswerWithNOEntries = { - 'list': { - 'pagination': { - 'count': 4, - 'hasMoreItems': false, - 'totalItems': 14, - 'skipCount': 10, - 'maxItems': 10 + list: { + pagination: { + count: 4, + hasMoreItems: false, + totalItems: 14, + skipCount: 10, + maxItems: 10 }, - 'entries': [] + entries: [] } }; export const fakeGetSitesAnswer = { - 'list': { - 'pagination': { - 'count': 3, - 'hasMoreItems': false, - 'totalItems': 3, - 'skipCount': 0, - 'maxItems': 20 + list: { + pagination: { + count: 3, + hasMoreItems: false, + totalItems: 3, + skipCount: 0, + maxItems: 20 }, - 'entries': [{ - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PRIVATE', - 'guid': 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b', - 'id': 'admin-site', - 'preset': 'site-dashboard', - 'title': 'Admin Site' + entries: [{ + entry: { + role: 'SiteManager', + visibility: 'PRIVATE', + guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b', + id: 'admin-site', + preset: 'site-dashboard', + title: 'Admin Site' } }, { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'swsdp', - 'preset': 'site-dashboard', - 'title': 'Sample: Web Site Design Project' + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'b4cff62a-664d-4d45-9302-98723eac1319', + description: 'This is a Sample Alfresco Team site.', + id: 'swsdp', + preset: 'site-dashboard', + title: 'Sample: Web Site Design Project' } }, { - 'entry': { - 'visibility': 'PUBLIC', - 'guid': 'af36cf8f-d43c-4a4b-84e6-d1b03e3a2ce5', - 'id': 'test-site', - 'preset': 'site-dashboard', - 'title': 'Test Site' + entry: { + visibility: 'PUBLIC', + guid: 'af36cf8f-d43c-4a4b-84e6-d1b03e3a2ce5', + id: 'test-site', + preset: 'site-dashboard', + title: 'Test Site' } }] } }; export const fakeGetSiteMembership = { - 'list': { - 'pagination': { - 'count': 2, - 'hasMoreItems': false, - 'totalItems': 2, - 'skipCount': 0, - 'maxItems': 20 + list: { + pagination: { + count: 2, + hasMoreItems: false, + totalItems: 2, + skipCount: 0, + maxItems: 20 }, - 'entries': [{ - 'entry': { - 'site': { - 'role': 'SiteManager', - 'visibility': 'PRIVATE', - 'guid': 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b', - 'id': 'admin-site', - 'preset': 'site-dashboard', - 'title': 'Admin Site' - }, 'role': 'SiteManager', 'guid': 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b', 'id': 'admin-site' + entries: [{ + entry: { + site: { + role: 'SiteManager', + visibility: 'PRIVATE', + guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b', + id: 'admin-site', + preset: 'site-dashboard', + title: 'Admin Site' + }, role: 'SiteManager', guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b', id: 'admin-site' } }, { - 'entry': { - 'site': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'swsdp', - 'preset': 'site-dashboard', - 'title': 'Sample: Web Site Design Project' - }, 'role': 'SiteManager', 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', 'id': 'swsdp' + entry: { + site: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'b4cff62a-664d-4d45-9302-98723eac1319', + description: 'This is a Sample Alfresco Team site.', + id: 'swsdp', + preset: 'site-dashboard', + title: 'Sample: Web Site Design Project' + }, role: 'SiteManager', guid: 'b4cff62a-664d-4d45-9302-98723eac1319', id: 'swsdp' } }] } @@ -217,90 +217,90 @@ export const fakeNodePaging: NodePaging = { }; export const mockNode1 = new Node({ - 'isFile': true, - 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'modifiedAt': '2017-05-24T15:08:55.640Z', - 'nodeType': 'cm:content', - 'content': { - 'mimeType': 'application/rtf', - 'mimeTypeName': 'Rich Text Format', - 'sizeInBytes': 14530, - 'encoding': 'UTF-8' + isFile: true, + createdByUser: { id: 'admin', displayName: 'Administrator' }, + modifiedAt: '2017-05-24T15:08:55.640Z', + nodeType: 'cm:content', + content: { + mimeType: 'application/rtf', + mimeTypeName: 'Rich Text Format', + sizeInBytes: 14530, + encoding: 'UTF-8' }, - 'parentId': 'd124de26-6ba0-4f40-8d98-4907da2d337a', - 'createdAt': '2017-05-24T15:08:55.640Z', - 'path': { - 'name': '/Company Home/Guest Home', - 'isComplete': true, - 'elements': [{ - 'id': '94acfc73-7014-4475-9bd9-93a2162f0f8c', - 'name': 'Company Home' - }, { 'id': 'd124de26-6ba0-4f40-8d98-4907da2d337a', 'name': 'Guest Home' }] + parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a', + createdAt: '2017-05-24T15:08:55.640Z', + path: { + name: '/Company Home/Guest Home', + isComplete: true, + elements: [{ + id: '94acfc73-7014-4475-9bd9-93a2162f0f8c', + name: 'Company Home' + }, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }] }, - 'isFolder': false, - 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'name': 'b_txt_file.rtf', - 'id': '70e1cc6a-6918-468a-b84a-1048093b06fd', - 'properties': { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }, - 'allowableOperations': ['delete', 'update'] + isFolder: false, + modifiedByUser: { id: 'admin', displayName: 'Administrator' }, + name: 'b_txt_file.rtf', + id: '70e1cc6a-6918-468a-b84a-1048093b06fd', + properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }, + allowableOperations: ['delete', 'update'] }); export const mockNode2 = new Node({ - 'isFile': true, - 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'modifiedAt': '2017-05-24T15:08:55.640Z', - 'nodeType': 'cm:content', - 'content': { - 'mimeType': 'application/rtf', - 'mimeTypeName': 'Rich Text Format', - 'sizeInBytes': 14530, - 'encoding': 'UTF-8' + isFile: true, + createdByUser: { id: 'admin', displayName: 'Administrator' }, + modifiedAt: '2017-05-24T15:08:55.640Z', + nodeType: 'cm:content', + content: { + mimeType: 'application/rtf', + mimeTypeName: 'Rich Text Format', + sizeInBytes: 14530, + encoding: 'UTF-8' }, - 'parentId': 'd124de26-6ba0-4f40-8d98-4907da2d337a', - 'createdAt': '2017-05-24T15:08:55.640Z', - 'path': { - 'name': '/Company Home/Guest Home', - 'isComplete': true, - 'elements': [{ - 'id': '94acfc73-7014-4475-9bd9-93a2162f0f8c', - 'name': 'Company Home' - }, { 'id': 'd124de26-6ba0-4f40-8d98-4907da2d337a', 'name': 'Guest Home' }] + parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a', + createdAt: '2017-05-24T15:08:55.640Z', + path: { + name: '/Company Home/Guest Home', + isComplete: true, + elements: [{ + id: '94acfc73-7014-4475-9bd9-93a2162f0f8c', + name: 'Company Home' + }, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }] }, - 'isFolder': false, - 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'name': 'b_txt_file.rtf', - 'id': '67b80f77-dbca-4f58-be6c-71b9dd61e554', - 'properties': { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }, - 'allowableOperations': ['delete', 'update'] + isFolder: false, + modifiedByUser: { id: 'admin', displayName: 'Administrator' }, + name: 'b_txt_file.rtf', + id: '67b80f77-dbca-4f58-be6c-71b9dd61e554', + properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }, + allowableOperations: ['delete', 'update'] }); export const mockNode3 = new Node({ - 'isFile': true, - 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'modifiedAt': '2017-05-24T15:08:55.640Z', - 'nodeType': 'cm:content', - 'content': { - 'mimeType': 'application/rtf', - 'mimeTypeName': 'Rich Text Format', - 'sizeInBytes': 14530, - 'encoding': 'UTF-8' + isFile: true, + createdByUser: { id: 'admin', displayName: 'Administrator' }, + modifiedAt: '2017-05-24T15:08:55.640Z', + nodeType: 'cm:content', + content: { + mimeType: 'application/rtf', + mimeTypeName: 'Rich Text Format', + sizeInBytes: 14530, + encoding: 'UTF-8' }, - 'parentId': 'd124de26-6ba0-4f40-8d98-4907da2d337a', - 'createdAt': '2017-05-24T15:08:55.640Z', - 'path': { - 'name': '/Company Home/Guest Home', - 'isComplete': true, - 'elements': [{ - 'id': '94acfc73-7014-4475-9bd9-93a2162f0f8c', - 'name': 'Company Home' - }, { 'id': 'd124de26-6ba0-4f40-8d98-4907da2d337a', 'name': 'Guest Home' }] + parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a', + createdAt: '2017-05-24T15:08:55.640Z', + path: { + name: '/Company Home/Guest Home', + isComplete: true, + elements: [{ + id: '94acfc73-7014-4475-9bd9-93a2162f0f8c', + name: 'Company Home' + }, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }] }, - 'isFolder': false, - 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' }, - 'name': 'c_txt_file.rtf', - 'id': '67b80f77-dbca-4f58-be6c-71b9dd61e555', - 'properties': { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }, - 'allowableOperations': ['delete', 'update'] + isFolder: false, + modifiedByUser: { id: 'admin', displayName: 'Administrator' }, + name: 'c_txt_file.rtf', + id: '67b80f77-dbca-4f58-be6c-71b9dd61e555', + properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }, + allowableOperations: ['delete', 'update'] }); export const mockPreselectedNodes: NodeEntry[] = [ diff --git a/lib/content-services/src/lib/mock/permission-list.component.mock.ts b/lib/content-services/src/lib/mock/permission-list.component.mock.ts index b2263ba5f12..7949f5ea2e8 100644 --- a/lib/content-services/src/lib/mock/permission-list.component.mock.ts +++ b/lib/content-services/src/lib/mock/permission-list.component.mock.ts @@ -16,80 +16,80 @@ */ export const fakeNodeWithPermissions: any = { - 'aspectNames': [ + aspectNames: [ 'cm:auditable', 'cm:taggable', 'cm:author', 'cm:titled', 'app:uifacets' ], - 'createdAt': '2017-11-16T16:29:38.638+0000', - 'path': { - 'name': '/Company Home/Sites/testsite/documentLibrary', - 'isComplete': true, - 'elements': [ + createdAt: '2017-11-16T16:29:38.638+0000', + path: { + name: '/Company Home/Sites/testsite/documentLibrary', + isComplete: true, + elements: [ { - 'id': '2be275a1-b00d-4e45-83d8-66af43ac2252', - 'name': 'Company Home' + id: '2be275a1-b00d-4e45-83d8-66af43ac2252', + name: 'Company Home' }, { - 'id': '1be10a97-6eb9-4b60-b6c6-1673900e9631', - 'name': 'Sites' + id: '1be10a97-6eb9-4b60-b6c6-1673900e9631', + name: 'Sites' }, { - 'id': 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', - 'name': 'testsite' + id: 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', + name: 'testsite' }, { - 'id': '71626fae-0c04-4d0c-a129-20fa4c178716', - 'name': 'documentLibrary' + id: '71626fae-0c04-4d0c-a129-20fa4c178716', + name: 'documentLibrary' } ] }, - 'isFolder': true, - 'isFile': false, - 'createdByUser': { - 'id': 'System', - 'displayName': 'System' + isFolder: true, + isFile: false, + createdByUser: { + id: 'System', + displayName: 'System' }, - 'modifiedAt': '2018-03-21T03:17:58.783+0000', - 'permissions': { - 'inherited': [ + modifiedAt: '2018-03-21T03:17:58.783+0000', + permissions: { + inherited: [ { - 'authorityId': 'guest', - 'name': 'Read', - 'accessStatus': 'ALLOWED' + authorityId: 'guest', + name: 'Read', + accessStatus: 'ALLOWED' }, { - 'authorityId': 'GROUP_EVERYONE', - 'name': 'Read', - 'accessStatus': 'ALLOWED' + authorityId: 'GROUP_EVERYONE', + name: 'Read', + accessStatus: 'ALLOWED' } ], - 'locallySet': [ + locallySet: [ { - 'authorityId': 'GROUP_EVERYONE', - 'name': 'Contributor', - 'accessStatus': 'ALLOWED' + authorityId: 'GROUP_EVERYONE', + name: 'Contributor', + accessStatus: 'ALLOWED' } ], - 'settable': [ + settable: [ 'Contributor', 'Collaborator', 'Coordinator', 'Editor', 'Consumer' ], - 'isInheritanceEnabled': true + isInheritanceEnabled: true }, - 'modifiedByUser': { - 'id': 'admin', - 'displayName': 'PedroH Hernandez' + modifiedByUser: { + id: 'admin', + displayName: 'PedroH Hernandez' }, - 'name': 'test', - 'id': 'f472543f-7218-403d-917b-7a5861257244', - 'nodeType': 'cm:folder', - 'properties': { + name: 'test', + id: 'f472543f-7218-403d-917b-7a5861257244', + nodeType: 'cm:folder', + properties: { 'cm:title': 'test', 'cm:author': 'yagud', 'cm:taggable': [ @@ -101,75 +101,75 @@ export const fakeNodeWithPermissions: any = { }; export const fakeNodeInheritedOnly = { - 'allowableOperations': [ 'updatePermissions' ], - 'aspectNames': [ + allowableOperations: [ 'updatePermissions' ], + aspectNames: [ 'cm:auditable', 'cm:taggable', 'cm:author', 'cm:titled', 'app:uifacets' ], - 'createdAt': '2017-11-16T16:29:38.638+0000', - 'path': { - 'name': '/Company Home/Sites/testsite/documentLibrary', - 'isComplete': true, - 'elements': [ + createdAt: '2017-11-16T16:29:38.638+0000', + path: { + name: '/Company Home/Sites/testsite/documentLibrary', + isComplete: true, + elements: [ { - 'id': '2be275a1-b00d-4e45-83d8-66af43ac2252', - 'name': 'Company Home' + id: '2be275a1-b00d-4e45-83d8-66af43ac2252', + name: 'Company Home' }, { - 'id': '1be10a97-6eb9-4b60-b6c6-1673900e9631', - 'name': 'Sites' + id: '1be10a97-6eb9-4b60-b6c6-1673900e9631', + name: 'Sites' }, { - 'id': 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', - 'name': 'testsite', - 'nodeType': 'st:site' + id: 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', + name: 'testsite', + nodeType: 'st:site' }, { - 'id': '71626fae-0c04-4d0c-a129-20fa4c178716', - 'name': 'documentLibrary' + id: '71626fae-0c04-4d0c-a129-20fa4c178716', + name: 'documentLibrary' } ] }, - 'isFolder': true, - 'isFile': false, - 'createdByUser': { - 'id': 'System', - 'displayName': 'System' + isFolder: true, + isFile: false, + createdByUser: { + id: 'System', + displayName: 'System' }, - 'modifiedAt': '2018-03-21T03:17:58.783+0000', - 'permissions': { - 'inherited': [ + modifiedAt: '2018-03-21T03:17:58.783+0000', + permissions: { + inherited: [ { - 'authorityId': 'guest', - 'name': 'Read', - 'accessStatus': 'ALLOWED' + authorityId: 'guest', + name: 'Read', + accessStatus: 'ALLOWED' }, { - 'authorityId': 'GROUP_EVERYONE', - 'name': 'Read', - 'accessStatus': 'ALLOWED' + authorityId: 'GROUP_EVERYONE', + name: 'Read', + accessStatus: 'ALLOWED' } ], - 'settable': [ + settable: [ 'Contributor', 'Collaborator', 'Coordinator', 'Editor', 'Consumer' ], - 'isInheritanceEnabled': true + isInheritanceEnabled: true }, - 'modifiedByUser': { - 'id': 'admin', - 'displayName': 'PedroH Hernandez' + modifiedByUser: { + id: 'admin', + displayName: 'PedroH Hernandez' }, - 'name': 'test', - 'id': 'f472543f-7218-403d-917b-7a5861257244', - 'nodeType': 'cm:folder', - 'properties': { + name: 'test', + id: 'f472543f-7218-403d-917b-7a5861257244', + nodeType: 'cm:folder', + properties: { 'cm:title': 'test', 'cm:author': 'yagud', 'cm:taggable': [ @@ -181,73 +181,73 @@ export const fakeNodeInheritedOnly = { }; export const fakeReadOnlyNodeInherited = { - 'aspectNames': [ + aspectNames: [ 'cm:auditable', 'cm:taggable', 'cm:author', 'cm:titled', 'app:uifacets' ], - 'createdAt': '2017-11-16T16:29:38.638+0000', - 'path': { - 'name': '/Company Home/Sites/testsite/documentLibrary', - 'isComplete': true, - 'elements': [ + createdAt: '2017-11-16T16:29:38.638+0000', + path: { + name: '/Company Home/Sites/testsite/documentLibrary', + isComplete: true, + elements: [ { - 'id': '2be275a1-b00d-4e45-83d8-66af43ac2252', - 'name': 'Company Home' + id: '2be275a1-b00d-4e45-83d8-66af43ac2252', + name: 'Company Home' }, { - 'id': '1be10a97-6eb9-4b60-b6c6-1673900e9631', - 'name': 'Sites' + id: '1be10a97-6eb9-4b60-b6c6-1673900e9631', + name: 'Sites' }, { - 'id': 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', - 'name': 'testsite' + id: 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', + name: 'testsite' }, { - 'id': '71626fae-0c04-4d0c-a129-20fa4c178716', - 'name': 'documentLibrary' + id: '71626fae-0c04-4d0c-a129-20fa4c178716', + name: 'documentLibrary' } ] }, - 'isFolder': true, - 'isFile': false, - 'createdByUser': { - 'id': 'System', - 'displayName': 'System' + isFolder: true, + isFile: false, + createdByUser: { + id: 'System', + displayName: 'System' }, - 'modifiedAt': '2018-03-21T03:17:58.783+0000', - 'permissions': { - 'inherited': [ + modifiedAt: '2018-03-21T03:17:58.783+0000', + permissions: { + inherited: [ { - 'authorityId': 'guest', - 'name': 'Read', - 'accessStatus': 'ALLOWED' + authorityId: 'guest', + name: 'Read', + accessStatus: 'ALLOWED' }, { - 'authorityId': 'GROUP_EVERYONE', - 'name': 'Read', - 'accessStatus': 'ALLOWED' + authorityId: 'GROUP_EVERYONE', + name: 'Read', + accessStatus: 'ALLOWED' } ], - 'settable': [ + settable: [ 'Contributor', 'Collaborator', 'Coordinator', 'Editor', 'Consumer' ], - 'isInheritanceEnabled': true + isInheritanceEnabled: true }, - 'modifiedByUser': { - 'id': 'admin', - 'displayName': 'PedroH Hernandez' + modifiedByUser: { + id: 'admin', + displayName: 'PedroH Hernandez' }, - 'name': 'test', - 'id': 'f472543f-7218-403d-917b-7a5861257244', - 'nodeType': 'cm:folder', - 'properties': { + name: 'test', + id: 'f472543f-7218-403d-917b-7a5861257244', + nodeType: 'cm:folder', + properties: { 'cm:title': 'test', 'cm:author': 'yagud', 'cm:taggable': [ @@ -259,68 +259,68 @@ export const fakeReadOnlyNodeInherited = { }; export const fakeNodeWithOnlyLocally: any = { - 'aspectNames': [ + aspectNames: [ 'cm:auditable', 'cm:taggable', 'cm:author', 'cm:titled', 'app:uifacets' ], - 'createdAt': '2017-11-16T16:29:38.638+0000', - 'path': { - 'name': '/Company Home/Sites/testsite/documentLibrary', - 'isComplete': true, - 'elements': [ + createdAt: '2017-11-16T16:29:38.638+0000', + path: { + name: '/Company Home/Sites/testsite/documentLibrary', + isComplete: true, + elements: [ { - 'id': '2be275a1-b00d-4e45-83d8-66af43ac2252', - 'name': 'Company Home' + id: '2be275a1-b00d-4e45-83d8-66af43ac2252', + name: 'Company Home' }, { - 'id': '1be10a97-6eb9-4b60-b6c6-1673900e9631', - 'name': 'Sites' + id: '1be10a97-6eb9-4b60-b6c6-1673900e9631', + name: 'Sites' }, { - 'id': 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', - 'name': 'testsite' + id: 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', + name: 'testsite' }, { - 'id': '71626fae-0c04-4d0c-a129-20fa4c178716', - 'name': 'documentLibrary' + id: '71626fae-0c04-4d0c-a129-20fa4c178716', + name: 'documentLibrary' } ] }, - 'isFolder': true, - 'isFile': false, - 'createdByUser': { - 'id': 'System', - 'displayName': 'System' + isFolder: true, + isFile: false, + createdByUser: { + id: 'System', + displayName: 'System' }, - 'modifiedAt': '2018-03-21T03:17:58.783+0000', - 'permissions': { - 'locallySet': [ + modifiedAt: '2018-03-21T03:17:58.783+0000', + permissions: { + locallySet: [ { - 'authorityId': 'GROUP_EVERYONE', - 'name': 'Contributor', - 'accessStatus': 'ALLOWED' + authorityId: 'GROUP_EVERYONE', + name: 'Contributor', + accessStatus: 'ALLOWED' } ], - 'settable': [ + settable: [ 'Contributor', 'Collaborator', 'Coordinator', 'Editor', 'Consumer' ], - 'isInheritanceEnabled': false + isInheritanceEnabled: false }, - 'modifiedByUser': { - 'id': 'admin', - 'displayName': 'PedroH Hernandez' + modifiedByUser: { + id: 'admin', + displayName: 'PedroH Hernandez' }, - 'name': 'test', - 'id': 'f472543f-7218-403d-917b-7a5861257244', - 'nodeType': 'cm:folder', - 'properties': { + name: 'test', + id: 'f472543f-7218-403d-917b-7a5861257244', + nodeType: 'cm:folder', + properties: { 'cm:title': 'test', 'cm:author': 'yagud', 'cm:taggable': [ @@ -332,78 +332,78 @@ export const fakeNodeWithOnlyLocally: any = { }; export const fakeNodeToRemovePermission: any = { - 'aspectNames': [ + aspectNames: [ 'cm:auditable', 'cm:taggable', 'cm:author', 'cm:titled', 'app:uifacets' ], - 'createdAt': '2017-11-16T16:29:38.638+0000', - 'path': { - 'name': '/Company Home/Sites/testsite/documentLibrary', - 'isComplete': true, - 'elements': [ + createdAt: '2017-11-16T16:29:38.638+0000', + path: { + name: '/Company Home/Sites/testsite/documentLibrary', + isComplete: true, + elements: [ { - 'id': '2be275a1-b00d-4e45-83d8-66af43ac2252', - 'name': 'Company Home' + id: '2be275a1-b00d-4e45-83d8-66af43ac2252', + name: 'Company Home' }, { - 'id': '1be10a97-6eb9-4b60-b6c6-1673900e9631', - 'name': 'Sites' + id: '1be10a97-6eb9-4b60-b6c6-1673900e9631', + name: 'Sites' }, { - 'id': 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', - 'name': 'testsite' + id: 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', + name: 'testsite' }, { - 'id': '71626fae-0c04-4d0c-a129-20fa4c178716', - 'name': 'documentLibrary' + id: '71626fae-0c04-4d0c-a129-20fa4c178716', + name: 'documentLibrary' } ] }, - 'isFolder': true, - 'isFile': false, - 'createdByUser': { - 'id': 'System', - 'displayName': 'System' + isFolder: true, + isFile: false, + createdByUser: { + id: 'System', + displayName: 'System' }, - 'modifiedAt': '2018-03-21T03:17:58.783+0000', - 'permissions': { - 'locallySet': [ + modifiedAt: '2018-03-21T03:17:58.783+0000', + permissions: { + locallySet: [ { - 'authorityId': 'GROUP_EVERYONE', - 'name': 'Contributor', - 'accessStatus': 'ALLOWED' + authorityId: 'GROUP_EVERYONE', + name: 'Contributor', + accessStatus: 'ALLOWED' }, { - 'authorityId': 'GROUP_FAKE_1', - 'name': 'Contributor', - 'accessStatus': 'ALLOWED' + authorityId: 'GROUP_FAKE_1', + name: 'Contributor', + accessStatus: 'ALLOWED' }, { - 'authorityId': 'FAKE_PERSON_1', - 'name': 'Contributor', - 'accessStatus': 'ALLOWED' + authorityId: 'FAKE_PERSON_1', + name: 'Contributor', + accessStatus: 'ALLOWED' } ], - 'settable': [ + settable: [ 'Contributor', 'Collaborator', 'Coordinator', 'Editor', 'Consumer' ], - 'isInheritanceEnabled': true + isInheritanceEnabled: true }, - 'modifiedByUser': { - 'id': 'admin', - 'displayName': 'PedroH Hernandez' + modifiedByUser: { + id: 'admin', + displayName: 'PedroH Hernandez' }, - 'name': 'test', - 'id': 'f472543f-7218-403d-917b-7a5861257244', - 'nodeType': 'cm:folder', - 'properties': { + name: 'test', + id: 'f472543f-7218-403d-917b-7a5861257244', + nodeType: 'cm:folder', + properties: { 'cm:title': 'test', 'cm:author': 'yagud', 'cm:taggable': [ @@ -415,56 +415,56 @@ export const fakeNodeToRemovePermission: any = { }; export const fakeNodeWithoutPermissions: any = { - 'aspectNames': [ + aspectNames: [ 'cm:auditable', 'cm:taggable', 'cm:author', 'cm:titled', 'app:uifacets' ], - 'createdAt': '2017-11-16T16:29:38.638+0000', - 'path': { - 'name': '/Company Home/Sites/testsite/documentLibrary', - 'isComplete': true, - 'elements': [ + createdAt: '2017-11-16T16:29:38.638+0000', + path: { + name: '/Company Home/Sites/testsite/documentLibrary', + isComplete: true, + elements: [ { - 'id': '2be275a1-b00d-4e45-83d8-66af43ac2252', - 'name': 'Company Home' + id: '2be275a1-b00d-4e45-83d8-66af43ac2252', + name: 'Company Home' }, { - 'id': '1be10a97-6eb9-4b60-b6c6-1673900e9631', - 'name': 'Sites' + id: '1be10a97-6eb9-4b60-b6c6-1673900e9631', + name: 'Sites' }, { - 'id': 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', - 'name': 'testsite' + id: 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', + name: 'testsite' }, { - 'id': '71626fae-0c04-4d0c-a129-20fa4c178716', - 'name': 'documentLibrary' + id: '71626fae-0c04-4d0c-a129-20fa4c178716', + name: 'documentLibrary' } ] }, - 'isFolder': true, - 'isFile': false, - 'createdByUser': { - 'id': 'System', - 'displayName': 'System' + isFolder: true, + isFile: false, + createdByUser: { + id: 'System', + displayName: 'System' }, - 'modifiedAt': '2018-03-21T03:17:58.783+0000', - 'permissions': { - 'locallySet': [], - 'settable': [], - 'isInheritanceEnabled': false + modifiedAt: '2018-03-21T03:17:58.783+0000', + permissions: { + locallySet: [], + settable: [], + isInheritanceEnabled: false }, - 'modifiedByUser': { - 'id': 'admin', - 'displayName': 'PedroH Hernandez' + modifiedByUser: { + id: 'admin', + displayName: 'PedroH Hernandez' }, - 'name': 'test', - 'id': 'f472543f-7218-403d-917b-7a5861257244', - 'nodeType': 'cm:folder', - 'properties': { + name: 'test', + id: 'f472543f-7218-403d-917b-7a5861257244', + nodeType: 'cm:folder', + properties: { 'cm:title': 'test', 'cm:author': 'yagud', 'cm:taggable': [ @@ -476,45 +476,45 @@ export const fakeNodeWithoutPermissions: any = { }; export const fakeSiteNodeResponse: any = { - 'list': { - 'pagination': { - 'count': 1, - 'hasMoreItems': false, - 'totalItems': 1, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 1, + hasMoreItems: false, + totalItems: 1, + skipCount: 0, + maxItems: 100 }, - 'context': {}, - 'entries': [ + context: {}, + entries: [ { - 'entry': { - 'isLink': false, - 'isFile': false, - 'createdByUser': { - 'id': 'admin', - 'displayName': 'Administrator' + entry: { + isLink: false, + isFile: false, + createdByUser: { + id: 'admin', + displayName: 'Administrator' }, - 'modifiedAt': '2018-03-22T15:40:10.093+0000', - 'nodeType': 'st:site', - 'parentId': '1be10a97-6eb9-4b60-b6c6-1673900e9631', - 'aspectNames': [ + modifiedAt: '2018-03-22T15:40:10.093+0000', + nodeType: 'st:site', + parentId: '1be10a97-6eb9-4b60-b6c6-1673900e9631', + aspectNames: [ 'cm:tagscope', 'cm:titled', 'cm:auditable' ], - 'createdAt': '2018-03-22T15:39:50.821+0000', - 'isFolder': true, - 'search': { - 'score': 10.292057 + createdAt: '2018-03-22T15:39:50.821+0000', + isFolder: true, + search: { + score: 10.292057 }, - 'modifiedByUser': { - 'id': 'admin', - 'displayName': 'Administrator' + modifiedByUser: { + id: 'admin', + displayName: 'Administrator' }, - 'name': 'testsite', - 'location': 'nodes', - 'id': 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', - 'properties': { + name: 'testsite', + location: 'nodes', + id: 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', + properties: { 'st:siteVisibility': 'PUBLIC', 'cm:title': 'TEST_SITE', 'st:sitePreset': 'site-dashboard' @@ -526,41 +526,41 @@ export const fakeSiteNodeResponse: any = { }; export const fakeSiteRoles: any = { - 'list': { - 'pagination': { - 'count': 4, - 'hasMoreItems': false, - 'totalItems': 4, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 4, + hasMoreItems: false, + totalItems: 4, + skipCount: 0, + maxItems: 100 }, - 'entries': [ + entries: [ { - 'entry': { - 'displayName': 'site_testsite_SiteCollaborator', - 'id': 'GROUP_site_testsite_SiteCollaborator', - 'memberType': 'GROUP' + entry: { + displayName: 'site_testsite_SiteCollaborator', + id: 'GROUP_site_testsite_SiteCollaborator', + memberType: 'GROUP' } }, { - 'entry': { - 'displayName': 'site_testsite_SiteConsumer', - 'id': 'GROUP_site_testsite_SiteConsumer', - 'memberType': 'GROUP' + entry: { + displayName: 'site_testsite_SiteConsumer', + id: 'GROUP_site_testsite_SiteConsumer', + memberType: 'GROUP' } }, { - 'entry': { - 'displayName': 'site_testsite_SiteContributor', - 'id': 'GROUP_site_testsite_SiteContributor', - 'memberType': 'GROUP' + entry: { + displayName: 'site_testsite_SiteContributor', + id: 'GROUP_site_testsite_SiteContributor', + memberType: 'GROUP' } }, { - 'entry': { - 'displayName': 'site_testsite_SiteManager', - 'id': 'GROUP_site_testsite_SiteManager', - 'memberType': 'GROUP' + entry: { + displayName: 'site_testsite_SiteManager', + id: 'GROUP_site_testsite_SiteManager', + memberType: 'GROUP' } } ] @@ -568,89 +568,89 @@ export const fakeSiteRoles: any = { }; export const fakeEmptyResponse: any = { - 'list': { - 'pagination': { - 'count': 0, - 'hasMoreItems': false, - 'totalItems': 0, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 0, + hasMoreItems: false, + totalItems: 0, + skipCount: 0, + maxItems: 100 }, - 'context': {}, - 'entries': [] + context: {}, + entries: [] } }; export const fakeNodeLocalSiteManager = { - 'allowableOperations': [ 'updatePermissions' ], - 'aspectNames': [ + allowableOperations: [ 'updatePermissions' ], + aspectNames: [ 'cm:auditable', 'cm:taggable', 'cm:author', 'cm:titled', 'app:uifacets' ], - 'createdAt': '2017-11-16T16:29:38.638+0000', - 'path': { - 'name': '/Company Home/Sites/testsite/documentLibrary', - 'isComplete': true, - 'elements': [ + createdAt: '2017-11-16T16:29:38.638+0000', + path: { + name: '/Company Home/Sites/testsite/documentLibrary', + isComplete: true, + elements: [ { - 'id': '2be275a1-b00d-4e45-83d8-66af43ac2252', - 'name': 'Company Home' + id: '2be275a1-b00d-4e45-83d8-66af43ac2252', + name: 'Company Home' }, { - 'id': '1be10a97-6eb9-4b60-b6c6-1673900e9631', - 'name': 'Sites' + id: '1be10a97-6eb9-4b60-b6c6-1673900e9631', + name: 'Sites' }, { - 'id': 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', - 'name': 'testsite', - 'nodeType': 'st:site' + id: 'e002c740-b8f9-482a-a554-8fff4e4c9dc0', + name: 'testsite', + nodeType: 'st:site' }, { - 'id': '71626fae-0c04-4d0c-a129-20fa4c178716', - 'name': 'documentLibrary' + id: '71626fae-0c04-4d0c-a129-20fa4c178716', + name: 'documentLibrary' } ] }, - 'isFolder': true, - 'isFile': false, - 'createdByUser': { - 'id': 'System', - 'displayName': 'System' + isFolder: true, + isFile: false, + createdByUser: { + id: 'System', + displayName: 'System' }, - 'modifiedAt': '2018-03-21T03:17:58.783+0000', - 'permissions': { - 'locallySet': [ + modifiedAt: '2018-03-21T03:17:58.783+0000', + permissions: { + locallySet: [ { - 'authorityId': 'GROUP_site_testsite_SiteManager', - 'name': 'SiteManager', - 'accessStatus': 'ALLOWED' + authorityId: 'GROUP_site_testsite_SiteManager', + name: 'SiteManager', + accessStatus: 'ALLOWED' }, { - 'authorityId': 'superadminuser', - 'name': 'SiteCollaborator', - 'accessStatus': 'ALLOWED' + authorityId: 'superadminuser', + name: 'SiteCollaborator', + accessStatus: 'ALLOWED' } ], - 'settable': [ + settable: [ 'Contributor', 'Collaborator', 'Coordinator', 'Editor', 'Consumer' ], - 'isInheritanceEnabled': false + isInheritanceEnabled: false }, - 'modifiedByUser': { - 'id': 'admin', - 'displayName': 'PedroH Hernandez' + modifiedByUser: { + id: 'admin', + displayName: 'PedroH Hernandez' }, - 'name': 'test', - 'id': 'f472543f-7218-403d-917b-7a5861257244', - 'nodeType': 'cm:folder', - 'properties': { + name: 'test', + id: 'f472543f-7218-403d-917b-7a5861257244', + nodeType: 'cm:folder', + properties: { 'cm:title': 'test', 'cm:author': 'yagud', 'cm:taggable': [ diff --git a/lib/content-services/src/lib/mock/search-filter-mock.ts b/lib/content-services/src/lib/mock/search-filter-mock.ts index 594f09a9d95..92b58a8fcc9 100644 --- a/lib/content-services/src/lib/mock/search-filter-mock.ts +++ b/lib/content-services/src/lib/mock/search-filter-mock.ts @@ -39,11 +39,11 @@ export const disabledCategories = [ component: { selector: 'check-list', settings: { - 'field': null, - 'pageSize': 5, - 'options': [ - { 'name': 'Folder', 'value': `TYPE:'cm:folder'` }, - { 'name': 'Document', 'value': `TYPE:'cm:content'` } + field: null, + pageSize: 5, + options: [ + { name: 'Folder', value: `TYPE:'cm:folder'` }, + { name: 'Document', value: `TYPE:'cm:content'` } ] } } @@ -59,11 +59,11 @@ export const expandedCategories = [ component: { selector: 'check-list', settings: { - 'field': null, - 'pageSize': 5, - 'options': [ - { 'name': 'Folder', 'value': `TYPE:'cm:folder'` }, - { 'name': 'Document', 'value': `TYPE:'cm:content'` } + field: null, + pageSize: 5, + options: [ + { name: 'Folder', value: `TYPE:'cm:folder'` }, + { name: 'Document', value: `TYPE:'cm:content'` } ] } } @@ -91,11 +91,11 @@ export const simpleCategories: SearchCategory[] = [ component: { selector: 'check-list', settings: { - 'field': 'check-list', - 'pageSize': 5, - 'options': [ - { 'name': 'Folder', 'value': `TYPE:'cm:folder'` }, - { 'name': 'Document', 'value': `TYPE:'cm:content'` } + field: 'check-list', + pageSize: 5, + options: [ + { name: 'Folder', value: `TYPE:'cm:folder'` }, + { name: 'Document', value: `TYPE:'cm:content'` } ] } } @@ -107,288 +107,288 @@ export const searchFilter = { 'app:fields': [ 'cm:name' ], - 'include': [ + include: [ 'allowableOperations' ], - 'sorting': { - 'options': [ + sorting: { + options: [ { - 'key': 'name', - 'label': 'Name', - 'type': 'FIELD', - 'field': 'cm:name', - 'ascending': true + key: 'name', + label: 'Name', + type: 'FIELD', + field: 'cm:name', + ascending: true } ], - 'defaults': [ + defaults: [ { - 'key': 'score', - 'type': 'FIELD', - 'field': 'score', - 'ascending': false + key: 'score', + type: 'FIELD', + field: 'score', + ascending: false } ] }, - 'resetButton': true, - 'filterQueries': [ + resetButton: true, + filterQueries: [ { - 'query': `TYPE:'cm:folder' OR TYPE:'cm:content'` + query: `TYPE:'cm:folder' OR TYPE:'cm:content'` }, { - 'query': 'NOT cm:creator:System' + query: 'NOT cm:creator:System' } ], - 'facetFields': { - 'expanded': true, - 'fields': [ + facetFields: { + expanded: true, + fields: [ { - 'field': 'content.mimetype', - 'mincount': 1, - 'label': 'SEARCH.FACET_FIELDS.TYPE' + field: 'content.mimetype', + mincount: 1, + label: 'SEARCH.FACET_FIELDS.TYPE' }, { - 'field': 'content.size', - 'mincount': 1, - 'label': 'SEARCH.FACET_FIELDS.SIZE' + field: 'content.size', + mincount: 1, + label: 'SEARCH.FACET_FIELDS.SIZE' }, { - 'field': 'creator', - 'mincount': 1, - 'label': 'SEARCH.FACET_FIELDS.CREATOR' + field: 'creator', + mincount: 1, + label: 'SEARCH.FACET_FIELDS.CREATOR' }, { - 'field': 'modifier', - 'mincount': 1, - 'label': 'SEARCH.FACET_FIELDS.MODIFIER' + field: 'modifier', + mincount: 1, + label: 'SEARCH.FACET_FIELDS.MODIFIER' }, { - 'field': 'created', - 'mincount': 1, - 'label': 'SEARCH.FACET_FIELDS.CREATED' + field: 'created', + mincount: 1, + label: 'SEARCH.FACET_FIELDS.CREATED' } ] }, - 'facetQueries': { - 'label': 'SEARCH.FACET_QUERIES.MY_FACET_QUERIES', - 'pageSize': 5, - 'expanded': true, - 'mincount': 1, - 'queries': [ + facetQueries: { + label: 'SEARCH.FACET_QUERIES.MY_FACET_QUERIES', + pageSize: 5, + expanded: true, + mincount: 1, + queries: [ { - 'query': 'created:2019', - 'label': 'SEARCH.FACET_QUERIES.CREATED_THIS_YEAR' + query: 'created:2019', + label: 'SEARCH.FACET_QUERIES.CREATED_THIS_YEAR' }, { - 'query': 'content.mimetype:text/html', - 'label': 'SEARCH.FACET_QUERIES.MIMETYPE', - 'group': 'Type facet queries' + query: 'content.mimetype:text/html', + label: 'SEARCH.FACET_QUERIES.MIMETYPE', + group: 'Type facet queries' }, { - 'query': 'content.size:[0 TO 10240]', - 'label': 'Extra Small', - 'group': 'Size facet queries' + query: 'content.size:[0 TO 10240]', + label: 'Extra Small', + group: 'Size facet queries' }, { - 'query': 'content.size:[10240 TO 102400]', - 'label': 'SEARCH.FACET_QUERIES.SMALL', - 'group': 'Size facet queries' + query: 'content.size:[10240 TO 102400]', + label: 'SEARCH.FACET_QUERIES.SMALL', + group: 'Size facet queries' }, { - 'query': 'content.size:[102400 TO 1048576]', - 'label': 'SEARCH.FACET_QUERIES.MEDIUM', - 'group': 'Size facet queries' + query: 'content.size:[102400 TO 1048576]', + label: 'SEARCH.FACET_QUERIES.MEDIUM', + group: 'Size facet queries' }, { - 'query': 'content.size:[1048576 TO 16777216]', - 'label': 'SEARCH.FACET_QUERIES.LARGE', - 'group': 'Size facet queries' + query: 'content.size:[1048576 TO 16777216]', + label: 'SEARCH.FACET_QUERIES.LARGE', + group: 'Size facet queries' }, { - 'query': 'content.size:[16777216 TO 134217728]', - 'label': 'SEARCH.FACET_QUERIES.XTRALARGE', - 'group': 'Size facet queries' + query: 'content.size:[16777216 TO 134217728]', + label: 'SEARCH.FACET_QUERIES.XTRALARGE', + group: 'Size facet queries' }, { - 'query': 'content.size:[134217728 TO MAX]', - 'label': 'SEARCH.FACET_QUERIES.XXTRALARGE', - 'group': 'Size facet queries' + query: 'content.size:[134217728 TO MAX]', + label: 'SEARCH.FACET_QUERIES.XXTRALARGE', + group: 'Size facet queries' }, { - 'query': 'content.size:[111111 TO MAX]', - 'label': 'my1', - 'group': 'Size facet queries' + query: 'content.size:[111111 TO MAX]', + label: 'my1', + group: 'Size facet queries' }, { - 'query': 'content.size:[222222 TO MAX]', - 'label': 'my2', - 'group': 'Size facet queries' + query: 'content.size:[222222 TO MAX]', + label: 'my2', + group: 'Size facet queries' }, { - 'query': 'content.size:[333333 TO MAX]', - 'label': 'my3', - 'group': 'Size facet queries' + query: 'content.size:[333333 TO MAX]', + label: 'my3', + group: 'Size facet queries' }, { - 'query': 'content.size:[444444 TO MAX]', - 'label': 'my4', - 'group': 'Size facet queries' + query: 'content.size:[444444 TO MAX]', + label: 'my4', + group: 'Size facet queries' }, { - 'query': 'content.size:[5555 TO MAX]', - 'label': 'my5', - 'group': 'Size facet queries' + query: 'content.size:[5555 TO MAX]', + label: 'my5', + group: 'Size facet queries' }, { - 'query': 'content.size:[666666 TO MAX]', - 'label': 'my6', - 'group': 'Size facet queries' + query: 'content.size:[666666 TO MAX]', + label: 'my6', + group: 'Size facet queries' }, { - 'query': 'content.size:[777777 TO MAX]', - 'label': 'my7', - 'group': 'Size facet queries' + query: 'content.size:[777777 TO MAX]', + label: 'my7', + group: 'Size facet queries' }, { - 'query': 'content.size:[888888 TO MAX]', - 'label': 'my8', - 'group': 'Size facet queries' + query: 'content.size:[888888 TO MAX]', + label: 'my8', + group: 'Size facet queries' } ] }, - 'facetIntervals': { - 'expanded': true, - 'intervals': [ + facetIntervals: { + expanded: true, + intervals: [ { - 'label': 'The Created', - 'field': 'cm:created', - 'sets': [ + label: 'The Created', + field: 'cm:created', + sets: [ { - 'label': 'lastYear', - 'start': '2018', - 'end': '2019', - 'endInclusive': false + label: 'lastYear', + start: '2018', + end: '2019', + endInclusive: false }, { - 'label': 'currentYear', - 'start': 'NOW/YEAR', - 'end': 'NOW/YEAR+1YEAR' + label: 'currentYear', + start: 'NOW/YEAR', + end: 'NOW/YEAR+1YEAR' }, { - 'label': 'earlier', - 'start': '*', - 'end': '2018', - 'endInclusive': false + label: 'earlier', + start: '*', + end: '2018', + endInclusive: false } ] }, { - 'label': 'TheModified', - 'field': 'cm:modified', - 'sets': [ + label: 'TheModified', + field: 'cm:modified', + sets: [ { - 'label': '2017', - 'start': '2017', - 'end': '2018', - 'endInclusive': false + label: '2017', + start: '2017', + end: '2018', + endInclusive: false }, { - 'label': '2017-2018', - 'start': '2017', - 'end': '2018', - 'endInclusive': true + label: '2017-2018', + start: '2017', + end: '2018', + endInclusive: true }, { - 'label': 'currentYear', - 'start': 'NOW/YEAR', - 'end': 'NOW/YEAR+1YEAR' + label: 'currentYear', + start: 'NOW/YEAR', + end: 'NOW/YEAR+1YEAR' }, { - 'label': 'earlierThan2017', - 'start': '*', - 'end': '2017', - 'endInclusive': false + label: 'earlierThan2017', + start: '*', + end: '2017', + endInclusive: false } ] } ] }, - 'categories': [ + categories: [ { - 'id': 'queryName', - 'name': 'Name', - 'enabled': true, - 'expanded': true, - 'component': { - 'selector': 'text', - 'settings': { - 'pattern': `cm:name:'(.*?)'`, - 'field': 'cm:name', - 'placeholder': 'Enter the name' + id: 'queryName', + name: 'Name', + enabled: true, + expanded: true, + component: { + selector: 'text', + settings: { + pattern: `cm:name:'(.*?)'`, + field: 'cm:name', + placeholder: 'Enter the name' } } }, { - 'id': 'checkList', - 'name': 'Check List', - 'enabled': true, - 'component': { - 'selector': 'check-list', - 'settings': { - 'pageSize': 5, - 'operator': 'OR', - 'options': [] + id: 'checkList', + name: 'Check List', + enabled: true, + component: { + selector: 'check-list', + settings: { + pageSize: 5, + operator: 'OR', + options: [] } } }, { - 'id': 'contentSize', - 'name': 'Content Size', - 'enabled': true, - 'component': { - 'selector': 'slider', - 'settings': { - 'field': 'cm:content.size', - 'min': 0, - 'max': 18, - 'step': 1, - 'thumbLabel': true + id: 'contentSize', + name: 'Content Size', + enabled: true, + component: { + selector: 'slider', + settings: { + field: 'cm:content.size', + min: 0, + max: 18, + step: 1, + thumbLabel: true } } }, { - 'id': 'contentSizeRange', - 'name': 'Content Size (range)', - 'enabled': true, - 'component': { - 'selector': 'number-range', - 'settings': { - 'field': 'cm:content.size', - 'format': '[{FROM} TO {TO}]' + id: 'contentSizeRange', + name: 'Content Size (range)', + enabled: true, + component: { + selector: 'number-range', + settings: { + field: 'cm:content.size', + format: '[{FROM} TO {TO}]' } } }, { - 'id': 'createdDateRange', - 'name': 'Created Date (range)', - 'enabled': true, - 'component': { - 'selector': 'date-range', - 'settings': { - 'field': 'cm:created', - 'dateFormat': 'DD-MMM-YY' + id: 'createdDateRange', + name: 'Created Date (range)', + enabled: true, + component: { + selector: 'date-range', + settings: { + field: 'cm:created', + dateFormat: 'DD-MMM-YY' } } }, { - 'id': 'queryType', - 'name': 'Type', - 'enabled': true, - 'component': { - 'selector': 'radio', - 'settings': { - 'field': null, - 'pageSize': 5, - 'options': [] + id: 'queryType', + name: 'Type', + enabled: true, + component: { + selector: 'radio', + settings: { + field: null, + pageSize: 5, + options: [] } } } @@ -396,119 +396,119 @@ export const searchFilter = { }; export const mockSearchResult = { - 'list': { - 'pagination': { 'count': 20, 'hasMoreItems': true, 'totalItems': 20284, 'skipCount': 0, 'maxItems': 20 }, - 'context': { - 'consistency': { 'lastTxId': 122854 }, - 'facets': [ + list: { + pagination: { count: 20, hasMoreItems: true, totalItems: 20284, skipCount: 0, maxItems: 20 }, + context: { + consistency: { lastTxId: 122854 }, + facets: [ { - 'type': 'query', - 'label': 'Type facet queries', - 'buckets': [ + type: 'query', + label: 'Type facet queries', + buckets: [ { - 'label': 'SEARCH.FACET_QUERIES.MIMETYPE', - 'filterQuery': 'content.mimetype:text/html', - 'metrics': [{ 'type': 'count', 'value': { 'count': 13 } }] + label: 'SEARCH.FACET_QUERIES.MIMETYPE', + filterQuery: 'content.mimetype:text/html', + metrics: [{ type: 'count', value: { count: 13 } }] }] }, { - 'type': 'query', - 'label': 'Size facet queries', - 'buckets': [ + type: 'query', + label: 'Size facet queries', + buckets: [ { - 'label': 'my1', - 'filterQuery': 'content.size:[111111 TO MAX]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 806 } }] + label: 'my1', + filterQuery: 'content.size:[111111 TO MAX]', + metrics: [{ type: 'count', value: { count: 806 } }] }, { - 'label': 'my3', - 'filterQuery': 'content.size:[333333 TO MAX]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 669 } }] + label: 'my3', + filterQuery: 'content.size:[333333 TO MAX]', + metrics: [{ type: 'count', value: { count: 669 } }] }, { - 'label': 'my2', - 'filterQuery': 'content.size:[222222 TO MAX]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 691 } }] + label: 'my2', + filterQuery: 'content.size:[222222 TO MAX]', + metrics: [{ type: 'count', value: { count: 691 } }] }, { - 'label': 'my5', - 'filterQuery': 'content.size:[5555 TO MAX]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 1866 } }] + label: 'my5', + filterQuery: 'content.size:[5555 TO MAX]', + metrics: [{ type: 'count', value: { count: 1866 } }] }, { - 'label': 'my4', - 'filterQuery': 'content.size:[444444 TO MAX]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 665 } }] + label: 'my4', + filterQuery: 'content.size:[444444 TO MAX]', + metrics: [{ type: 'count', value: { count: 665 } }] }, { - 'label': 'my7', - 'filterQuery': 'content.size:[777777 TO MAX]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 641 } }] + label: 'my7', + filterQuery: 'content.size:[777777 TO MAX]', + metrics: [{ type: 'count', value: { count: 641 } }] }, { - 'label': 'SEARCH.FACET_QUERIES.SMALL', - 'filterQuery': 'content.size:[10240 TO 102400]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 526 } }] + label: 'SEARCH.FACET_QUERIES.SMALL', + filterQuery: 'content.size:[10240 TO 102400]', + metrics: [{ type: 'count', value: { count: 526 } }] }, { - 'label': 'my6', - 'filterQuery': 'content.size:[666666 TO MAX]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 652 } }] + label: 'my6', + filterQuery: 'content.size:[666666 TO MAX]', + metrics: [{ type: 'count', value: { count: 652 } }] }, { - 'label': 'SEARCH.FACET_QUERIES.XTRALARGE', - 'filterQuery': 'content.size:[16777216 TO 134217728]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 617 } }] + label: 'SEARCH.FACET_QUERIES.XTRALARGE', + filterQuery: 'content.size:[16777216 TO 134217728]', + metrics: [{ type: 'count', value: { count: 617 } }] }, { - 'label': 'my8', - 'filterQuery': 'content.size:[888888 TO MAX]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 641 } }] + label: 'my8', + filterQuery: 'content.size:[888888 TO MAX]', + metrics: [{ type: 'count', value: { count: 641 } }] }, { - 'label': 'SEARCH.FACET_QUERIES.XXTRALARGE', - 'filterQuery': 'content.size:[134217728 TO MAX]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 0 } }] + label: 'SEARCH.FACET_QUERIES.XXTRALARGE', + filterQuery: 'content.size:[134217728 TO MAX]', + metrics: [{ type: 'count', value: { count: 0 } }] }, { - 'label': 'SEARCH.FACET_QUERIES.MEDIUM', - 'filterQuery': 'content.size:[102400 TO 1048576]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 630 } }] + label: 'SEARCH.FACET_QUERIES.MEDIUM', + filterQuery: 'content.size:[102400 TO 1048576]', + metrics: [{ type: 'count', value: { count: 630 } }] }, { - 'label': 'SEARCH.FACET_QUERIES.LARGE', - 'filterQuery': 'content.size:[1048576 TO 16777216]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 23 } }] + label: 'SEARCH.FACET_QUERIES.LARGE', + filterQuery: 'content.size:[1048576 TO 16777216]', + metrics: [{ type: 'count', value: { count: 23 } }] }, { - 'label': 'Extra Small', - 'filterQuery': 'content.size:[0 TO 10240]', - 'metrics': [{ 'type': 'count', 'value': { 'count': 10239 } }] + label: 'Extra Small', + filterQuery: 'content.size:[0 TO 10240]', + metrics: [{ type: 'count', value: { count: 10239 } }] }] }, { - 'type': 'query', - 'label': 'SEARCH.FACET_QUERIES.MY_FACET_QUERIES', - 'buckets': [ + type: 'query', + label: 'SEARCH.FACET_QUERIES.MY_FACET_QUERIES', + buckets: [ { - 'label': 'SEARCH.FACET_QUERIES.CREATED_THIS_YEAR', - 'filterQuery': 'created:2019', - 'metrics': [{ 'type': 'count', 'value': { 'count': 0 } }] + label: 'SEARCH.FACET_QUERIES.CREATED_THIS_YEAR', + filterQuery: 'created:2019', + metrics: [{ type: 'count', value: { count: 0 } }] }] }, { - 'type': 'field', - 'label': 'SEARCH.FACET_FIELDS.SIZE', - 'buckets': [] + type: 'field', + label: 'SEARCH.FACET_FIELDS.SIZE', + buckets: [] }, { - 'type': 'field', - 'label': 'SEARCH.FACET_FIELDS.CREATED', - 'buckets': [] + type: 'field', + label: 'SEARCH.FACET_FIELDS.CREATED', + buckets: [] }, { - 'type': 'field', - 'label': 'SEARCH.FACET_FIELDS.TYPE', - 'buckets': [] + type: 'field', + label: 'SEARCH.FACET_FIELDS.TYPE', + buckets: [] }, { - 'type': 'field', - 'label': 'SEARCH.FACET_FIELDS.MODIFIER', - 'buckets': [] + type: 'field', + label: 'SEARCH.FACET_FIELDS.MODIFIER', + buckets: [] }, { - 'type': 'field', - 'label': 'SEARCH.FACET_FIELDS.CREATOR', - 'buckets': [] + type: 'field', + label: 'SEARCH.FACET_FIELDS.CREATOR', + buckets: [] }, { - 'type': 'interval', - 'label': 'TheModified', - 'buckets': [] + type: 'interval', + label: 'TheModified', + buckets: [] }, { - 'type': 'interval', - 'label': 'The Created', - 'buckets': [] + type: 'interval', + label: 'The Created', + buckets: [] }] } } @@ -553,56 +553,56 @@ export const stepThree = [ export const sizeOptions = [ { - 'name': 'Extra Small (10239)', - 'value': 'Extra Small (10239)' + name: 'Extra Small (10239)', + value: 'Extra Small (10239)' }, { - 'name': 'SEARCH.FACET_QUERIES.SMALL (526)', - 'value': 'SEARCH.FACET_QUERIES.SMALL (526)' + name: 'SEARCH.FACET_QUERIES.SMALL (526)', + value: 'SEARCH.FACET_QUERIES.SMALL (526)' }, { - 'name': 'SEARCH.FACET_QUERIES.MEDIUM (630)', - 'value': 'SEARCH.FACET_QUERIES.MEDIUM (630)' + name: 'SEARCH.FACET_QUERIES.MEDIUM (630)', + value: 'SEARCH.FACET_QUERIES.MEDIUM (630)' }, { - 'name': 'SEARCH.FACET_QUERIES.LARGE (23)', - 'value': 'SEARCH.FACET_QUERIES.LARGE (23)' + name: 'SEARCH.FACET_QUERIES.LARGE (23)', + value: 'SEARCH.FACET_QUERIES.LARGE (23)' }, { - 'name': 'SEARCH.FACET_QUERIES.XTRALARGE (617)', - 'value': 'SEARCH.FACET_QUERIES.XTRALARGE (617)' + name: 'SEARCH.FACET_QUERIES.XTRALARGE (617)', + value: 'SEARCH.FACET_QUERIES.XTRALARGE (617)' }, { - 'name': 'my1 (806)', - 'group': 'my1 (806)' + name: 'my1 (806)', + group: 'my1 (806)' }, { - 'name': 'my2 (691)', - 'value': 'my2 (691)' + name: 'my2 (691)', + value: 'my2 (691)' }, { - 'name': 'my3 (669)', - 'value': 'my3 (669)' + name: 'my3 (669)', + value: 'my3 (669)' }, { - 'name': 'my4 (665)', - 'value': 'my4 (665)' + name: 'my4 (665)', + value: 'my4 (665)' }, { - 'name': 'my5 (1866)', - 'group': 'my5 (1866)' + name: 'my5 (1866)', + group: 'my5 (1866)' }, { - 'name': 'my6 (652)', - 'group': 'my6 (652)' + name: 'my6 (652)', + group: 'my6 (652)' }, { - 'name': 'my7 (641)', - 'value': 'my7 (641)' + name: 'my7 (641)', + value: 'my7 (641)' }, { - 'name': 'my8 (641)', - 'value': 'my8 (641)' + name: 'my8 (641)', + value: 'my8 (641)' } ]; @@ -615,20 +615,20 @@ export const filteredResult = [ ]; export const mockContentSizeResponseBucket = { - 'label': '5875', - 'filterQuery': 'content.size:5875', - 'metrics': [ + label: '5875', + filterQuery: 'content.size:5875', + metrics: [ { - 'type': 'count', - 'value': { - 'count': 364 + type: 'count', + value: { + count: 364 } } ] }; -export function getMockSearchResultWithResponseBucket() { +export const getMockSearchResultWithResponseBucket = () => { const cloneResult = JSON.parse(JSON.stringify( mockSearchResult)); cloneResult.list.context.facets[3].buckets.push(mockContentSizeResponseBucket); return cloneResult; -} +}; diff --git a/lib/content-services/src/lib/mock/search-query.mock.ts b/lib/content-services/src/lib/mock/search-query.mock.ts index 9355c980c02..34e02cc292c 100644 --- a/lib/content-services/src/lib/mock/search-query.mock.ts +++ b/lib/content-services/src/lib/mock/search-query.mock.ts @@ -17,7 +17,7 @@ import { QueryBody } from '@alfresco/js-api'; -export const mockQueryBody: QueryBody = { +export const mockQueryBody: QueryBody = { query: { query: '(search-term*)', language: 'afts' @@ -38,4 +38,4 @@ export const mockQueryBody: QueryBody = { }, highlight: null, facetFormat: 'V2' -}; +} as QueryBody; diff --git a/lib/content-services/src/lib/mock/search.component.mock.ts b/lib/content-services/src/lib/mock/search.component.mock.ts index 385e4bffc68..13d254aad5a 100644 --- a/lib/content-services/src/lib/mock/search.component.mock.ts +++ b/lib/content-services/src/lib/mock/search.component.mock.ts @@ -53,7 +53,7 @@ const entryDifferentItem = { } }; -export let result = new ResultSetPaging({ +export const result = new ResultSetPaging({ list: { entries: [ entryItem @@ -61,7 +61,7 @@ export let result = new ResultSetPaging({ } }); -export let differentResult = new ResultSetPaging({ +export const differentResult = new ResultSetPaging({ list: { entries: [ entryDifferentItem @@ -69,7 +69,7 @@ export let differentResult = new ResultSetPaging({ } }); -export let results = { +export const results = { list: { entries: [ entryItem, @@ -79,7 +79,7 @@ export let results = { } }; -export let folderResult = { +export const folderResult = { list: { entries: [ { @@ -100,13 +100,13 @@ export let folderResult = { } }; -export let noResult = { +export const noResult = { list: { entries: [] } }; -export let errorJson = { +export const errorJson = { error: { errorKey: 'Search failed', statusCode: 400, diff --git a/lib/content-services/src/lib/mock/search.service.mock.ts b/lib/content-services/src/lib/mock/search.service.mock.ts index 8f2286b9f13..92f3f01716b 100644 --- a/lib/content-services/src/lib/mock/search.service.mock.ts +++ b/lib/content-services/src/lib/mock/search.service.mock.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export let fakeSearch = { +export const fakeSearch = { list: { pagination: { count: 1, @@ -44,7 +44,7 @@ export let fakeSearch = { } }; -export let mockError = { +export const mockError = { error: { errorKey: 'Search failed', statusCode: 400, @@ -54,7 +54,7 @@ export let mockError = { } }; -export let searchMockApi = { +export const searchMockApi = { core: { queriesApi: { findNodes: () => Promise.resolve(fakeSearch) diff --git a/lib/content-services/src/lib/mock/sites-dropdown.component.mock.ts b/lib/content-services/src/lib/mock/sites-dropdown.component.mock.ts index ebd1165a2f0..2c4bfcf2872 100644 --- a/lib/content-services/src/lib/mock/sites-dropdown.component.mock.ts +++ b/lib/content-services/src/lib/mock/sites-dropdown.component.mock.ts @@ -18,276 +18,266 @@ import { SitePaging } from '@alfresco/js-api'; /* We are using functions instead of constants here to pass a new instance of the object each time */ -export function getFakeSitePaging(): SitePaging { - return { - 'list': { - 'pagination': { - 'count': 2, - 'hasMoreItems': true, - 'totalItems': 2, - 'skipCount': 0, - 'maxItems': 100 +export const getFakeSitePaging = (): SitePaging => ({ + list: { + pagination: { + count: 2, + hasMoreItems: true, + totalItems: 2, + skipCount: 0, + maxItems: 100 + }, + entries: [ + { + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'fake-1', + description: 'fake-test-site', + id: 'fake-test-site', + preset: 'site-dashboard', + title: 'fake-test-site' + } }, - 'entries': [ - { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'fake-1', - 'description': 'fake-test-site', - 'id': 'fake-test-site', - 'preset': 'site-dashboard', - 'title': 'fake-test-site' - } - }, - { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'fake-2', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'swsdp', - 'preset': 'site-dashboard', - 'title': 'fake-test-2' - } + { + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'fake-2', + description: 'This is a Sample Alfresco Team site.', + id: 'swsdp', + preset: 'site-dashboard', + title: 'fake-test-2' } - ] - } - }; -} + } + ] + } +}); -export function getFakeSitePagingNoMoreItems(): SitePaging { - return { - 'list': { - 'pagination': { - 'count': 2, - 'hasMoreItems': false, - 'totalItems': 2, - 'skipCount': 0, - 'maxItems': 100 +export const getFakeSitePagingNoMoreItems = (): SitePaging => ({ + list: { + pagination: { + count: 2, + hasMoreItems: false, + totalItems: 2, + skipCount: 0, + maxItems: 100 + }, + entries: [ + { + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'fake-1', + description: 'fake-test-site', + id: 'fake-test-site', + preset: 'site-dashboard', + title: 'fake-test-site' + } }, - 'entries': [ - { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'fake-1', - 'description': 'fake-test-site', - 'id': 'fake-test-site', - 'preset': 'site-dashboard', - 'title': 'fake-test-site' - } - }, - { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'fake-2', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'swsdp', - 'preset': 'site-dashboard', - 'title': 'fake-test-2' - } + { + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'fake-2', + description: 'This is a Sample Alfresco Team site.', + id: 'swsdp', + preset: 'site-dashboard', + title: 'fake-test-2' } - ] - } - }; -} + } + ] + } +}); -export function getFakeSitePagingFirstPage(): SitePaging { - return { - 'list': { - 'pagination': { - 'count': 2, - 'hasMoreItems': true, - 'totalItems': 2, - 'skipCount': 0, - 'maxItems': 4 +export const getFakeSitePagingFirstPage = (): SitePaging => ({ + list: { + pagination: { + count: 2, + hasMoreItems: true, + totalItems: 2, + skipCount: 0, + maxItems: 4 + }, + entries: [ + { + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'fake-1', + description: 'fake-test-site', + id: 'fake-test-site', + preset: 'site-dashboard', + title: 'fake-test-site' + } }, - 'entries': [ - { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'fake-1', - 'description': 'fake-test-site', - 'id': 'fake-test-site', - 'preset': 'site-dashboard', - 'title': 'fake-test-site' - } - }, - { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'fake-2', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'swsdp', - 'preset': 'site-dashboard', - 'title': 'fake-test-2' - } + { + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'fake-2', + description: 'This is a Sample Alfresco Team site.', + id: 'swsdp', + preset: 'site-dashboard', + title: 'fake-test-2' } - ] - } - }; -} + } + ] + } +}); -export function getFakeSitePagingLastPage(): SitePaging { - return { - 'list': { - 'pagination': { - 'count': 4, - 'hasMoreItems': false, - 'totalItems': 2, - 'skipCount': 2, - 'maxItems': 4 +export const getFakeSitePagingLastPage = (): SitePaging => ({ + list: { + pagination: { + count: 4, + hasMoreItems: false, + totalItems: 2, + skipCount: 2, + maxItems: 4 + }, + entries: [ + { + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'fake-3', + description: 'fake-test-3', + id: 'fake-test-3', + preset: 'site-dashboard', + title: 'fake-test-3' + } }, - 'entries': [ - { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'fake-3', - 'description': 'fake-test-3', - 'id': 'fake-test-3', - 'preset': 'site-dashboard', - 'title': 'fake-test-3' - } - }, - { - 'entry': { - 'role': 'SiteManager', - 'visibility': 'PUBLIC', - 'guid': 'fake-test-4', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'fake-test-4', - 'preset': 'site-dashboard', - 'title': 'fake-test-4' - } + { + entry: { + role: 'SiteManager', + visibility: 'PUBLIC', + guid: 'fake-test-4', + description: 'This is a Sample Alfresco Team site.', + id: 'fake-test-4', + preset: 'site-dashboard', + title: 'fake-test-4' } - ] - } - }; -} + } + ] + } +}); -export function getFakeSitePagingWithMembers() { - return new SitePaging({ - 'list': { - 'entries': [{ - 'entry': { - 'visibility': 'MODERATED', - 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'MODERATED-SITE', - 'preset': 'site-dashboard', - 'title': 'FAKE-MODERATED-SITE' - }, - 'relations': { - 'members': { - 'list': { - 'pagination': { - 'count': 3, - 'hasMoreItems': false, - 'skipCount': 0, - 'maxItems': 100 +export const getFakeSitePagingWithMembers = () => new SitePaging({ + list: { + entries: [{ + entry: { + visibility: 'MODERATED', + guid: 'b4cff62a-664d-4d45-9302-98723eac1319', + description: 'This is a Sample Alfresco Team site.', + id: 'MODERATED-SITE', + preset: 'site-dashboard', + title: 'FAKE-MODERATED-SITE' + }, + relations: { + members: { + list: { + pagination: { + count: 3, + hasMoreItems: false, + skipCount: 0, + maxItems: 100 + }, + entries: [ + { + entry: { + role: 'SiteManager', + person: { + firstName: 'Administrator', + emailNotificationsEnabled: true, + company: {}, + id: 'admin', + enabled: true, + email: 'admin@alfresco.com' + }, + id: 'admin' + } }, - 'entries': [ - { - 'entry': { - 'role': 'SiteManager', - 'person': { - 'firstName': 'Administrator', - 'emailNotificationsEnabled': true, - 'company': {}, - 'id': 'admin', - 'enabled': true, - 'email': 'admin@alfresco.com' + { + entry: { + role: 'SiteCollaborator', + person: { + lastName: 'Beecher', + userStatus: 'Helping to design the look and feel of the new web site', + jobTitle: 'Graphic Designer', + statusUpdatedAt: '2011-02-15T20:20:13.432+0000', + mobile: '0112211001100', + emailNotificationsEnabled: true, + description: 'Alice is a demo user for the sample Alfresco Team site.', + telephone: '0112211001100', + enabled: false, + firstName: 'Alice', + skypeId: 'abeecher', + avatarId: '198500fc-1e99-4f5f-8926-248cea433366', + location: 'Tilbury, UK', + company: { + organization: 'Moresby, Garland and Wedge', + address1: '200 Butterwick Street', + address2: 'Tilbury', + address3: 'UK', + postcode: 'ALF1 SAM1' }, - 'id': 'admin' - } - }, - { - 'entry': { - 'role': 'SiteCollaborator', - 'person': { - 'lastName': 'Beecher', - 'userStatus': 'Helping to design the look and feel of the new web site', - 'jobTitle': 'Graphic Designer', - 'statusUpdatedAt': '2011-02-15T20:20:13.432+0000', - 'mobile': '0112211001100', - 'emailNotificationsEnabled': true, - 'description': 'Alice is a demo user for the sample Alfresco Team site.', - 'telephone': '0112211001100', - 'enabled': false, - 'firstName': 'Alice', - 'skypeId': 'abeecher', - 'avatarId': '198500fc-1e99-4f5f-8926-248cea433366', - 'location': 'Tilbury, UK', - 'company': { - 'organization': 'Moresby, Garland and Wedge', - 'address1': '200 Butterwick Street', - 'address2': 'Tilbury', - 'address3': 'UK', - 'postcode': 'ALF1 SAM1' - }, - 'id': 'abeecher', - 'email': 'abeecher@example.com' - }, - 'id': 'abeecher' - } + id: 'abeecher', + email: 'abeecher@example.com' + }, + id: 'abeecher' } - ] - } + } + ] } } - }, { - 'entry': { - 'visibility': 'PUBLIC', - 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'PUBLIC-SITE', - 'preset': 'site-dashboard', - 'title': 'FAKE-SITE-PUBLIC' - } - }, { - 'entry': { - 'visibility': 'PRIVATE', - 'guid': 'b4cff62a-664d-4d45-9302-98723eac1319', - 'description': 'This is a Sample Alfresco Team site.', - 'id': 'MEMBER-SITE', - 'preset': 'site-dashboard', - 'title': 'FAKE-PRIVATE-SITE-MEMBER' - }, - 'relations': { - 'members': { - 'list': { - 'pagination': { - 'count': 3, - 'hasMoreItems': false, - 'skipCount': 0, - 'maxItems': 100 - }, - 'entries': [ - { - 'entry': { - 'role': 'SiteManager', - 'person': { - 'firstName': 'Administrator', - 'emailNotificationsEnabled': true, - 'company': {}, - 'id': 'admin', - 'enabled': true, - 'email': 'admin@alfresco.com' - }, - 'id': 'test' - } + } + }, { + entry: { + visibility: 'PUBLIC', + guid: 'b4cff62a-664d-4d45-9302-98723eac1319', + description: 'This is a Sample Alfresco Team site.', + id: 'PUBLIC-SITE', + preset: 'site-dashboard', + title: 'FAKE-SITE-PUBLIC' + } + }, { + entry: { + visibility: 'PRIVATE', + guid: 'b4cff62a-664d-4d45-9302-98723eac1319', + description: 'This is a Sample Alfresco Team site.', + id: 'MEMBER-SITE', + preset: 'site-dashboard', + title: 'FAKE-PRIVATE-SITE-MEMBER' + }, + relations: { + members: { + list: { + pagination: { + count: 3, + hasMoreItems: false, + skipCount: 0, + maxItems: 100 + }, + entries: [ + { + entry: { + role: 'SiteManager', + person: { + firstName: 'Administrator', + emailNotificationsEnabled: true, + company: {}, + id: 'admin', + enabled: true, + email: 'admin@alfresco.com' + }, + id: 'test' } - ] - } + } + ] } } } - ] } - }); -} + ] + } +}); diff --git a/lib/content-services/src/lib/mock/upload.service.mock.ts b/lib/content-services/src/lib/mock/upload.service.mock.ts index 280ddac86db..cd9ba0ebcd8 100644 --- a/lib/content-services/src/lib/mock/upload.service.mock.ts +++ b/lib/content-services/src/lib/mock/upload.service.mock.ts @@ -16,42 +16,42 @@ */ export const mockUploadSuccessPromise = { - on: function (event, callback) { + on(event, callback) { if (event === 'success') { callback(); } return this; }, - catch: function (callback) { + catch(callback) { callback(); return this; }, - then: function (callback) { + then(callback) { callback(); return this; }, - next: function (callback) { + next(callback) { callback(); return this; } }; export const mockUploadErrorPromise = { - on: function (event, callback) { + on(event, callback) { if (event === 'error') { callback(); } return this; }, - catch: function (callback) { + catch(callback) { callback(); return this; }, - then: function (callback) { + then(callback) { callback(); return this; }, - next: function (callback) { + next(callback) { callback(); return this; } diff --git a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-dialog.component.spec.ts b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-dialog.component.spec.ts index c4cfc165ecd..aa75df14899 100644 --- a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-dialog.component.spec.ts +++ b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-dialog.component.spec.ts @@ -100,7 +100,7 @@ describe('AddPermissionDialog', () => { expect(confirmButton.disabled).toBeTruthy(); }); - it('should enable the button when a selection is done', async() => { + it('should enable the button when a selection is done', async () => { const addPermissionPanelComponent: AddPermissionPanelComponent = fixture.debugElement.query(By.directive(AddPermissionPanelComponent)).componentInstance; addPermissionPanelComponent.select.emit(fakeAuthorityResults); let confirmButton = element.querySelector('[data-automation-id="add-permission-dialog-confirm-button"]'); @@ -244,7 +244,7 @@ describe('AddPermissionDialog', () => { confirmButton.click(); }); - it('should stream the confirmed selection on the confirm subject', async() => { + it('should stream the confirmed selection on the confirm subject', async () => { const addPermissionPanelComponent: AddPermissionPanelComponent = fixture.debugElement.query(By.directive(AddPermissionPanelComponent)).componentInstance; addPermissionPanelComponent.select.emit(fakeAuthorityResults); data.confirm.subscribe((selection) => { diff --git a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-dialog.component.ts b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-dialog.component.ts index 4ec5a90667f..e7b926babf5 100644 --- a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-dialog.component.ts +++ b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-dialog.component.ts @@ -96,8 +96,8 @@ export class AddPermissionDialogComponent { } onMemberUpdate(role: string, member: MemberModel) { - const _member = this.selectedMembers.find(({ id }) => id === member.id); - _member.role = role; + const memberInstance = this.selectedMembers.find(({ id }) => id === member.id); + memberInstance.role = role; } isValid(): boolean { diff --git a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-panel.component.spec.ts b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-panel.component.spec.ts index 619a1945b95..eacc2eda898 100644 --- a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-panel.component.spec.ts +++ b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-panel.component.spec.ts @@ -55,12 +55,12 @@ describe('AddPermissionPanelComponent', () => { fixture.destroy(); }); - function typeWordIntoSearchInput(word: string): void { + const typeWordIntoSearchInput = (word: string): void => { const inputDebugElement = debugElement.query(By.css('#searchInput')); inputDebugElement.nativeElement.value = word; inputDebugElement.nativeElement.focus(); inputDebugElement.nativeElement.dispatchEvent(new Event('input')); - } + }; it('should be able to render the component', () => { expect(element.querySelector('#adf-add-permission-type-search')).not.toBeNull(); diff --git a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-panel.component.ts b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-panel.component.ts index 5420568b0fa..988a5532833 100644 --- a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-panel.component.ts +++ b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission-panel.component.ts @@ -52,6 +52,7 @@ export class AddPermissionPanelComponent { selectedItems: NodeEntry[] = []; + // eslint-disable-next-line @typescript-eslint/naming-convention EVERYONE: NodeEntry = new NodeEntry({ entry: { nodeType: 'cm:authorityContainer', properties: {'cm:authorityName': 'GROUP_EVERYONE'}}}); constructor() { diff --git a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission.component.spec.ts b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission.component.spec.ts index 8fdaad287db..69832a3a426 100644 --- a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission.component.spec.ts +++ b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission.component.spec.ts @@ -57,7 +57,7 @@ describe('AddPermissionComponent', () => { expect(element.querySelector('#adf-add-permission-type-search')).not.toBeNull(); expect(element.querySelector('#searchInput')).not.toBeNull(); expect(element.querySelector('#adf-add-permission-actions')).not.toBeNull(); - const addButton: HTMLButtonElement = element.querySelector('#adf-add-permission-action-button'); + const addButton = element.querySelector('#adf-add-permission-action-button'); expect(addButton.disabled).toBeTruthy(); }); diff --git a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission.component.ts b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission.component.ts index f36de1b5c06..5e3570f4220 100644 --- a/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission.component.ts +++ b/lib/content-services/src/lib/permission-manager/components/add-permission/add-permission.component.ts @@ -81,12 +81,10 @@ export class AddPermissionComponent implements OnInit { } private transformNodeToPermissionElement(nodes: NodeEntry[], role: string): PermissionElement[] { - return nodes.map((node) => { - return { - 'authorityId': node.entry.properties['cm:authorityName'] ?? node.entry.properties['cm:userName'], - 'name': role, - 'accessStatus': 'ALLOWED' - }; - }); + return nodes.map((node) => ({ + authorityId: node.entry.properties['cm:authorityName'] ?? node.entry.properties['cm:userName'], + name: role, + accessStatus: 'ALLOWED' + })); } } diff --git a/lib/content-services/src/lib/permission-manager/components/add-permission/search-config-permission.service.ts b/lib/content-services/src/lib/permission-manager/components/add-permission/search-config-permission.service.ts index f0646783e15..fc5f7efd8ce 100644 --- a/lib/content-services/src/lib/permission-manager/components/add-permission/search-config-permission.service.ts +++ b/lib/content-services/src/lib/permission-manager/components/add-permission/search-config-permission.service.ts @@ -41,7 +41,7 @@ export class SearchPermissionConfigurationService implements SearchConfiguration include: ['properties', 'aspectNames'], paging: { maxItems: maxResults, - skipCount: skipCount + skipCount }, filterQueries: [ /* eslint-disable-next-line */ diff --git a/lib/content-services/src/lib/permission-manager/components/inherited-button.directive.spec.ts b/lib/content-services/src/lib/permission-manager/components/inherited-button.directive.spec.ts index e4209a4f8ae..e09d311c684 100644 --- a/lib/content-services/src/lib/permission-manager/components/inherited-button.directive.spec.ts +++ b/lib/content-services/src/lib/permission-manager/components/inherited-button.directive.spec.ts @@ -70,7 +70,7 @@ describe('InheritPermissionDirective', () => { fixture.detectChanges(); await fixture.whenStable(); - const buttonPermission: HTMLButtonElement = element.querySelector('#sample-button-permission'); + const buttonPermission = element.querySelector('#sample-button-permission'); expect(buttonPermission).not.toBeNull(); expect(element.querySelector('#update-notification')).toBeNull(); buttonPermission.click(); @@ -95,7 +95,7 @@ describe('InheritPermissionDirective', () => { fixture.detectChanges(); await fixture.whenStable(); - const buttonPermission: HTMLButtonElement = element.querySelector('#sample-button-permission'); + const buttonPermission = element.querySelector('#sample-button-permission'); expect(buttonPermission).not.toBeNull(); expect(element.querySelector('#update-notification')).not.toBeNull(); buttonPermission.click(); @@ -114,7 +114,7 @@ describe('InheritPermissionDirective', () => { fixture.detectChanges(); await fixture.whenStable(); - const buttonPermission: HTMLButtonElement = element.querySelector('#sample-button-permission'); + const buttonPermission = element.querySelector('#sample-button-permission'); expect(buttonPermission).not.toBeNull(); expect(element.querySelector('#update-notification')).not.toBeNull(); buttonPermission.click(); diff --git a/lib/content-services/src/lib/permission-manager/components/inherited-button.directive.ts b/lib/content-services/src/lib/permission-manager/components/inherited-button.directive.ts index e0e00cdd128..4744edad701 100644 --- a/lib/content-services/src/lib/permission-manager/components/inherited-button.directive.ts +++ b/lib/content-services/src/lib/permission-manager/components/inherited-button.directive.ts @@ -23,7 +23,7 @@ import { Node } from '@alfresco/js-api'; @Directive({ selector: 'button[adf-inherit-permission], mat-button-toggle[adf-inherit-permission]', host: { - 'role': 'button', + role: 'button', '(click)': 'onInheritPermissionClicked()' } }) diff --git a/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.component.spec.ts b/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.component.spec.ts index a4d6129d1e1..0aa7ece7e34 100644 --- a/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.component.spec.ts +++ b/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.component.spec.ts @@ -114,7 +114,7 @@ describe('PermissionListComponent', () => { }); describe('Inherited Permission', () => { - it('should show inherited details', async() => { + it('should show inherited details', async () => { getNodeSpy.and.returnValue(of(fakeNodeInheritedOnly)); component.ngOnInit(); @@ -191,7 +191,7 @@ describe('PermissionListComponent', () => { getNodeSpy.and.returnValue(of(fakeLocalPermission)); }); - it('should show locally set permissions', async() => { + it('should show locally set permissions', async () => { searchQuerySpy.and.returnValue(of(fakeSiteNodeResponse)); component.ngOnInit(); @@ -202,7 +202,7 @@ describe('PermissionListComponent', () => { expect(element.querySelector('#adf-select-role-permission').textContent).toContain('Contributor'); }); - it('should see the settable roles if the node is not in any site', async() => { + it('should see the settable roles if the node is not in any site', async () => { searchQuerySpy.and.returnValue(of(fakeSiteNodeResponse)); component.ngOnInit(); @@ -225,7 +225,7 @@ describe('PermissionListComponent', () => { expect(options[3].nativeElement.innerText).toContain('ADF.ROLES.SITEMANAGER'); }); - it('should show readonly member for site manager to toggle the inherit permission', async() => { + it('should show readonly member for site manager to toggle the inherit permission', async () => { getNodeSpy.and.returnValue(of(fakeNodeLocalSiteManager)); component.ngOnInit(); diff --git a/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.service.spec.ts b/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.service.spec.ts index bfbcd9c6c68..e79fb5e9153 100644 --- a/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.service.spec.ts +++ b/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.service.spec.ts @@ -110,9 +110,9 @@ describe('PermissionListService', () => { const event = { source: { checked: false } }; const updateNode = JSON.parse(JSON.stringify(fakeNodeInheritedOnly)); node.permissions.locallySet = [{ - 'authorityId': 'GROUP_site_testsite_SiteManager', - 'name': 'SiteManager', - 'accessStatus': 'ALLOWED' + authorityId: 'GROUP_site_testsite_SiteManager', + name: 'SiteManager', + accessStatus: 'ALLOWED' }]; updateNode.permissions.isInheritanceEnabled = false; spyOn(nodePermissionService, 'getNodeWithRoles').and.returnValue(of({node , roles: []})); diff --git a/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.service.ts b/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.service.ts index 08cd470b496..9afaf593656 100644 --- a/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.service.ts +++ b/lib/content-services/src/lib/permission-manager/components/permission-list/permission-list.service.ts @@ -27,6 +27,8 @@ import { NodePermissionsModel } from '../../models/member.model'; import { NodePermissionService } from '../../services/node-permission.service'; import { NodePermissionDialogService } from '../../services/node-permission-dialog.service'; +const SITE_MANAGER_ROLE = 'SiteManager'; + @Injectable({ providedIn: 'root' }) @@ -52,7 +54,6 @@ export class PermissionListService { private node: Node; private roles: RoleModel[]; - private SITE_MANAGER_ROLE = 'SiteManager'; constructor( private nodeService: NodesApiService, @@ -89,7 +90,7 @@ export class PermissionListService { if (authorityId) { const permissions = [ ...(this.node.permissions.locallySet || []), - { authorityId, name: this.SITE_MANAGER_ROLE, accessStatus: 'ALLOWED' } + { authorityId, name: SITE_MANAGER_ROLE, accessStatus: 'ALLOWED' } ]; updateLocalPermission$ = this.nodePermissionService.updatePermissions(this.node, permissions); } @@ -223,8 +224,8 @@ export class PermissionListService { let hasLocalManagerPermission = false; let authorityId: string; if (sitePath) { - authorityId = `GROUP_site_${sitePath.name}_${this.SITE_MANAGER_ROLE}`; - hasLocalManagerPermission = !!node.permissions.locallySet?.find((permission) => permission.authorityId === authorityId && permission.name === this.SITE_MANAGER_ROLE); + authorityId = `GROUP_site_${sitePath.name}_${SITE_MANAGER_ROLE}`; + hasLocalManagerPermission = !!node.permissions.locallySet?.find((permission) => permission.authorityId === authorityId && permission.name === SITE_MANAGER_ROLE); } if (!hasLocalManagerPermission && authorityId) { @@ -245,8 +246,8 @@ export class PermissionListService { canUpdateThePermission(node: Node, permission: PermissionElement): boolean { const sitePath = node.path.elements.find((path) => path.nodeType === 'st:site'); if (!node.permissions.isInheritanceEnabled && sitePath) { - const authorityId = `GROUP_site_${sitePath.name}_${this.SITE_MANAGER_ROLE}`; - return !(permission.authorityId === authorityId && permission.name === this.SITE_MANAGER_ROLE); + const authorityId = `GROUP_site_${sitePath.name}_${SITE_MANAGER_ROLE}`; + return !(permission.authorityId === authorityId && permission.name === SITE_MANAGER_ROLE); } return true; } diff --git a/lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.spec.ts b/lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.spec.ts index 665a47d7dec..472dadd44a0 100644 --- a/lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.spec.ts +++ b/lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.spec.ts @@ -61,7 +61,7 @@ describe('NodePermissionDialogService', () => { let fakePermissionNode = new Node({}); beforeEach(() => { - fakePermissionNode = { id: 'fake-permission-node', allowableOperations: ['updatePermissions']}; + fakePermissionNode = { id: 'fake-permission-node', allowableOperations: ['updatePermissions']} as Node; }); it('should be able to open the dialog showing node permissions', () => { @@ -97,7 +97,7 @@ describe('NodePermissionDialogService', () => { let fakeForbiddenNode = new Node({}); beforeEach(() => { - fakeForbiddenNode = { id: 'fake-permission-node', allowableOperations: ['update']}; + fakeForbiddenNode = { id: 'fake-permission-node', allowableOperations: ['update']} as Node; }); it('should not be able to open the dialog showing node permissions', () => { diff --git a/lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.ts b/lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.ts index b1a26b7b8f4..4edb95c3ba1 100644 --- a/lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.ts +++ b/lib/content-services/src/lib/permission-manager/services/node-permission-dialog.service.ts @@ -38,6 +38,7 @@ export class NodePermissionDialogService { /** * Opens a dialog to add permissions to a node. + * * @param node target node * @param roles settable roles for the node * @param title Dialog title @@ -52,9 +53,9 @@ export class NodePermissionDialogService { }); const data: AddPermissionDialogData = { - node: node, - title: title, - confirm: confirm, + node, + title, + confirm, roles }; @@ -80,6 +81,7 @@ export class NodePermissionDialogService { /** * Opens a dialog to update permissions for a node. + * * @param nodeId ID of the target node * @param title Dialog title * @returns Node with updated permissions @@ -87,14 +89,10 @@ export class NodePermissionDialogService { updateNodePermissionByDialog(nodeId?: string, title?: string): Observable { return this.nodePermissionService.getNodeWithRoles(nodeId) .pipe( - switchMap(({node, roles}) => { - return this.openAddPermissionDialog(node, roles, title) - .pipe( - switchMap((selection) => { - return this.nodePermissionService.updateNodePermissions(nodeId, selection); - }) - ); - }) + switchMap(({node, roles}) => this.openAddPermissionDialog(node, roles, title) + .pipe( + switchMap((selection) => this.nodePermissionService.updateNodePermissions(nodeId, selection)) + )) ); } } diff --git a/lib/content-services/src/lib/permission-manager/services/node-permission.service.spec.ts b/lib/content-services/src/lib/permission-manager/services/node-permission.service.spec.ts index 6f0b443c5bb..d52b43909d1 100644 --- a/lib/content-services/src/lib/permission-manager/services/node-permission.service.spec.ts +++ b/lib/content-services/src/lib/permission-manager/services/node-permission.service.spec.ts @@ -62,12 +62,10 @@ describe('NodePermissionService', () => { nodeService = TestBed.inject(NodesApiService); }); - function returnUpdatedNode(nodeBody: Node) { - return of(new Node({ - id: 'fake-updated-node', - permissions: nodeBody.permissions - })); - } + const returnUpdatedNode = (nodeBody: Node) => of(new Node({ + id: 'fake-updated-node', + permissions: nodeBody.permissions + })); it('should return a list of roles taken from the site groups', (done) => { spyOn(searchApiService, 'searchByQueryBody').and.returnValue(of(fakeSiteNodeResponse)); @@ -95,9 +93,9 @@ describe('NodePermissionService', () => { it('should be able to update a locally set permission role', (done) => { const fakeAccessStatus: any = 'DENIED'; const fakePermission: PermissionElement = { - 'authorityId': 'GROUP_EVERYONE', - 'name': 'Contributor', - 'accessStatus' : fakeAccessStatus + authorityId: 'GROUP_EVERYONE', + name: 'Contributor', + accessStatus : fakeAccessStatus }; spyOn(nodeService, 'updateNode').and.callFake((_, permissionBody) => returnUpdatedNode(permissionBody)); @@ -114,11 +112,11 @@ describe('NodePermissionService', () => { }); it('should be able to remove a locally set permission', (done) => { - const fakePermission = { - 'authorityId': 'FAKE_PERSON_1', - 'name': 'Contributor', - 'accessStatus' : 'ALLOWED' - }; + const fakePermission = { + authorityId: 'FAKE_PERSON_1', + name: 'Contributor', + accessStatus : 'ALLOWED' + } as PermissionElement; spyOn(nodeService, 'updateNode').and.callFake((_, permissionBody) => returnUpdatedNode(permissionBody)); const fakeNodeCopy = JSON.parse(JSON.stringify(fakeNodeToRemovePermission)); diff --git a/lib/content-services/src/lib/permission-manager/services/node-permission.service.ts b/lib/content-services/src/lib/permission-manager/services/node-permission.service.ts index bb730c9ac72..ccfeab08762 100644 --- a/lib/content-services/src/lib/permission-manager/services/node-permission.service.ts +++ b/lib/content-services/src/lib/permission-manager/services/node-permission.service.ts @@ -56,6 +56,7 @@ export class NodePermissionService { /** * Gets a list of roles for the current node. + * * @param node The target node * @returns Array of strings representing the roles */ @@ -95,6 +96,7 @@ export class NodePermissionService { /** * Updates the permission role for a node. + * * @param node Target node * @param updatedPermissionRole Permission role to update or add * @returns Node with updated permission @@ -113,6 +115,7 @@ export class NodePermissionService { /** * Update permissions for a node. + * * @param nodeId ID of the target node * @param permissionList New permission settings * @returns Node with updated permissions @@ -125,6 +128,7 @@ export class NodePermissionService { /** * Updates the locally set permissions for a node. + * * @param node ID of the target node * @param permissions Permission settings * @returns Node with updated permissions @@ -163,6 +167,7 @@ export class NodePermissionService { /** * Removes a permission setting from a node. + * * @param node ID of the target node * @param permissionToRemove Permission setting to remove * @returns Node with modified permissions @@ -196,6 +201,7 @@ export class NodePermissionService { /** * Gets all members related to a group name. + * * @param groupName Name of group to look for members * @param opts Extra options supported by JS-API * @returns List of members @@ -213,17 +219,17 @@ export class NodePermissionService { const builtPathNames = pathNames.join(' OR '); return { - 'query': { - 'query': builtPathNames + query: { + query: builtPathNames }, - 'paging': { - 'maxItems': 100, - 'skipCount': 0 + paging: { + maxItems: 100, + skipCount: 0 }, - 'include': ['aspectNames', 'properties'], - 'filterQueries': [ + include: ['aspectNames', 'properties'], + filterQueries: [ { - 'query': + query: `TYPE:'st:site'` } ] @@ -257,6 +263,7 @@ export class NodePermissionService { /** * Removes permissions setting from a node. + * * @param node target node with permission * @param permissions Permissions to remove * @returns Node with modified permissions @@ -276,6 +283,7 @@ export class NodePermissionService { /** * updates permissions setting from a node. + * * @param node target node with permission * @param permissions Permissions to update * @returns Node with modified permissions @@ -288,22 +296,21 @@ export class NodePermissionService { /** * Gets all node detail for nodeId along with settable permissions. + * * @param nodeId Id of the node * @returns node and it's associated roles { node: Node; roles: RoleModel[] } */ getNodeWithRoles(nodeId: string): Observable<{ node: Node; roles: RoleModel[] }> { return this.nodeService.getNode(nodeId).pipe( - switchMap(node => { - return forkJoin({ - node: of(node), - roles: this.getNodeRoles(node) - .pipe( - catchError(() => of(node.permissions?.settable)), - map(_roles => _roles.map(role => ({ role, label: role })) - ) + switchMap(node => forkJoin({ + node: of(node), + roles: this.getNodeRoles(node) + .pipe( + catchError(() => of(node.permissions?.settable)), + map(_roles => _roles.map(role => ({ role, label: role })) ) - }); - }) + ) + })) ); } diff --git a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.spec.ts b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.spec.ts index d5381d51bb8..d597c6fdfc6 100644 --- a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.spec.ts @@ -42,10 +42,10 @@ describe('SearchCheckListComponent', () => { it('should setup options from settings', () => { const options: any = [ - { 'name': 'Folder', 'value': `TYPE:'cm:folder'` }, - { 'name': 'Document', 'value': `TYPE:'cm:content'` } + { name: 'Folder', value: `TYPE:'cm:folder'` }, + { name: 'Document', value: `TYPE:'cm:content'` } ]; - component.settings = { options: options }; + component.settings = { options } as any; component.ngOnInit(); expect(component.options.items).toEqual(options); @@ -70,13 +70,13 @@ describe('SearchCheckListComponent', () => { }); it('should setup operator from the settings', () => { - component.settings = { operator: 'AND' }; + component.settings = { operator: 'AND' } as any; component.ngOnInit(); expect(component.operator).toBe('AND'); }); it('should use OR operator by default', () => { - component.settings = { operator: null }; + component.settings = { operator: null } as any; component.ngOnInit(); expect(component.operator).toBe('OR'); }); @@ -88,24 +88,24 @@ describe('SearchCheckListComponent', () => { ]); component.id = 'checklist'; - component.context = { + component.context = { queryFragments: {}, - update() {} - }; + update: () => {} + } as any; component.ngOnInit(); spyOn(component.context, 'update').and.stub(); component.changeHandler( - { checked: true }, + { checked: true } as any, component.options.items[0] ); expect(component.context.queryFragments[component.id]).toEqual(`TYPE:'cm:folder'`); component.changeHandler( - { checked: true }, + { checked: true } as any, component.options.items[1] ); @@ -128,12 +128,12 @@ describe('SearchCheckListComponent', () => { it('should update query builder on reset', () => { component.id = 'checklist'; - component.context = { + component.context = { queryFragments: { - 'checklist': 'query' + checklist: 'query' }, - update() {} - }; + update: () => {} + } as any; spyOn(component.context, 'update').and.stub(); component.ngOnInit(); @@ -151,13 +151,13 @@ describe('SearchCheckListComponent', () => { describe('Pagination', () => { it('should show 5 items when pageSize not defined', () => { component.id = 'checklist'; - component.context = { + component.context = { queryFragments: { - 'checklist': 'query' + checklist: 'query' }, - update() {} - }; - component.settings = { options: sizeOptions }; + update: () => {} + } as any; + component.settings = { options: sizeOptions } as any; component.ngOnInit(); fixture.detectChanges(); @@ -170,13 +170,13 @@ describe('SearchCheckListComponent', () => { it('should show all items when pageSize is high', () => { component.id = 'checklist'; - component.context = { + component.context = { queryFragments: { - 'checklist': 'query' + checklist: 'query' }, - update() {} - }; - component.settings = { pageSize: 15, options: sizeOptions }; + update: () => {} + } as any; + component.settings = { pageSize: 15, options: sizeOptions } as any; component.ngOnInit(); fixture.detectChanges(); @@ -189,13 +189,13 @@ describe('SearchCheckListComponent', () => { it('should able to check/reset the checkbox', () => { component.id = 'checklist'; - component.context = { + component.context = { queryFragments: { - 'checklist': 'query' + checklist: 'query' }, update: () => {} - }; - component.settings = { options: sizeOptions }; + } as any; + component.settings = { options: sizeOptions } as any; spyOn(component, 'submitValues').and.stub(); component.ngOnInit(); fixture.detectChanges(); diff --git a/lib/content-services/src/lib/search/components/search-chip-list/search-chip-list.component.spec.ts b/lib/content-services/src/lib/search/components/search-chip-list/search-chip-list.component.spec.ts index 45bb71a8f4e..2b93546b1ee 100644 --- a/lib/content-services/src/lib/search/components/search-chip-list/search-chip-list.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-chip-list/search-chip-list.component.spec.ts @@ -18,7 +18,7 @@ import { Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { SearchFacetFiltersService, SelectedBucket } from '../../services/search-facet-filters.service'; +import { SearchFacetFiltersService } from '../../services/search-facet-filters.service'; import { ContentTestingModule } from '../../../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; @@ -34,8 +34,8 @@ import { TranslateModule } from '@ngx-translate/core'; class TestComponent { allowClear = true; searchFilter = { - selectedBuckets: [], - unselectFacetBucket() {} + selectedBuckets: [], + unselectFacetBucket: () => {} }; } diff --git a/lib/content-services/src/lib/search/components/search-control.component.spec.ts b/lib/content-services/src/lib/search/components/search-control.component.spec.ts index 7189d3f4ced..694d52a20ce 100644 --- a/lib/content-services/src/lib/search/components/search-control.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-control.component.spec.ts @@ -92,12 +92,12 @@ describe('SearchControlComponent', () => { fixture.destroy(); }); - function typeWordIntoSearchInput(word: string): void { + const typeWordIntoSearchInput = (word: string): void => { const inputDebugElement = debugElement.query(By.css('#adf-control-input')); inputDebugElement.nativeElement.value = word; inputDebugElement.nativeElement.focus(); inputDebugElement.nativeElement.dispatchEvent(new Event('input')); - } + }; describe('when input values are inserted', () => { @@ -242,7 +242,7 @@ describe('SearchControlComponent', () => { fixture.detectChanges(); fixture.whenStable().then(() => { fixture.detectChanges(); - const resultElement: HTMLElement = element.querySelector('#result_option_0'); + const resultElement = element.querySelector('#result_option_0'); resultElement.focus(); expect(resultElement).not.toBe(null); inputDebugElement.nativeElement.dispatchEvent(new KeyboardEvent('keypress', { key: 'TAB' })); @@ -264,14 +264,14 @@ describe('SearchControlComponent', () => { fixture.detectChanges(); fixture.whenStable().then(() => { fixture.detectChanges(); - let resultElement: HTMLElement = element.querySelector('#result_option_0'); + let resultElement = element.querySelector('#result_option_0'); expect(resultElement).not.toBeNull(); const escapeEvent: any = new Event('ESCAPE'); escapeEvent.keyCode = 27; inputDebugElement.triggerEventHandler('keydown', escapeEvent); fixture.whenStable().then(() => { fixture.detectChanges(); - resultElement = element.querySelector('#result_option_0'); + resultElement = element.querySelector('#result_option_0'); expect(resultElement).toBeNull(); done(); }); @@ -289,14 +289,14 @@ describe('SearchControlComponent', () => { fixture.detectChanges(); fixture.whenStable().then(() => { fixture.detectChanges(); - let resultElement: HTMLElement = element.querySelector('#result_option_0'); + let resultElement = element.querySelector('#result_option_0'); expect(resultElement).not.toBeNull(); const escapeEvent: any = new Event('ENTER'); escapeEvent.keyCode = 13; inputDebugElement.triggerEventHandler('keydown', escapeEvent); fixture.whenStable().then(() => { fixture.detectChanges(); - resultElement = element.querySelector('#result_option_0'); + resultElement = element.querySelector('#result_option_0'); expect(resultElement).toBeNull(); done(); }); diff --git a/lib/content-services/src/lib/search/components/search-control.component.ts b/lib/content-services/src/lib/search/components/search-control.component.ts index a9eb8d59e1d..dec279c156c 100644 --- a/lib/content-services/src/lib/search/components/search-control.component.ts +++ b/lib/content-services/src/lib/search/components/search-control.component.ts @@ -147,7 +147,7 @@ export class SearchControlComponent implements OnDestroy { } onBlur(event: FocusEvent): void { - const nextElement: any = this.getNextElementSibling( event.target); + const nextElement: any = this.getNextElementSibling(event.target as Element); if (!nextElement && !this.isListElement(event)) { this.focusSubject.next(event); } @@ -155,20 +155,21 @@ export class SearchControlComponent implements OnDestroy { onSelectFirstResult() { if ( this.listResultElement && this.listResultElement.length > 0) { - const firstElement: MatListItem = this.listResultElement.first; + const firstElement = this.listResultElement.first as MatListItem; + // eslint-disable-next-line no-underscore-dangle firstElement._getHostElement().focus(); } } onRowArrowDown(event: Event): void { - const nextElement: any = this.getNextElementSibling( event.target); + const nextElement: any = this.getNextElementSibling(event.target as Element); if (nextElement) { nextElement.focus(); } } onRowArrowUp(event: Event): void { - const previousElement: any = this.getPreviousElementSibling( event.target); + const previousElement: any = this.getPreviousElementSibling(event.target as Element); if (previousElement) { previousElement.focus(); } else { diff --git a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.spec.ts b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.spec.ts index 8ad693a930c..8f16f9bf592 100644 --- a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.spec.ts @@ -125,8 +125,7 @@ describe('SearchDateRangeComponent', () => { queryFragments: { createdDateRange: 'query' }, - update() { - } + update: () => {} }; component.id = 'createdDateRange'; @@ -144,8 +143,7 @@ describe('SearchDateRangeComponent', () => { it('should update query builder on value changes', () => { const context: any = { queryFragments: {}, - update() { - } + update: () => {} }; component.id = 'createdDateRange'; @@ -203,7 +201,7 @@ describe('SearchDateRangeComponent', () => { }); it('should be able to set a fixed maximum date', async () => { - component.settings = { field: 'cm:created', dateFormat: dateFormatFixture, maxDate: maxDate }; + component.settings = { field: 'cm:created', dateFormat: dateFormatFixture, maxDate }; fixture.detectChanges(); const inputs = fixture.debugElement.nativeElement.querySelectorAll('input[ng-reflect-max="Tue Mar 10 2020 23:59:59 GMT+0"]'); diff --git a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts index a41a1fe5a77..24de4f572e4 100644 --- a/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-date-range/search-date-range.component.ts @@ -96,7 +96,7 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy ngOnInit() { this.datePickerFormat = this.settings?.dateFormat ? this.settings.dateFormat : DEFAULT_FORMAT_DATE; - const customDateAdapter = this.dateAdapter; + const customDateAdapter = this.dateAdapter as MomentDateAdapter; customDateAdapter.overrideDisplayFormat = this.datePickerFormat; this.userPreferencesService @@ -226,7 +226,7 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy formControl.setValue(formatDate); } else if (formatDate) { formControl.setErrors({ - 'invalidOnChange': true + invalidOnChange: true }); } diff --git a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.spec.ts b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.spec.ts index a8debdedc2d..95e73263ca6 100644 --- a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.spec.ts @@ -117,8 +117,7 @@ describe('SearchDatetimeRangeComponent', () => { queryFragments: { createdDatetimeRange: 'query' }, - update() { - } + update: () => {} }; component.id = 'createdDatetimeRange'; @@ -138,8 +137,7 @@ describe('SearchDatetimeRangeComponent', () => { it('should update the query in UTC format when values change', async () => { const context: any = { queryFragments: {}, - update() { - } + update: () => {} }; component.id = 'createdDateRange'; @@ -165,8 +163,7 @@ describe('SearchDatetimeRangeComponent', () => { it('should be able to update the query in UTC format from a GMT format', async () => { const context: any = { queryFragments: {}, - update() { - } + update: () => {} }; const fromInGmt = '2021-02-24T17:00:00+02:00'; const toInGmt = '2021-02-28T15:00:00+02:00'; @@ -225,7 +222,7 @@ describe('SearchDatetimeRangeComponent', () => { }); it('should be able to set a fixed maximum datetime', async () => { - component.settings = { field: 'cm:created', datetimeFormat: datetimeFormatFixture, maxDatetime: maxDatetime }; + component.settings = { field: 'cm:created', datetimeFormat: datetimeFormatFixture, maxDatetime }; fixture.detectChanges(); await fixture.whenStable(); diff --git a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts index 4128eeea8b4..863f3dd3218 100644 --- a/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-datetime-range/search-datetime-range.component.ts @@ -214,7 +214,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes formControl.setValue(formatDate); } else if (formatDate) { formControl.setErrors({ - 'invalidOnChange': true + invalidOnChange: true }); } diff --git a/lib/content-services/src/lib/search/components/search-facet-field/search-facet-field.component.spec.ts b/lib/content-services/src/lib/search/components/search-facet-field/search-facet-field.component.spec.ts index f9c63e87dfd..f0f40de539e 100644 --- a/lib/content-services/src/lib/search/components/search-facet-field/search-facet-field.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-facet-field/search-facet-field.component.spec.ts @@ -96,7 +96,7 @@ describe('SearchFacetFieldComponent', () => { component.field = field; fixture.detectChanges(); - component.onToggleBucket(event, field, query); + component.onToggleBucket(event, field, query as any); expect(query.checked).toEqual(false); expect(queryBuilder.removeUserFacetBucket).toHaveBeenCalledWith(field, query); @@ -108,7 +108,7 @@ describe('SearchFacetFieldComponent', () => { spyOn(queryBuilder, 'update').and.stub(); const field: FacetField = { field: 'f1', label: 'f1' }; - component.onToggleBucket( { checked: true }, field, null); + component.onToggleBucket({ checked: true } as any, field, null); expect(queryBuilder.update).not.toHaveBeenCalled(); }); diff --git a/lib/content-services/src/lib/search/components/search-filter-chips/search-filter-chips.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-chips/search-filter-chips.component.spec.ts index fcc2b274ecf..13d64e2a9a9 100644 --- a/lib/content-services/src/lib/search/components/search-filter-chips/search-filter-chips.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter-chips/search-filter-chips.component.spec.ts @@ -119,7 +119,7 @@ describe('SearchFilterChipsComponent', () => { } }; - searchFacetFiltersService.responseFacets = [ + searchFacetFiltersService.responseFacets = [ { type: 'field', label: 'f1', field: 'f1', buckets: new SearchFilterList([ { label: 'b1', count: 10, filterQuery: 'filter', checked: true }, { label: 'b2', count: 1, filterQuery: 'filter2' }]) }, @@ -168,7 +168,7 @@ describe('SearchFilterChipsComponent', () => { } }; - searchFacetFiltersService.responseFacets = [ + searchFacetFiltersService.responseFacets = [ { type: 'field', label: 'f1', field: 'f1', buckets: new SearchFilterList( [ { label: 'b1', count: 10, filterQuery: 'filter', checked: true }, { label: 'b2', count: 1, filterQuery: 'filter2' }]) }, @@ -271,7 +271,7 @@ describe('SearchFilterChipsComponent', () => { inputElement.triggerEventHandler('change', { target: { value: '*' } }); expect(queryBuilder.update).toHaveBeenCalled(); - queryBuilder.executed.next( mockSearchResult); + queryBuilder.executed.next(mockSearchResult); await fixture.whenStable(); fixture.detectChanges(); @@ -285,7 +285,7 @@ describe('SearchFilterChipsComponent', () => { queryBuilder.resetToDefaults(); fixture.detectChanges(); - queryBuilder.executed.next( mockSearchResult); + queryBuilder.executed.next(mockSearchResult); fixture.detectChanges(); fixture.detectChanges(); @@ -356,7 +356,7 @@ describe('SearchFilterChipsComponent', () => { queryBuilder.resetToDefaults(); fixture.detectChanges(); - queryBuilder.executed.next( mockSearchResult); + queryBuilder.executed.next(mockSearchResult); fixture.detectChanges(); const facetElement = fixture.debugElement.query(By.css(chip)); @@ -368,7 +368,7 @@ describe('SearchFilterChipsComponent', () => { appConfigService.config.search = searchFilter; queryBuilder.resetToDefaults(); fixture.detectChanges(); - queryBuilder.executed.next( mockSearchResult); + queryBuilder.executed.next(mockSearchResult); fixture.detectChanges(); spyOn(queryBuilder, 'update').and.stub(); diff --git a/lib/content-services/src/lib/search/components/search-filter-container/search-filter-container.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter-container/search-filter-container.component.spec.ts index 1b5f680f740..fcf774be4a1 100644 --- a/lib/content-services/src/lib/search/components/search-filter-container/search-filter-container.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter-container/search-filter-container.component.spec.ts @@ -27,17 +27,17 @@ import { MatMenuTrigger } from '@angular/material/menu'; import { SearchCategory } from '../../models/search-category.interface'; const mockCategory: SearchCategory = { - 'id': 'queryName', - 'name': 'Name', - 'columnKey': 'name', - 'enabled': true, - 'expanded': true, - 'component': { - 'selector': 'text', - 'settings': { - 'pattern': `cm:name:'(.*?)'`, - 'field': 'cm:name', - 'placeholder': 'Enter the name' + id: 'queryName', + name: 'Name', + columnKey: 'name', + enabled: true, + expanded: true, + component: { + selector: 'text', + settings: { + pattern: `cm:name:'(.*?)'`, + field: 'cm:name', + placeholder: 'Enter the name' } } }; @@ -151,6 +151,7 @@ describe('SearchFilterContainerComponent', () => { fixture.detectChanges(); expect(component.focusTrap).toBeDefined(); + // eslint-disable-next-line no-underscore-dangle expect(component.focusTrap._element).toBe(component.filterContainer.nativeElement); }); diff --git a/lib/content-services/src/lib/search/components/search-filter/search-filter.component.spec.ts b/lib/content-services/src/lib/search/components/search-filter/search-filter.component.spec.ts index 18a498d8734..05ea2841b01 100644 --- a/lib/content-services/src/lib/search/components/search-filter/search-filter.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-filter/search-filter.component.spec.ts @@ -87,7 +87,7 @@ describe('SearchFilterComponent', () => { } }; - searchFacetFiltersService.responseFacets = [ + searchFacetFiltersService.responseFacets = [ { type: 'field', label: 'f1', field: 'f1', buckets: new SearchFilterList([ { label: 'b1', count: 10, filterQuery: 'filter', checked: true }, { label: 'b2', count: 1, filterQuery: 'filter2' }]) }, @@ -131,7 +131,7 @@ describe('SearchFilterComponent', () => { } }; - searchFacetFiltersService.responseFacets = [ + searchFacetFiltersService.responseFacets = [ { type: 'field', label: 'f1', field: 'f1', buckets: new SearchFilterList([ { label: 'b1', count: 10, filterQuery: 'filter', checked: true }, { label: 'b2', count: 1, filterQuery: 'filter2' }]) }, @@ -175,7 +175,7 @@ describe('SearchFilterComponent', () => { } }; - searchFacetFiltersService.responseFacets = [ + searchFacetFiltersService.responseFacets = [ { type: 'field', label: 'f1', field: 'f1', buckets: new SearchFilterList([ { label: 'b1', count: 10, filterQuery: 'filter', checked: true }, { label: 'b2', count: 1, filterQuery: 'filter2' }]) }, @@ -201,13 +201,13 @@ describe('SearchFilterComponent', () => { spyOn(queryBuilder, 'update').and.stub(); spyOn(queryBuilder, 'removeUserFacetBucket').and.callThrough(); - const queryResponse = { + const queryResponse = { label: 'query response', buckets: new SearchFilterList([ { label: 'q1', query: 'q1', checked: true, metrics: [{value: {count: 1}}] }, { label: 'q2', query: 'q2', checked: false, metrics: [{value: {count: 1}}] }, { label: 'q3', query: 'q3', checked: true, metrics: [{value: {count: 1}}] }]) - }; + } as any; searchFacetFiltersService.responseFacets = [queryResponse]; fixture.detectChanges(); @@ -317,7 +317,7 @@ describe('SearchFilterComponent', () => { inputElement.triggerEventHandler('change', { target: { value: '*' } }); expect(queryBuilder.update).toHaveBeenCalled(); - queryBuilder.executed.next( mockSearchResult); + queryBuilder.executed.next(mockSearchResult); fixture.detectChanges(); panels = fixture.debugElement.queryAll(By.css('.mat-expansion-panel')); @@ -334,7 +334,7 @@ describe('SearchFilterComponent', () => { const inputElement = fixture.debugElement.query(By.css('[data-automation-id="expansion-panel-Name"] input')); inputElement.triggerEventHandler('change', { target: { value: '*' } }); - queryBuilder.executed.next( getMockSearchResultWithResponseBucket()); + queryBuilder.executed.next(getMockSearchResultWithResponseBucket()); fixture.detectChanges(); const panels = fixture.debugElement.queryAll(By.css('.mat-expansion-panel')); @@ -348,7 +348,7 @@ describe('SearchFilterComponent', () => { queryBuilder.resetToDefaults(); fixture.detectChanges(); - queryBuilder.executed.next( mockSearchResult); + queryBuilder.executed.next(mockSearchResult); fixture.detectChanges(); let sizes = getAllMenus(`${panel} mat-checkbox`, fixture); @@ -414,7 +414,7 @@ describe('SearchFilterComponent', () => { queryBuilder.resetToDefaults(); fixture.detectChanges(); - queryBuilder.executed.next( mockSearchResult); + queryBuilder.executed.next(mockSearchResult); fixture.detectChanges(); const facetElement = fixture.debugElement.query(By.css(panel)); @@ -426,7 +426,7 @@ describe('SearchFilterComponent', () => { appConfigService.config.search = searchFilter; queryBuilder.resetToDefaults(); fixture.detectChanges(); - queryBuilder.executed.next( mockSearchResult); + queryBuilder.executed.next(mockSearchResult); fixture.detectChanges(); spyOn(queryBuilder, 'update').and.stub(); @@ -469,7 +469,7 @@ describe('SearchFilterComponent', () => { appConfigService.config.search = searchFilter; queryBuilder.resetToDefaults(); fixture.detectChanges(); - queryBuilder.executed.next( mockSearchResult); + queryBuilder.executed.next(mockSearchResult); fixture.detectChanges(); spyOn(queryBuilder, 'update').and.stub(); @@ -505,7 +505,7 @@ describe('SearchFilterComponent', () => { }); it('should reset the query fragments when reset All is clicked', () => { - component.queryBuilder.queryFragments = { 'fragment1' : 'value1'}; + component.queryBuilder.queryFragments = { fragment1 : 'value1'}; appConfigService.config.search = searchFilter; searchFacetFiltersService.responseFacets = []; component.displayResetButton = true; @@ -522,7 +522,7 @@ describe('SearchFilterComponent', () => { }); }); -export function getAllMenus(regex, fixture: ComponentFixture): string[] { +export const getAllMenus = (regex, fixture: ComponentFixture): string[] => { const elements = fixture.debugElement.queryAll(By.css(regex)); return Array.from(elements).map(element => element.nativeElement.innerText); -} +}; diff --git a/lib/content-services/src/lib/search/components/search-filter/search-filter.component.ts b/lib/content-services/src/lib/search/components/search-filter/search-filter.component.ts index 01bdda25fc3..91c32db03aa 100644 --- a/lib/content-services/src/lib/search/components/search-filter/search-filter.component.ts +++ b/lib/content-services/src/lib/search/components/search-filter/search-filter.component.ts @@ -37,7 +37,7 @@ export class SearchFilterComponent { facetQueriesLabel: string = 'Facet Queries'; facetExpanded = { - 'default': false + default: false }; displayResetButton: boolean; diff --git a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.spec.ts b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.spec.ts index 59c8e420ab0..14373232215 100644 --- a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.spec.ts @@ -48,7 +48,7 @@ describe('SearchNumberRangeComponent', () => { queryFragments: { contentSize: 'query' }, - update() {} + update: () => {} }; component.id = 'contentSize'; @@ -66,7 +66,7 @@ describe('SearchNumberRangeComponent', () => { it('should update query builder on value changes', () => { const context: any = { queryFragments: {}, - update() {} + update: () => {} }; component.id = 'contentSize'; @@ -110,7 +110,7 @@ describe('SearchNumberRangeComponent', () => { it('should format value based on the current pattern', () => { const context: any = { queryFragments: {}, - update() {} + update: () => {} }; component.id = 'range1'; diff --git a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts index 5e3bdc13eec..9dade7218cf 100644 --- a/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts +++ b/lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts @@ -83,7 +83,7 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit { } formValidator(formGroup: FormGroup) { - return parseInt(formGroup.get('from').value, 10) < parseInt(formGroup.get('to').value, 10) ? null : {'mismatch': true}; + return parseInt(formGroup.get('from').value, 10) < parseInt(formGroup.get('to').value, 10) ? null : {mismatch: true}; } apply(model: { from: string; to: string }, isValid: boolean) { diff --git a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.spec.ts b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.spec.ts index c75fcb8bc37..368e1616b50 100644 --- a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.spec.ts @@ -42,10 +42,10 @@ describe('SearchCheckListComponent', () => { it('should setup options from settings', () => { const options: any = [ - { 'name': 'Folder', 'value': `TYPE:'cm:folder'` }, - { 'name': 'Document', 'value': `TYPE:'cm:content'` } + { name: 'Folder', value: `TYPE:'cm:folder'` }, + { name: 'Document', value: `TYPE:'cm:content'` } ]; - component.settings = { options: options }; + component.settings = { options } as any; component.ngOnInit(); expect(component.options.items).toEqual(options); @@ -70,13 +70,13 @@ describe('SearchCheckListComponent', () => { }); it('should setup operator from the settings', () => { - component.settings = { operator: 'AND' }; + component.settings = { operator: 'AND' } as any; component.ngOnInit(); expect(component.operator).toBe('AND'); }); it('should use OR operator by default', () => { - component.settings = { operator: null }; + component.settings = { operator: null } as any; component.ngOnInit(); expect(component.operator).toBe('OR'); }); @@ -88,24 +88,24 @@ describe('SearchCheckListComponent', () => { ]); component.id = 'checklist'; - component.context = { + component.context = { queryFragments: {}, - update() {} - }; + update: () => {} + } as any; component.ngOnInit(); spyOn(component.context, 'update').and.stub(); component.changeHandler( - { checked: true }, + { checked: true } as any, component.options.items[0] ); expect(component.context.queryFragments[component.id]).toEqual(`TYPE:'cm:folder'`); component.changeHandler( - { checked: true }, + { checked: true } as any, component.options.items[1] ); @@ -128,12 +128,12 @@ describe('SearchCheckListComponent', () => { it('should update query builder on reset', () => { component.id = 'checklist'; - component.context = { + component.context = { queryFragments: { - 'checklist': 'query' + checklist: 'query' }, - update() {} - }; + update: () => {} + } as any; spyOn(component.context, 'update').and.stub(); component.ngOnInit(); @@ -151,13 +151,13 @@ describe('SearchCheckListComponent', () => { describe('Pagination', () => { it('should show 5 items when pageSize not defined', () => { component.id = 'checklist'; - component.context = { + component.context = { queryFragments: { - 'checklist': 'query' + checklist: 'query' }, - update() {} - }; - component.settings = { options: sizeOptions }; + update: () => {} + } as any; + component.settings = { options: sizeOptions } as any; component.ngOnInit(); fixture.detectChanges(); @@ -170,13 +170,13 @@ describe('SearchCheckListComponent', () => { it('should show all items when pageSize is high', () => { component.id = 'checklist'; - component.context = { + component.context = { queryFragments: { - 'checklist': 'query' + checklist: 'query' }, - update() {} - }; - component.settings = { pageSize: 15, options: sizeOptions }; + update: () => {} + } as any; + component.settings = { pageSize: 15, options: sizeOptions } as any; component.ngOnInit(); fixture.detectChanges(); @@ -189,13 +189,13 @@ describe('SearchCheckListComponent', () => { it('should able to check/reset the checkbox', () => { component.id = 'checklist'; - component.context = { + component.context = { queryFragments: { - 'checklist': 'query' + checklist: 'query' }, update: () => {} - }; - component.settings = { options: sizeOptions }; + } as any; + component.settings = { options: sizeOptions } as any; spyOn(component, 'submitValues').and.stub(); component.ngOnInit(); fixture.detectChanges(); diff --git a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.spec.ts b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.spec.ts index 9b93bbfa689..890c9ae6041 100644 --- a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.spec.ts @@ -42,13 +42,13 @@ describe('SearchRadioComponent', () => { describe('Pagination', () => { it('should show 5 items when pageSize not defined', () => { component.id = 'radio'; - component.context = { + component.context = { queryFragments: { - 'radio': 'query' + radio: 'query' }, - update() {} - }; - component.settings = { options: sizeOptions }; + update: () => {} + } as any; + component.settings = { options: sizeOptions } as any; component.ngOnInit(); fixture.detectChanges(); @@ -61,13 +61,13 @@ describe('SearchRadioComponent', () => { it('should show all items when pageSize is high', () => { component.id = 'radio'; - component.context = { + component.context = { queryFragments: { - 'radio': 'query' + radio: 'query' }, - update() {} - }; - component.settings = { pageSize: 15, options: sizeOptions }; + update: () => {} + } as any; + component.settings = { pageSize: 15, options: sizeOptions } as any; component.ngOnInit(); fixture.detectChanges(); @@ -80,13 +80,13 @@ describe('SearchRadioComponent', () => { it('should able to check the radio button', async () => { component.id = 'radio'; - component.context = { + component.context = { queryFragments: { - 'radio': 'query' + radio: 'query' }, update: () => {} - }; - component.settings = { options: sizeOptions }; + } as any; + component.settings = { options: sizeOptions } as any; spyOn(component.context, 'update').and.stub(); fixture.detectChanges(); await fixture.whenStable(); diff --git a/lib/content-services/src/lib/search/components/search-slider/search-slider.component.spec.ts b/lib/content-services/src/lib/search/components/search-slider/search-slider.component.spec.ts index 39685920eb0..e6cc904b037 100644 --- a/lib/content-services/src/lib/search/components/search-slider/search-slider.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-slider/search-slider.component.spec.ts @@ -56,17 +56,17 @@ describe('SearchSliderComponent', () => { }); it('should update value on slider change', () => { - component.onChangedHandler( { value: 10 }); + component.onChangedHandler({ value: 10 } as MatSliderChange); expect(component.value).toEqual(10); - component.onChangedHandler( { value: 20 }); + component.onChangedHandler({ value: 20 } as MatSliderChange); expect(component.value).toEqual(20); }); it('should update its query part on slider change', () => { const context: any = { queryFragments: {}, - update() {} + update: () => {} }; spyOn(context, 'update').and.stub(); @@ -76,11 +76,11 @@ describe('SearchSliderComponent', () => { component.settings = { field: 'cm:content.size' }; fixture.detectChanges(); - component.onChangedHandler( { value: 10 }); + component.onChangedHandler({ value: 10 } as MatSliderChange); expect(context.queryFragments[component.id]).toEqual('cm:content.size:[0 TO 10]'); expect(context.update).toHaveBeenCalled(); - component.onChangedHandler( { value: 20 }); + component.onChangedHandler({ value: 20 } as MatSliderChange); expect(context.queryFragments[component.id]).toEqual('cm:content.size:[0 TO 20]'); }); @@ -95,7 +95,7 @@ describe('SearchSliderComponent', () => { const context: any = { queryFragments: {}, - update() {} + update: () => {} }; component.settings = settings; @@ -123,7 +123,7 @@ describe('SearchSliderComponent', () => { const context: any = { queryFragments: {}, - update() {} + update: () => {} }; component.settings = settings; diff --git a/lib/content-services/src/lib/search/components/search-sorting-picker/search-sorting-picker.component.spec.ts b/lib/content-services/src/lib/search/components/search-sorting-picker/search-sorting-picker.component.spec.ts index ea9b8e28710..e48a0d91db9 100644 --- a/lib/content-services/src/lib/search/components/search-sorting-picker/search-sorting-picker.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-sorting-picker/search-sorting-picker.component.spec.ts @@ -41,16 +41,16 @@ describe('SearchSortingPickerComponent', () => { const config: SearchConfiguration = { sorting: { options: [ - { 'key': 'name', 'label': 'Name', 'type': 'FIELD', 'field': 'cm:name', 'ascending': true }, - { 'key': 'content.sizeInBytes', 'label': 'Size', 'type': 'FIELD', 'field': 'content.size', 'ascending': true }, - { 'key': 'description', 'label': 'Description', 'type': 'FIELD', 'field': 'cm:description', 'ascending': true } + { key: 'name', label: 'Name', type: 'FIELD', field: 'cm:name', ascending: true }, + { key: 'content.sizeInBytes', label: 'Size', type: 'FIELD', field: 'content.size', ascending: true }, + { key: 'description', label: 'Description', type: 'FIELD', field: 'cm:description', ascending: true } ], defaults: [ - { 'key': 'name', 'type': 'FIELD', 'field': 'cm:name', 'ascending': false } + { key: 'name', type: 'FIELD', field: 'cm:name', ascending: false } as any ] }, categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); diff --git a/lib/content-services/src/lib/search/components/search-text/search-text.component.spec.ts b/lib/content-services/src/lib/search/components/search-text/search-text.component.spec.ts index 832ba8b024b..d5be96b129d 100644 --- a/lib/content-services/src/lib/search/components/search-text/search-text.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-text/search-text.component.spec.ts @@ -37,15 +37,15 @@ describe('SearchTextComponent', () => { component = fixture.componentInstance; component.id = 'text'; component.settings = { - 'pattern': `cm:name:'(.*?)'`, - 'field': 'cm:name', - 'placeholder': 'Enter the name' + pattern: `cm:name:'(.*?)'`, + field: 'cm:name', + placeholder: 'Enter the name' }; - component.context = { + component.context = { queryFragments: {}, - update() {} - }; + update: () => {} + } as any; }); it('should parse value from the context at startup', () => { diff --git a/lib/content-services/src/lib/search/components/search.component.spec.ts b/lib/content-services/src/lib/search/components/search.component.spec.ts index bc06fde74d7..7c6d33e62cf 100644 --- a/lib/content-services/src/lib/search/components/search.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search.component.spec.ts @@ -89,7 +89,7 @@ describe('SearchComponent', () => { fixture.detectChanges(); fixture.whenStable().then(() => { fixture.detectChanges(); - const message: HTMLElement = element.querySelector('#component-result-message'); + const message = element.querySelector('#component-result-message'); expect(message.textContent).toBe('ERROR'); done(); }); @@ -129,7 +129,7 @@ describe('SearchComponent', () => { fixture.detectChanges(); const optionShowed = element.querySelectorAll('#autocomplete-search-result-list > li').length; expect(optionShowed).toBe(1); - const folderOption: HTMLElement = element.querySelector('#result_option_0'); + const folderOption = element.querySelector('#result_option_0'); expect(folderOption.textContent.trim()).toBe('MyDoc'); done(); }); diff --git a/lib/content-services/src/lib/search/components/search.component.ts b/lib/content-services/src/lib/search/components/search.component.ts index f12325b90a0..f6013f134c2 100644 --- a/lib/content-services/src/lib/search/components/search.component.ts +++ b/lib/content-services/src/lib/search/components/search.component.ts @@ -41,9 +41,7 @@ import { debounceTime, takeUntil } from 'rxjs/operators'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, exportAs: 'searchAutocomplete', - host: { - 'class': 'adf-search' - } + host: { class: 'adf-search' } }) export class SearchComponent implements SearchComponentInterface, AfterContentInit, OnChanges, OnDestroy { @@ -168,7 +166,7 @@ export class SearchComponent implements SearchComponentInterface, AfterContentIn onSearchDataLoaded(resultSetPaging: ResultSetPaging) { if (resultSetPaging) { - this.results = resultSetPaging; + this.results = resultSetPaging as NodePaging; this.resultLoaded.emit(this.results); this.isOpen = true; this.setVisibility(); diff --git a/lib/content-services/src/lib/search/forms/search-term-validator.ts b/lib/content-services/src/lib/search/forms/search-term-validator.ts index ac03b044719..593186601fd 100644 --- a/lib/content-services/src/lib/search/forms/search-term-validator.ts +++ b/lib/content-services/src/lib/search/forms/search-term-validator.ts @@ -20,10 +20,8 @@ import { FormControl } from '@angular/forms'; export class SearchTermValidator { static minAlphanumericChars(minChars: number) { - return (control: FormControl) => { - return ('' + control.value).replace(/[^0-9a-zA-Z]+/g, '').length >= minChars ? null : { - hasMinAlphanumericChars: false - }; + return (control: FormControl) => ('' + control.value).replace(/[^0-9a-zA-Z]+/g, '').length >= minChars ? null : { + hasMinAlphanumericChars: false }; } diff --git a/lib/content-services/src/lib/search/models/response-facet-query-list.model.ts b/lib/content-services/src/lib/search/models/response-facet-query-list.model.ts index ab501eb10a2..4d3b38a2d98 100644 --- a/lib/content-services/src/lib/search/models/response-facet-query-list.model.ts +++ b/lib/content-services/src/lib/search/models/response-facet-query-list.model.ts @@ -21,10 +21,7 @@ import { SearchFilterList } from './search-filter-list.model'; export class ResponseFacetQueryList extends SearchFilterList { constructor(items: FacetQuery[] = [], translationService, pageSize: number = 5) { super( - items - .filter((item) => { - return item.count > 0; - }), + items.filter((item) => item.count > 0), pageSize ); diff --git a/lib/content-services/src/lib/search/models/search-filter-list.model.spec.ts b/lib/content-services/src/lib/search/models/search-filter-list.model.spec.ts index 7b4de9fd91e..16a74d54aab 100644 --- a/lib/content-services/src/lib/search/models/search-filter-list.model.spec.ts +++ b/lib/content-services/src/lib/search/models/search-filter-list.model.spec.ts @@ -27,9 +27,7 @@ export class Payload { describe('SearchFilterList', () => { - function generateItems(count: number): Payload[] { - return Array(count).fill(null).map((_, id) => new Payload(id)); - } + const generateItems = (count: number): Payload[] => Array(count).fill(null).map((_, id) => new Payload(id)); it('should init with external items', () => { const items = [ @@ -160,9 +158,7 @@ describe('SearchFilterList', () => { const list = new SearchFilterList(items, 5); expect(list.visibleItems.length).toBe(5); - list.filter = (item: Payload): boolean => { - return item.name === 'custom'; - }; + list.filter = (item: Payload): boolean => item.name === 'custom'; expect(list.visibleItems.length).toBe(1); }); diff --git a/lib/content-services/src/lib/search/models/search-filter-list.model.ts b/lib/content-services/src/lib/search/models/search-filter-list.model.ts index dfb0db729bc..5f4024d93c4 100644 --- a/lib/content-services/src/lib/search/models/search-filter-list.model.ts +++ b/lib/content-services/src/lib/search/models/search-filter-list.model.ts @@ -130,7 +130,7 @@ export class SearchFilterList implements Iterable { const items = this.visibleItems; return { - next(): IteratorResult { + next: (): IteratorResult => { if (pointer < items.length) { return { done: false, diff --git a/lib/content-services/src/lib/search/services/base-query-builder.service.ts b/lib/content-services/src/lib/search/services/base-query-builder.service.ts index 59b1c88986f..cccbb8dd642 100644 --- a/lib/content-services/src/lib/search/services/base-query-builder.service.ts +++ b/lib/content-services/src/lib/search/services/base-query-builder.service.ts @@ -21,7 +21,6 @@ import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core'; import { QueryBody, RequestFacetFields, - RequestFacetField, RequestSortDefinitionInner, ResultSetPaging, RequestHighlight, @@ -180,6 +179,7 @@ export abstract class BaseQueryBuilderService { /** * Adds a facet bucket to a field. + * * @param field The target field * @param bucket Bucket to add */ @@ -196,6 +196,7 @@ export abstract class BaseQueryBuilderService { /** * Gets the buckets currently added to a field + * * @param field The target fields * @returns Bucket array */ @@ -205,6 +206,7 @@ export abstract class BaseQueryBuilderService { /** * Removes an existing bucket from a field. + * * @param field The target field * @param bucket Bucket to remove */ @@ -218,19 +220,21 @@ export abstract class BaseQueryBuilderService { /** * Adds a filter query to the current query. + * * @param query Query string to add */ addFilterQuery(query: string): void { if (query) { const existing = this.filterQueries.find((filterQuery) => filterQuery.query === query); if (!existing) { - this.filterQueries.push({ query: query }); + this.filterQueries.push({ query }); } } } /** * Removes an existing filter query. + * * @param query The query to remove */ removeFilterQuery(query: string): void { @@ -242,6 +246,7 @@ export abstract class BaseQueryBuilderService { /** * Gets a facet query by label. + * * @param label Label of the query * @returns Facet query data */ @@ -257,6 +262,7 @@ export abstract class BaseQueryBuilderService { /** * Gets a facet field by label. + * * @param label Label of the facet field * @returns Facet field data */ @@ -290,6 +296,7 @@ export abstract class BaseQueryBuilderService { /** * Builds and executes the current query. + * * @returns Nothing */ async execute(queryBody?: QueryBody) { @@ -325,6 +332,7 @@ export abstract class BaseQueryBuilderService { /** * Builds the current query. + * * @returns The finished query */ buildQuery(): QueryBody { @@ -337,12 +345,12 @@ export abstract class BaseQueryBuilderService { if (query) { - const result: QueryBody = { + const result: QueryBody = { query: { - query: query, + query, language: 'afts' }, - include: include, + include, paging: this.paging, fields: this.config.fields, filterQueries: this.filterQueries, @@ -366,6 +374,7 @@ export abstract class BaseQueryBuilderService { /** * Gets the primary sorting definition. + * * @returns The primary sorting definition */ getPrimarySorting(): SearchSortingDefinition { @@ -377,6 +386,7 @@ export abstract class BaseQueryBuilderService { /** * Gets all pre-configured sorting options that users can choose from. + * * @returns Pre-configured sorting options */ getSortingOptions(): SearchSortingDefinition[] { @@ -388,6 +398,7 @@ export abstract class BaseQueryBuilderService { /** * Gets the query group. + * * @param query Target query * @returns Query group */ @@ -397,6 +408,7 @@ export abstract class BaseQueryBuilderService { /** * Checks if FacetQueries has been defined + * * @returns True if defined, false otherwise */ get hasFacetQueries(): boolean { @@ -411,6 +423,7 @@ export abstract class BaseQueryBuilderService { /** * Checks if FacetIntervals has been defined + * * @returns True if defined, false otherwise */ get hasFacetIntervals(): boolean { @@ -426,20 +439,18 @@ export abstract class BaseQueryBuilderService { } protected get sort(): RequestSortDefinitionInner[] { - return this.sorting.map((def) => { - return new RequestSortDefinitionInner({ - type: def.type, - field: def.field, - ascending: def.ascending - }); - }); + return this.sorting.map((def) => new RequestSortDefinitionInner({ + type: def.type, + field: def.field, + ascending: def.ascending + })); } protected get facetQueries(): FacetQuery[] { if (this.hasFacetQueries) { return this.config.facetQueries.queries.map((query) => { query.group = this.getQueryGroup(query); - return { ...query }; + return { ...query }; }); } @@ -451,17 +462,17 @@ export abstract class BaseQueryBuilderService { const configIntervals = this.config.facetIntervals; return { - intervals: configIntervals.intervals.map((interval) => { + intervals: configIntervals.intervals.map((interval) => ({ label: this.getSupportedLabel(interval.label), field: interval.field, - sets: interval.sets.map((set) => { - label: this.getSupportedLabel(set.label), - start: set.start, - end: set.end, - startInclusive: set.startInclusive, - endInclusive: set.endInclusive - }) - }) + sets: interval.sets.map((set) => ({ + label: this.getSupportedLabel(set.label), + start: set.start, + end: set.end, + startInclusive: set.startInclusive, + endInclusive: set.endInclusive + } as any)) + } as any)) }; } @@ -512,14 +523,14 @@ export abstract class BaseQueryBuilderService { if (facetFields && facetFields.length > 0) { return { - facets: facetFields.map((facet) => { + facets: facetFields.map((facet) => ({ field: facet.field, mincount: facet.mincount, label: this.getSupportedLabel(facet.label), limit: facet.limit, offset: facet.offset, prefix: facet.prefix - }) + } as any)) }; } @@ -528,6 +539,7 @@ export abstract class BaseQueryBuilderService { /** * Encloses a label name with double quotes if it contains whitespace characters. + * * @param configLabel Original label text * @returns Label, possibly with quotes if it contains spaces */ diff --git a/lib/content-services/src/lib/search/services/search-facet-filters.service.ts b/lib/content-services/src/lib/search/services/search-facet-filters.service.ts index c5fa5612599..1b6cace7a4e 100644 --- a/lib/content-services/src/lib/search/services/search-facet-filters.service.ts +++ b/lib/content-services/src/lib/search/services/search-facet-filters.service.ts @@ -31,6 +31,8 @@ export interface SelectedBucket { bucket: FacetFieldBucket; } +const DEFAULT_PAGE_SIZE: number = 5; + @Injectable({ providedIn: 'root' }) @@ -45,15 +47,14 @@ export class SearchFacetFiltersService implements OnDestroy { /** shows the facet chips */ selectedBuckets: SelectedBucket[] = []; - private DEFAULT_PAGE_SIZE = 5; - private readonly facetQueriesPageSize = this.DEFAULT_PAGE_SIZE; + private readonly facetQueriesPageSize = DEFAULT_PAGE_SIZE; private readonly onDestroy$ = new Subject(); constructor(@Inject(SEARCH_QUERY_SERVICE_TOKEN) public queryBuilder: SearchQueryBuilderService, private searchService: SearchService, private translationService: TranslationService) { if (queryBuilder.config && queryBuilder.config.facetQueries) { - this.facetQueriesPageSize = queryBuilder.config.facetQueries.pageSize || this.DEFAULT_PAGE_SIZE; + this.facetQueriesPageSize = queryBuilder.config.facetQueries.pageSize || DEFAULT_PAGE_SIZE; } this.queryBuilder.configUpdated @@ -110,12 +111,12 @@ export class SearchFacetFiltersService implements OnDestroy { if (!this.responseFacets) { this.responseFacets = []; } - this.responseFacets.push( { + this.responseFacets.push({ ...field, type: responseField.type || itemType, label: field.label, - pageSize: field.pageSize | this.DEFAULT_PAGE_SIZE, - currentPageSize: field.pageSize | this.DEFAULT_PAGE_SIZE, + pageSize: field.pageSize | DEFAULT_PAGE_SIZE, + currentPageSize: field.pageSize | DEFAULT_PAGE_SIZE, buckets: bucketList }); } @@ -167,12 +168,12 @@ export class SearchFacetFiltersService implements OnDestroy { if (!this.responseFacets) { this.responseFacets = []; } - this.responseFacets.push( { + this.responseFacets.push({ field: group, type: responseField.type || 'query', label: group, - pageSize: this.DEFAULT_PAGE_SIZE, - currentPageSize: this.DEFAULT_PAGE_SIZE, + pageSize: DEFAULT_PAGE_SIZE, + currentPageSize: DEFAULT_PAGE_SIZE, buckets: bucketList, settings: facetQuerySetting }); @@ -187,12 +188,12 @@ export class SearchFacetFiltersService implements OnDestroy { respBucket['count'] = this.getCountValue(respBucket); respBucket.filterQuery = respBucket.filterQuery || this.getCorrespondingFilterQuery(configField, respBucket.label); - return { + return { ...respBucket, checked: false, display: respBucket.display, label: respBucket.label - }; + } as FacetFieldBucket; }); } @@ -202,7 +203,7 @@ export class SearchFacetFiltersService implements OnDestroy { .find((bucket) => bucket.label === query.label) || {}; respBucket['count'] = this.getCountValue(respBucket); - return { + return { ...respBucket, checked: false, display: respBucket.display, @@ -327,9 +328,7 @@ export class SearchFacetFiltersService implements OnDestroy { this.selectedBuckets.push( ...this.queryBuilder.getUserFacetBuckets(field.field) .filter((bucket) => bucket.checked) - .map((bucket) => { - return {field, bucket}; - }) + .map((bucket) => ({field, bucket})) ); } } diff --git a/lib/content-services/src/lib/search/services/search-filter.service.ts b/lib/content-services/src/lib/search/services/search-filter.service.ts index 7192d06faf8..80b8d073bd1 100644 --- a/lib/content-services/src/lib/search/services/search-filter.service.ts +++ b/lib/content-services/src/lib/search/services/search-filter.service.ts @@ -33,9 +33,9 @@ export class SearchFilterService { * Contains string-to-type mappings for registered widgets. */ widgets: { [id: string]: Type } = { - 'text': SearchTextComponent, - 'radio': SearchRadioComponent, - 'slider': SearchSliderComponent, + text: SearchTextComponent, + radio: SearchRadioComponent, + slider: SearchSliderComponent, 'number-range': SearchNumberRangeComponent, 'check-list': SearchCheckListComponent, 'date-range': SearchDateRangeComponent, diff --git a/lib/content-services/src/lib/search/services/search-header-query-builder.service.spec.ts b/lib/content-services/src/lib/search/services/search-header-query-builder.service.spec.ts index 106d07853c1..f006f011999 100644 --- a/lib/content-services/src/lib/search/services/search-header-query-builder.service.spec.ts +++ b/lib/content-services/src/lib/search/services/search-header-query-builder.service.spec.ts @@ -38,8 +38,8 @@ describe('SearchHeaderQueryBuilderService', () => { it('should load the configuration from app config', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: true } as any ], filterQueries: [{ query: 'query1' }, { query: 'query2' }] }; @@ -66,8 +66,8 @@ describe('SearchHeaderQueryBuilderService', () => { it('should return the category assigned to a column key', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', columnKey: 'fake-key-1', enabled: true }, - { id: 'cat2', columnKey: 'fake-key-2', enabled: true } + { id: 'cat1', columnKey: 'fake-key-1', enabled: true } as any, + { id: 'cat2', columnKey: 'fake-key-2', enabled: true } as any ], filterQueries: [{ query: 'query1' }, { query: 'query2' }] }; @@ -98,8 +98,8 @@ describe('SearchHeaderQueryBuilderService', () => { it('should add the extra filter for the parent node', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: true } as any ], filterQueries: [{ query: 'query1' }, { query: 'query2' }] }; @@ -128,8 +128,8 @@ describe('SearchHeaderQueryBuilderService', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: true } as any ], filterQueries: expectedResult }; @@ -154,7 +154,7 @@ describe('SearchHeaderQueryBuilderService', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ], filterQueries: [ { query: 'PARENT:"workspace://SpacesStore/fake-node-id' } diff --git a/lib/content-services/src/lib/search/services/search-header-query-builder.service.ts b/lib/content-services/src/lib/search/services/search-header-query-builder.service.ts index e9f0344e589..79df1cb5ec3 100644 --- a/lib/content-services/src/lib/search/services/search-header-query-builder.service.ts +++ b/lib/content-services/src/lib/search/services/search-header-query-builder.service.ts @@ -66,7 +66,7 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService { setActiveFilter(columnActivated: string, filterValue: string) { const selectedFilter = this.activeFilters.find((activeFilter) => activeFilter.key === columnActivated); if (!selectedFilter) { - this.activeFilters.push( { + this.activeFilters.push({ key: columnActivated, value: filterValue }); @@ -104,7 +104,7 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService { const currentSort: SearchSortingDefinition = { key: columnSorting.key, label: 'current', - type: type, + type, field: fieldValue, ascending: optionAscending }; diff --git a/lib/content-services/src/lib/search/services/search-query-builder.service.spec.ts b/lib/content-services/src/lib/search/services/search-query-builder.service.spec.ts index 8caa6540754..546e076ed17 100644 --- a/lib/content-services/src/lib/search/services/search-query-builder.service.spec.ts +++ b/lib/content-services/src/lib/search/services/search-query-builder.service.spec.ts @@ -39,8 +39,8 @@ describe('SearchQueryBuilder', () => { it('should reset to defaults', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: true } as any ], filterQueries: [ { query: 'query1' }, @@ -87,9 +87,9 @@ describe('SearchQueryBuilder', () => { it('should use only enabled categories', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: false }, - { id: 'cat3', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: false } as any, + { id: 'cat3', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -222,9 +222,9 @@ describe('SearchQueryBuilder', () => { const config: SearchConfiguration = { categories: [], facetFields: { - 'fields': [ - { 'field': 'content.mimetype', 'mincount': 1, 'label': 'Type' }, - { 'field': 'content.size', 'mincount': 1, 'label': 'Size' } + fields: [ + { field: 'content.mimetype', mincount: 1, label: 'Type' }, + { field: 'content.size', mincount: 1, label: 'Size' } ] } }; @@ -241,9 +241,9 @@ describe('SearchQueryBuilder', () => { const config: SearchConfiguration = { categories: [], facetFields: { - 'fields': [ - { 'field': 'content.mimetype', 'mincount': 1, 'label': 'Type' }, - { 'field': 'content.size', 'mincount': 1, 'label': 'Size' } + fields: [ + { field: 'content.mimetype', mincount: 1, label: 'Type' }, + { field: 'content.size', mincount: 1, label: 'Size' } ] } }; @@ -259,8 +259,8 @@ describe('SearchQueryBuilder', () => { const config: SearchConfiguration = { categories: [], facetFields: { - 'fields': [ - { 'field': 'content.size', 'mincount': 1, 'label': 'Label with spaces' } + fields: [ + { field: 'content.size', mincount: 1, label: 'Label with spaces' } ] } }; @@ -276,7 +276,7 @@ describe('SearchQueryBuilder', () => { it('should require a query fragment to build query', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -291,7 +291,7 @@ describe('SearchQueryBuilder', () => { it('should build query with single fragment', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -307,8 +307,8 @@ describe('SearchQueryBuilder', () => { it('should build query with multiple fragments', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -328,8 +328,8 @@ describe('SearchQueryBuilder', () => { const config: SearchConfiguration = { fields: ['field1', 'field2'], categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -346,8 +346,8 @@ describe('SearchQueryBuilder', () => { const config: SearchConfiguration = { fields: [], categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -363,7 +363,7 @@ describe('SearchQueryBuilder', () => { it('should build query with custom filter queries', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -381,7 +381,7 @@ describe('SearchQueryBuilder', () => { it('should build query with custom facet queries', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ], facetQueries: { queries: [ @@ -401,7 +401,7 @@ describe('SearchQueryBuilder', () => { it('should build query with custom facet fields', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ], facetFields: { fields: [ @@ -431,7 +431,7 @@ describe('SearchQueryBuilder', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ], facetFields: { fields: [ @@ -469,7 +469,7 @@ describe('SearchQueryBuilder', () => { it('should build query with custom facet intervals', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ], facetIntervals: { intervals: [ @@ -517,7 +517,7 @@ describe('SearchQueryBuilder', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ], facetIntervals: { intervals: [ @@ -558,8 +558,8 @@ describe('SearchQueryBuilder', () => { const config: SearchConfiguration = { fields: [], categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -576,7 +576,7 @@ describe('SearchQueryBuilder', () => { it('should use pagination settings', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -594,7 +594,7 @@ describe('SearchQueryBuilder', () => { it('should build final request with user and custom queries', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -630,7 +630,7 @@ describe('SearchQueryBuilder', () => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -651,9 +651,9 @@ describe('SearchQueryBuilder', () => { it('should use highlight in the queries', () => { const config: SearchConfiguration = { highlight: { - 'prefix': 'my-prefix', - 'postfix': 'my-postfix', - 'mergeContiguous': true + prefix: 'my-prefix', + postfix: 'my-postfix', + mergeContiguous: true } }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -672,7 +672,7 @@ describe('SearchQueryBuilder', () => { it('should emit error event', (done) => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -690,7 +690,7 @@ describe('SearchQueryBuilder', () => { it('should emit empty results on error', (done) => { const config: SearchConfiguration = { categories: [ - { id: 'cat1', enabled: true } + { id: 'cat1', enabled: true } as any ] }; const alfrescoApiService = TestBed.inject(AlfrescoApiService); @@ -775,8 +775,8 @@ describe('SearchQueryBuilder', () => { configs = [ { categories: [ - { id: 'cat1', enabled: true }, - { id: 'cat2', enabled: true } + { id: 'cat1', enabled: true } as any, + { id: 'cat2', enabled: true } as any ], filterQueries: [ { query: 'query1' }, @@ -787,7 +787,7 @@ describe('SearchQueryBuilder', () => { }, { categories: [ - { id: 'mouse', enabled: true } + { id: 'mouse', enabled: true } as any ], filterQueries: [ { query: 'query1' }, @@ -798,7 +798,7 @@ describe('SearchQueryBuilder', () => { }, { categories: [ - { id: 'cat_and_mouse', enabled: true } + { id: 'cat_and_mouse', enabled: true } as any ], default: false } diff --git a/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.spec.ts b/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.spec.ts index aa7cdc7fb98..99380e8586d 100644 --- a/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.spec.ts +++ b/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.spec.ts @@ -31,18 +31,18 @@ import { ContentTestingModule } from '../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; const customSiteList = { - 'list': { - 'entries': [ + list: { + entries: [ { - 'entry': { - 'guid': '-my-', - 'title': 'PERSONAL_FILES' + entry: { + guid: '-my-', + title: 'PERSONAL_FILES' } }, { - 'entry': { - 'guid': '-mysites-', - 'title': 'FILE_LIBRARIES' + entry: { + guid: '-mysites-', + title: 'FILE_LIBRARIES' } } ] @@ -106,10 +106,10 @@ describe('DropdownSitesComponent', () => { component = fixture.componentInstance; }); - function openSelectBox() { + const openSelectBox = () => { const selectBox = debug.query(By.css(('[data-automation-id="site-my-files-option"] .mat-select-trigger'))); selectBox.triggerEventHandler('click', null); - } + }; it('Dropdown sites should be rendered', async () => { fixture.detectChanges(); diff --git a/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.ts b/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.ts index 4441731fa6a..1a983d67130 100644 --- a/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.ts +++ b/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.ts @@ -20,6 +20,9 @@ import { SitesService, LogService, InfiniteSelectScrollDirective } from '@alfres import { SitePaging, SiteEntry } from '@alfresco/js-api'; import { MatSelectChange } from '@angular/material/select'; +/* eslint-disable no-shadow */ +/* eslint-disable @typescript-eslint/naming-convention */ + export enum Relations { Members = 'members', Containers = 'containers' @@ -30,7 +33,7 @@ export enum Relations { styleUrls: ['./sites-dropdown.component.scss'], templateUrl: './sites-dropdown.component.html', encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-sites-dropdown' } + host: { class: 'adf-sites-dropdown' } }) export class DropdownSitesComponent implements OnInit { @@ -169,8 +172,6 @@ export class DropdownSitesComponent implements OnInit { private isCurrentUserMember(site, loggedUserName): boolean { return site.entry.visibility === 'PUBLIC' || - !!site.relations.members.list.entries.find((member) => { - return member.entry.id.toLowerCase() === loggedUserName.toLowerCase(); - }); + !!site.relations.members.list.entries.find((member) => member.entry.id.toLowerCase() === loggedUserName.toLowerCase()); } } diff --git a/lib/content-services/src/lib/social/rating.component.spec.ts b/lib/content-services/src/lib/social/rating.component.spec.ts index 54b2c0e9e95..3343c253e73 100644 --- a/lib/content-services/src/lib/social/rating.component.spec.ts +++ b/lib/content-services/src/lib/social/rating.component.spec.ts @@ -76,11 +76,11 @@ describe('Rating component', () => { it('should the star rating filled with the right grey/colored star', (done) => { spyOn(service, 'getRating').and.returnValue(of({ - 'entry': { + entry: { myRating: 3, - 'ratedAt': '2017-04-06T14:34:28.061+0000', - 'id': 'fiveStar', - 'aggregate': {'numberOfRatings': 1, 'average': 3.0} + ratedAt: '2017-04-06T14:34:28.061+0000', + id: 'fiveStar', + aggregate: {numberOfRatings: 1, average: 3.0} } })); @@ -96,20 +96,20 @@ describe('Rating component', () => { it('should click on a star to change your vote', (done) => { spyOn(service, 'getRating').and.returnValue(of({ - 'entry': { + entry: { myRating: 1, - 'ratedAt': '2017-04-06T14:34:28.061+0000', - 'id': 'fiveStar', - 'aggregate': {'numberOfRatings': 1, 'average': 1.0} + ratedAt: '2017-04-06T14:34:28.061+0000', + id: 'fiveStar', + aggregate: {numberOfRatings: 1, average: 1.0} } })); const rateSpy = spyOn(service, 'postRating').and.returnValue(of({ - 'entry': { - 'myRating': 3, - 'ratedAt': '2017-04-06T14:36:40.731+0000', - 'id': 'fiveStar', - 'aggregate': {'numberOfRatings': 1, 'average': 3.0} + entry: { + myRating: 3, + ratedAt: '2017-04-06T14:36:40.731+0000', + id: 'fiveStar', + aggregate: {numberOfRatings: 1, average: 3.0} } })); @@ -132,11 +132,11 @@ describe('Rating component', () => { it('should click on the rated star to remove your vote', () => { spyOn(service, 'getRating').and.returnValue(of({ - 'entry': { + entry: { myRating: 3, - 'ratedAt': '2017-04-06T14:34:28.061+0000', - 'id': 'fiveStar', - 'aggregate': {'numberOfRatings': 1, 'average': 3.0} + ratedAt: '2017-04-06T14:34:28.061+0000', + id: 'fiveStar', + aggregate: {numberOfRatings: 1, average: 3.0} } })); diff --git a/lib/content-services/src/lib/social/services/rating.service.ts b/lib/content-services/src/lib/social/services/rating.service.ts index 90b127bc381..52884ba547f 100644 --- a/lib/content-services/src/lib/social/services/rating.service.ts +++ b/lib/content-services/src/lib/social/services/rating.service.ts @@ -38,6 +38,7 @@ export class RatingService implements RatingServiceInterface { /** * Gets the current user's rating for a node. + * * @param nodeId Node to get the rating from * @param ratingType Type of rating (can be "likes" or "fiveStar") * @returns The rating value @@ -51,6 +52,7 @@ export class RatingService implements RatingServiceInterface { /** * Adds the current user's rating for a node. + * * @param nodeId Target node for the rating * @param ratingType Type of rating (can be "likes" or "fiveStar") * @param vote Rating value (boolean for "likes", numeric 0..5 for "fiveStar") @@ -58,8 +60,8 @@ export class RatingService implements RatingServiceInterface { */ postRating(nodeId: string, ratingType: string, vote: any): Observable { const ratingBody: RatingBody = new RatingBody({ - 'id': ratingType, - 'myRating': vote + id: ratingType, + myRating: vote }); return from(this.ratingsApi.createRating(nodeId, ratingBody)) .pipe( @@ -69,6 +71,7 @@ export class RatingService implements RatingServiceInterface { /** * Removes the current user's rating for a node. + * * @param nodeId Target node * @param ratingType Type of rating to remove (can be "likes" or "fiveStar") * @returns Null response indicating that the operation is complete diff --git a/lib/content-services/src/lib/tag/services/tag.service.ts b/lib/content-services/src/lib/tag/services/tag.service.ts index 71b5134284d..976aca2cafe 100644 --- a/lib/content-services/src/lib/tag/services/tag.service.ts +++ b/lib/content-services/src/lib/tag/services/tag.service.ts @@ -43,6 +43,7 @@ export class TagService { /** * Gets a list of tags added to a node. + * * @param nodeId ID of the target node * @returns TagPaging object (defined in JS-API) containing the tags */ @@ -54,6 +55,7 @@ export class TagService { /** * Gets a list of all the tags already defined in the repository. + * * @param opts Options supported by JS-API * @returns TagPaging object (defined in JS-API) containing the tags */ @@ -64,6 +66,7 @@ export class TagService { /** * Adds a tag to a node. + * * @param nodeId ID of the target node * @param tagName Name of the tag to add * @returns TagEntry object (defined in JS-API) with details of the new tag @@ -85,6 +88,7 @@ export class TagService { /** * Removes a tag from a node. + * * @param nodeId ID of the target node * @param tag Name of the tag to remove * @returns Null object when the operation completes diff --git a/lib/content-services/src/lib/tag/tag-actions.component.spec.ts b/lib/content-services/src/lib/tag/tag-actions.component.spec.ts index 31dafddceee..cb41fb962b6 100644 --- a/lib/content-services/src/lib/tag/tag-actions.component.spec.ts +++ b/lib/content-services/src/lib/tag/tag-actions.component.spec.ts @@ -49,18 +49,18 @@ describe('TagActionsComponent', () => { }); const dataTag = { - 'list': { - 'pagination': { - 'count': 3, - 'hasMoreItems': false, - 'totalItems': 3, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 3, + hasMoreItems: false, + totalItems: 3, + skipCount: 0, + maxItems: 100 }, - 'entries': [{ - 'entry': {'tag': 'test1', 'id': '0ee933fa-57fc-4587-8a77-b787e814f1d2'} - }, {'entry': {'tag': 'test2', 'id': 'fcb92659-1f10-41b4-9b17-851b72a3b597'}}, { - 'entry': {'tag': 'test3', 'id': 'fb4213c0-729d-466c-9a6c-ee2e937273bf'} + entries: [{ + entry: {tag: 'test1', id: '0ee933fa-57fc-4587-8a77-b787e814f1d2'} + }, {entry: {tag: 'test2', id: 'fcb92659-1f10-41b4-9b17-851b72a3b597'}}, { + entry: {tag: 'test3', id: 'fb4213c0-729d-466c-9a6c-ee2e937273bf'} }] } }; diff --git a/lib/content-services/src/lib/tag/tag-actions.component.ts b/lib/content-services/src/lib/tag/tag-actions.component.ts index 97eedd3097c..6aa97c8bdf4 100644 --- a/lib/content-services/src/lib/tag/tag-actions.component.ts +++ b/lib/content-services/src/lib/tag/tag-actions.component.ts @@ -105,9 +105,7 @@ export class TagActionsComponent implements OnChanges, OnInit, OnDestroy { searchTag(searchTagName: string) { if (this.tagsEntries) { - return this.tagsEntries.find((currentTag) => { - return (searchTagName === currentTag.entry.tag); - }); + return this.tagsEntries.find((currentTag) => (searchTagName === currentTag.entry.tag)); } } diff --git a/lib/content-services/src/lib/tag/tag-list.component.spec.ts b/lib/content-services/src/lib/tag/tag-list.component.spec.ts index 40103b76165..f2f90ca5599 100644 --- a/lib/content-services/src/lib/tag/tag-list.component.spec.ts +++ b/lib/content-services/src/lib/tag/tag-list.component.spec.ts @@ -26,18 +26,18 @@ import { TranslateModule } from '@ngx-translate/core'; describe('TagList', () => { const dataTag = { - 'list': { - 'pagination': { - 'count': 3, - 'hasMoreItems': false, - 'totalItems': 3, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 3, + hasMoreItems: false, + totalItems: 3, + skipCount: 0, + maxItems: 100 }, - 'entries': [{ - 'entry': {'tag': 'test1', 'id': '0ee933fa-57fc-4587-8a77-b787e814f1d2'} - }, {'entry': {'tag': 'test2', 'id': 'fcb92659-1f10-41b4-9b17-851b72a3b597'}}, { - 'entry': {'tag': 'test3', 'id': 'fb4213c0-729d-466c-9a6c-ee2e937273bf'} + entries: [{ + entry: {tag: 'test1', id: '0ee933fa-57fc-4587-8a77-b787e814f1d2'} + }, {entry: {tag: 'test2', id: 'fcb92659-1f10-41b4-9b17-851b72a3b597'}}, { + entry: {tag: 'test3', id: 'fb4213c0-729d-466c-9a6c-ee2e937273bf'} }] } }; diff --git a/lib/content-services/src/lib/tag/tag-list.component.ts b/lib/content-services/src/lib/tag/tag-list.component.ts index a270ec1793c..01cb484cf7e 100644 --- a/lib/content-services/src/lib/tag/tag-list.component.ts +++ b/lib/content-services/src/lib/tag/tag-list.component.ts @@ -58,6 +58,7 @@ export class TagListComponent implements OnInit, OnDestroy { /** * Constructor + * * @param tagService */ constructor(private tagService: TagService) { diff --git a/lib/content-services/src/lib/tag/tag-node-list.component.spec.ts b/lib/content-services/src/lib/tag/tag-node-list.component.spec.ts index f49b0ed850c..5704c7f2827 100644 --- a/lib/content-services/src/lib/tag/tag-node-list.component.spec.ts +++ b/lib/content-services/src/lib/tag/tag-node-list.component.spec.ts @@ -26,18 +26,18 @@ import { TranslateModule } from '@ngx-translate/core'; describe('TagNodeList', () => { const dataTag = { - 'list': { - 'pagination': { - 'count': 3, - 'hasMoreItems': false, - 'totalItems': 3, - 'skipCount': 0, - 'maxItems': 100 + list: { + pagination: { + count: 3, + hasMoreItems: false, + totalItems: 3, + skipCount: 0, + maxItems: 100 }, - 'entries': [{ - 'entry': {'tag': 'test1', 'id': '0ee933fa-57fc-4587-8a77-b787e814f1d2'} - }, {'entry': {'tag': 'test2', 'id': 'fcb92659-1f10-41b4-9b17-851b72a3b597'}}, { - 'entry': {'tag': 'test3', 'id': 'fb4213c0-729d-466c-9a6c-ee2e937273bf'} + entries: [{ + entry: {tag: 'test1', id: '0ee933fa-57fc-4587-8a77-b787e814f1d2'} + }, {entry: {tag: 'test2', id: 'fcb92659-1f10-41b4-9b17-851b72a3b597'}}, { + entry: {tag: 'test3', id: 'fb4213c0-729d-466c-9a6c-ee2e937273bf'} }] } }; diff --git a/lib/content-services/src/lib/tag/tag-node-list.component.ts b/lib/content-services/src/lib/tag/tag-node-list.component.ts index 4571dd48a03..bf44939b787 100644 --- a/lib/content-services/src/lib/tag/tag-node-list.component.ts +++ b/lib/content-services/src/lib/tag/tag-node-list.component.ts @@ -52,6 +52,7 @@ export class TagNodeListComponent implements OnChanges, OnDestroy, OnInit { /** * Constructor + * * @param tagService */ constructor(private tagService: TagService) { diff --git a/lib/content-services/src/lib/tree-view/components/tree-view.component.spec.ts b/lib/content-services/src/lib/tree-view/components/tree-view.component.spec.ts index cc5702567b8..643d732c041 100644 --- a/lib/content-services/src/lib/tree-view/components/tree-view.component.spec.ts +++ b/lib/content-services/src/lib/tree-view/components/tree-view.component.spec.ts @@ -34,35 +34,35 @@ describe('TreeViewComponent', () => { let component: any; const fakeNodeList: TreeBaseNode[] = [ - { + { nodeId: 'fake-node-id', name: 'fake-node-name', level: 0, expandable: true, - node: { entry: { name: 'fake-node-name', id: 'fake-node-id' } } + node: { entry: { name: 'fake-node-name', id: 'fake-node-id' } } as any } ]; const fakeChildrenList: TreeBaseNode[] = [ - { nodeId: 'fake-child-id', name: 'fake-child-name', level: 0, expandable: true, node: {} }, - { nodeId: 'fake-second-id', name: 'fake-second-name', level: 0, expandable: true, node: {} } + { nodeId: 'fake-child-id', name: 'fake-child-name', level: 0, expandable: true, node: {} as any }, + { nodeId: 'fake-second-id', name: 'fake-second-name', level: 0, expandable: true, node: {} as any } ]; const fakeNextChildrenList: TreeBaseNode[] = [ - { + { nodeId: 'fake-next-child-id', name: 'fake-next-child-name', level: 0, expandable: true, - node: {} + node: {} as any }, - { + { nodeId: 'fake-next-second-id', name: 'fake-next-second-name', level: 0, expandable: true, - node: {} + node: {} as any } ]; - const returnRootOrChildrenNode = function (nodeId: string) { + const returnRootOrChildrenNode = (nodeId: string) => { if (nodeId === '9999999') { return of(fakeNodeList); } else if (nodeId === 'fake-second-id') { @@ -89,7 +89,7 @@ describe('TreeViewComponent', () => { spyOn(treeService, 'getTreeNodes').and.callFake((nodeId) => returnRootOrChildrenNode(nodeId)); component.nodeId = '9999999'; const changeNodeId = new SimpleChange(null, '9999999', true); - component.ngOnChanges({ 'nodeId': changeNodeId }); + component.ngOnChanges({ nodeId: changeNodeId }); fixture.detectChanges(); }); @@ -119,7 +119,7 @@ describe('TreeViewComponent', () => { it('should show only the correct subfolders when the nodeId is changed', async () => { component.nodeId = 'fake-second-id'; const changeNodeId = new SimpleChange('9999999', 'fake-second-id', true); - component.ngOnChanges({ 'nodeId': changeNodeId }); + component.ngOnChanges({ nodeId: changeNodeId }); fixture.detectChanges(); await fixture.whenStable(); @@ -254,7 +254,7 @@ describe('TreeViewComponent', () => { done(); }); const changeNodeId = new SimpleChange(null, 'Poopoovic', true); - fixture.componentInstance.ngOnChanges({ 'nodeId': changeNodeId }); + fixture.componentInstance.ngOnChanges({ nodeId: changeNodeId }); fixture.detectChanges(); }); }); diff --git a/lib/content-services/src/lib/tree-view/services/tree-view.service.ts b/lib/content-services/src/lib/tree-view/services/tree-view.service.ts index 521972e7ba8..3a272a3b08d 100644 --- a/lib/content-services/src/lib/tree-view/services/tree-view.service.ts +++ b/lib/content-services/src/lib/tree-view/services/tree-view.service.ts @@ -33,9 +33,7 @@ export class TreeViewService { getTreeNodes(nodeId): Observable { return this.nodeApi.getNodeChildren(nodeId) .pipe( - map((nodePage: NodePaging) => { - return nodePage.list.entries.filter((node) => node.entry.isFolder ? node : null); - }), + map((nodePage: NodePaging) => nodePage.list.entries.filter((node) => node.entry.isFolder ? node : null)), map((nodes: NodeEntry[]) => nodes.map((node) => new TreeBaseNode(node))) ); } diff --git a/lib/content-services/src/lib/upload/components/base-upload/upload-base.spec.ts b/lib/content-services/src/lib/upload/components/base-upload/upload-base.spec.ts index 93dfc0823af..87a520d8cfe 100644 --- a/lib/content-services/src/lib/upload/components/base-upload/upload-base.spec.ts +++ b/lib/content-services/src/lib/upload/components/base-upload/upload-base.spec.ts @@ -72,7 +72,7 @@ describe('UploadBase', () => { spyOn(uploadService, 'uploadFilesInTheQueue').and.stub(); component.beginUpload.subscribe(() => done()); - const file = { name: 'bigFile.png', size: 1000 }; + const file = { name: 'bigFile.png', size: 1000 } as File; component.uploadFiles([file]); fixture.detectChanges(); }); @@ -86,7 +86,7 @@ describe('UploadBase', () => { event.preventDefault(); prevented = true; }); - const file = { name: 'bigFile.png', size: 1000 }; + const file = { name: 'bigFile.png', size: 1000 } as File; component.uploadFiles([file]); tick(); @@ -106,7 +106,7 @@ describe('UploadBase', () => { event.preventDefault(); prevented = true; }); - const file = { name: 'bigFile.png', size: 1000 }; + const file = { name: 'bigFile.png', size: 1000 } as File; component.uploadFiles([file]); tick(); @@ -132,7 +132,7 @@ describe('UploadBase', () => { uploadEvent = event; event.preventDefault(); }); - const file = { name: 'bigFile.png', size: 1000 }; + const file = { name: 'bigFile.png', size: 1000 } as File; component.uploadFiles([file]); tick(); @@ -147,11 +147,11 @@ describe('UploadBase', () => { describe('fileSize', () => { const files: File[] = [ - { name: 'bigFile.png', size: 1000 }, - { name: 'smallFile.png', size: 10 } + { name: 'bigFile.png', size: 1000 } as File, + { name: 'smallFile.png', size: 10 } as File ]; - let addToQueueSpy; + let addToQueueSpy: jasmine.Spy;; beforeEach(() => { addToQueueSpy = spyOn(uploadService, 'addToQueue'); @@ -177,7 +177,7 @@ describe('UploadBase', () => { it('should allow file of 0 size when the max file size is set to 0', () => { const zeroFiles: File[] = [ - { name: 'zeroFile.png', size: 0 } + { name: 'zeroFile.png', size: 0 } as File ]; component.maxFilesSize = 0; @@ -217,12 +217,12 @@ describe('UploadBase', () => { describe('uploadFiles', () => { const files: File[] = [ - { name: 'phobos.jpg' }, - { name: 'deimos.png' }, - { name: 'ganymede.bmp' } + { name: 'phobos.jpg' } as File, + { name: 'deimos.png' } as File, + { name: 'ganymede.bmp' } as File ]; - let addToQueueSpy; + let addToQueueSpy: jasmine.Spy;; beforeEach(() => { addToQueueSpy = spyOn(uploadService, 'addToQueue'); @@ -325,10 +325,10 @@ describe('UploadBase', () => { describe('Comments', () => { - let addToQueueSpy; + let addToQueueSpy: jasmine.Spy;; const files: File[] = [ - { name: 'phobos.jpg' } + { name: 'phobos.jpg' } as File ]; beforeEach(() => { @@ -353,10 +353,10 @@ describe('UploadBase', () => { describe('Versions', () => { - let addToQueueSpy; + let addToQueueSpy: jasmine.Spy;; const files: File[] = [ - { name: 'phobos.jpg' } + { name: 'phobos.jpg' } as File ]; beforeEach(() => { @@ -398,10 +398,10 @@ describe('UploadBase', () => { describe('Node Type', () => { - let addToQueueSpy; + let addToQueueSpy: jasmine.Spy; const files: File[] = [ - { name: 'process.bpmn' } + { name: 'process.bpmn' } as File ]; beforeEach(() => { diff --git a/lib/content-services/src/lib/upload/components/base-upload/upload-base.ts b/lib/content-services/src/lib/upload/components/base-upload/upload-base.ts index f05ddec9d24..80ed472138c 100644 --- a/lib/content-services/src/lib/upload/components/base-upload/upload-base.ts +++ b/lib/content-services/src/lib/upload/components/base-upload/upload-base.ts @@ -97,22 +97,19 @@ export abstract class UploadBase implements OnInit, OnDestroy { /** * Upload a list of file in the specified path + * * @param files */ uploadFiles(files: File[]): void { const filteredFiles: FileModel[] = files - .map((file: File) => { - return this.createFileModel(file, this.rootFolderId, (( file).webkitRelativePath || '').replace(/\/[^\/]*$/, '')); - }); + .map((file: File) => this.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^\/]*$/, ''))); this.uploadQueue(filteredFiles); } uploadFilesInfo(files: FileInfo[]): void { const filteredFiles: FileModel[] = files - .map((fileInfo: FileInfo) => { - return this.createFileModel(fileInfo.file, this.rootFolderId, fileInfo.relativeFolder); - }); + .map((fileInfo: FileInfo) => this.createFileModel(fileInfo.file, this.rootFolderId, fileInfo.relativeFolder)); this.uploadQueue(filteredFiles); } @@ -170,8 +167,8 @@ export abstract class UploadBase implements OnInit, OnDestroy { comment: this.comment, majorVersion: this.majorVersion, newVersion: this.versioning, - parentId: parentId, - path: path, + parentId, + path, nodeType: this.nodeType }, id); } diff --git a/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.spec.ts b/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.spec.ts index 539336e7b0e..7a8fe348cec 100644 --- a/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.spec.ts +++ b/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.spec.ts @@ -53,8 +53,8 @@ describe('FileUploadingDialogComponent', () => { emitter = new EventEmitter(); fileList = [ - new FileModel( { name: 'fake-name', size: 10 }), - new FileModel( { name: 'fake-name2', size: 10 }) + new FileModel({ name: 'fake-name', size: 10 } as File), + new FileModel({ name: 'fake-name2', size: 10 } as File) ]; fixture.detectChanges(); @@ -229,7 +229,7 @@ describe('FileUploadingDialogComponent', () => { describe('cancelAllUploads()', () => { beforeEach(() => { - ( component).uploadList = { + (component as any).uploadList = { cancelAllFiles: jasmine.createSpy('cancelAllFiles') }; }); diff --git a/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.ts b/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.ts index ce2db4d9d34..48b1a72f9c2 100644 --- a/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.ts +++ b/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.ts @@ -134,9 +134,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy { .pipe(takeUntil(this.onDestroy$)) .subscribe(objId => { if (this.filesUploadingList) { - const uploadedFile = this.filesUploadingList.find((file) => { - return file.data ? file.data.entry.id === objId : false; - }); + const uploadedFile = this.filesUploadingList.find((file) => file.data ? file.data.entry.id === objId : false); if (uploadedFile) { uploadedFile.status = FileUploadStatus.Cancelled; this.changeDetector.detectChanges(); diff --git a/lib/content-services/src/lib/upload/components/file-uploading-list-row.component.spec.ts b/lib/content-services/src/lib/upload/components/file-uploading-list-row.component.spec.ts index 1f842b329a2..ad804d9a3a2 100644 --- a/lib/content-services/src/lib/upload/components/file-uploading-list-row.component.spec.ts +++ b/lib/content-services/src/lib/upload/components/file-uploading-list-row.component.spec.ts @@ -16,7 +16,7 @@ */ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FileModel, FileUploadOptions, FileUploadStatus, setupTestBed } from '@alfresco/adf-core'; +import { FileModel, FileUploadStatus, setupTestBed } from '@alfresco/adf-core'; import { FileUploadingListRowComponent } from './file-uploading-list-row.component'; import { ContentTestingModule } from '../../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; @@ -25,7 +25,7 @@ import { By } from '@angular/platform-browser'; describe('FileUploadingListRowComponent', () => { let fixture: ComponentFixture; let component: FileUploadingListRowComponent; - const file = new FileModel( { name: 'fake-name' }); + const file = new FileModel({ name: 'fake-name' } as File); setupTestBed({ imports: [ @@ -60,8 +60,8 @@ describe('FileUploadingListRowComponent', () => { }); it('should render node version when upload a version file', () => { - component.file = new FileModel( { name: 'fake-name' }); - component.file.options = { newVersion: true }; + component.file = new FileModel({ name: 'fake-name' } as File); + component.file.options = { newVersion: true }; component.file.data = { entry: { properties: { 'cm:versionLabel': '1' } } }; fixture.detectChanges(); @@ -73,8 +73,8 @@ describe('FileUploadingListRowComponent', () => { it('should not emit remove event on a version file', () => { spyOn(component.remove, 'emit'); - component.file = new FileModel( { name: 'fake-name' }); - component.file.options = { newVersion: true }; + component.file = new FileModel({ name: 'fake-name' } as File); + component.file.options = { newVersion: true }; component.file.data = { entry: { properties: { 'cm:versionLabel': '1' } } }; component.file.status = FileUploadStatus.Complete; @@ -86,7 +86,7 @@ describe('FileUploadingListRowComponent', () => { }); it('should show cancel button when upload is in progress', async () => { - component.file = new FileModel( { name: 'fake-name' }); + component.file = new FileModel({ name: 'fake-name' } as File); component.file.data = { entry: { properties: { 'cm:versionLabel': '1' } } }; component.file.status = FileUploadStatus.Progress; @@ -98,7 +98,7 @@ describe('FileUploadingListRowComponent', () => { }); it('should show cancel button when upload is starting', async () => { - component.file = new FileModel( { name: 'fake-name' }); + component.file = new FileModel({ name: 'fake-name' } as File); component.file.data = { entry: { properties: { 'cm:versionLabel': '1' } } }; component.file.status = FileUploadStatus.Starting; @@ -110,7 +110,7 @@ describe('FileUploadingListRowComponent', () => { }); it('should hide cancel button when upload is complete', async () => { - component.file = new FileModel( { name: 'fake-name' }); + component.file = new FileModel({ name: 'fake-name' } as File); component.file.data = { entry: { properties: { 'cm:versionLabel': '1' } } }; component.file.status = FileUploadStatus.Complete; @@ -122,7 +122,7 @@ describe('FileUploadingListRowComponent', () => { }); it('should provide tooltip for the cancel button', async () => { - component.file = new FileModel( { name: 'fake-name' }); + component.file = new FileModel({ name: 'fake-name' } as File); component.file.data = { entry: { properties: { 'cm:versionLabel': '1' } } }; component.file.status = FileUploadStatus.Progress; diff --git a/lib/content-services/src/lib/upload/components/file-uploading-list-row.component.ts b/lib/content-services/src/lib/upload/components/file-uploading-list-row.component.ts index 017152ed31c..0c1ccea7a17 100644 --- a/lib/content-services/src/lib/upload/components/file-uploading-list-row.component.ts +++ b/lib/content-services/src/lib/upload/components/file-uploading-list-row.component.ts @@ -34,6 +34,7 @@ export class FileUploadingListRowComponent { @Output() remove: EventEmitter = new EventEmitter(); + // eslint-disable-next-line @typescript-eslint/naming-convention FileUploadStatus = FileUploadStatus; onCancel(file: FileModel): void { diff --git a/lib/content-services/src/lib/upload/components/file-uploading-list.component.spec.ts b/lib/content-services/src/lib/upload/components/file-uploading-list.component.spec.ts index 38cbe8c6911..d35b25c5245 100644 --- a/lib/content-services/src/lib/upload/components/file-uploading-list.component.spec.ts +++ b/lib/content-services/src/lib/upload/components/file-uploading-list.component.spec.ts @@ -16,7 +16,7 @@ */ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { TranslationService, FileUploadStatus, NodesApiService, UploadService, setupTestBed } from '@alfresco/adf-core'; +import { TranslationService, FileUploadStatus, NodesApiService, UploadService, setupTestBed, FileModel } from '@alfresco/adf-core'; import { of, throwError } from 'rxjs'; import { FileUploadingListComponent } from './file-uploading-list.component'; import { ContentTestingModule } from '../../testing/content.testing.module'; @@ -115,7 +115,7 @@ describe('FileUploadingListComponent', () => { }); it('should set `Deleted` status on file version instances when original is removed', () => { - component.files = [ + component.files = [ { data: { entry: { id: 'nodeId' } @@ -125,7 +125,7 @@ describe('FileUploadingListComponent', () => { options: { newVersion: false } - }, + } as FileModel, { data: { entry: { id: 'nodeId' } @@ -135,7 +135,7 @@ describe('FileUploadingListComponent', () => { options: { newVersion: true } - } + } as FileModel ]; spyOn(nodesApiService, 'deleteNode').and.returnValue(of(component.files[0])); @@ -164,19 +164,19 @@ describe('FileUploadingListComponent', () => { describe('cancelAllFiles()', () => { beforeEach(() => { - component.files = [ + component.files = [ { data: { entry: { id: '1' } }, status: FileUploadStatus.Cancelled - }, + } as FileModel, { data: { entry: { id: '2' } }, status: FileUploadStatus.Error - } + } as FileModel ]; }); @@ -215,55 +215,55 @@ describe('FileUploadingListComponent', () => { describe('isUploadCompleted()', () => { it('should return false when at least one file is in progress', () => { - component.files = [ - { status: FileUploadStatus.Progress }, - { status: FileUploadStatus.Complete } + component.files = [ + { status: FileUploadStatus.Progress } as FileModel, + { status: FileUploadStatus.Complete } as FileModel ]; expect(component.isUploadCompleted()).toBe(false); }); it('should return false when at least one file is in pending', () => { - component.files = [ - { status: FileUploadStatus.Pending }, - { status: FileUploadStatus.Complete } + component.files = [ + { status: FileUploadStatus.Pending } as FileModel, + { status: FileUploadStatus.Complete } as FileModel ]; expect(component.isUploadCompleted()).toBe(false); }); it('should return false when at least one file is in starting state', () => { - component.files = [ - { status: FileUploadStatus.Starting }, - { status: FileUploadStatus.Complete } + component.files = [ + { status: FileUploadStatus.Starting } as FileModel, + { status: FileUploadStatus.Complete } as FileModel ]; expect(component.isUploadCompleted()).toBe(false); }); it('should return false when files are cancelled', () => { - component.files = [ - { status: FileUploadStatus.Cancelled }, - { status: FileUploadStatus.Cancelled } + component.files = [ + { status: FileUploadStatus.Cancelled } as FileModel, + { status: FileUploadStatus.Cancelled } as FileModel ]; expect(component.isUploadCompleted()).toBe(false); }); it('should return true when there are deleted files', () => { - component.files = [ - { status: FileUploadStatus.Complete }, - { status: FileUploadStatus.Deleted } + component.files = [ + { status: FileUploadStatus.Complete } as FileModel, + { status: FileUploadStatus.Deleted } as FileModel ]; expect(component.isUploadCompleted()).toBe(true); }); it('should return true when none of the files is in progress', () => { - component.files = [ - { status: FileUploadStatus.Error }, - { status: FileUploadStatus.Cancelled }, - { status: FileUploadStatus.Complete } + component.files = [ + { status: FileUploadStatus.Error } as FileModel, + { status: FileUploadStatus.Cancelled } as FileModel, + { status: FileUploadStatus.Complete } as FileModel ]; expect(component.isUploadCompleted()).toBe(true); @@ -272,58 +272,58 @@ describe('FileUploadingListComponent', () => { describe('isUploadCancelled()', () => { it('should return false when not all files are cancelled', () => { - component.files = [ - { status: FileUploadStatus.Complete }, - { status: FileUploadStatus.Cancelled }, - { status: FileUploadStatus.Error } + component.files = [ + { status: FileUploadStatus.Complete } as FileModel, + { status: FileUploadStatus.Cancelled } as FileModel, + { status: FileUploadStatus.Error } as FileModel ]; expect(component.isUploadCancelled()).toBe(false); }); it('should return false when there are no cancelled files', () => { - component.files = [ - { status: FileUploadStatus.Complete }, - { status: FileUploadStatus.Error }, - { status: FileUploadStatus.Error } + component.files = [ + { status: FileUploadStatus.Complete } as FileModel, + { status: FileUploadStatus.Error } as FileModel, + { status: FileUploadStatus.Error } as FileModel ]; expect(component.isUploadCancelled()).toBe(false); }); it('should return false when there is at least one file in progress', () => { - component.files = [ - { status: FileUploadStatus.Progress }, - { status: FileUploadStatus.Error }, - { status: FileUploadStatus.Error } + component.files = [ + { status: FileUploadStatus.Progress } as FileModel, + { status: FileUploadStatus.Error } as FileModel, + { status: FileUploadStatus.Error } as FileModel ]; expect(component.isUploadCancelled()).toBe(false); }); it('should return false when there is at least one file in pending', () => { - component.files = [ - { status: FileUploadStatus.Pending }, - { status: FileUploadStatus.Error }, - { status: FileUploadStatus.Error } + component.files = [ + { status: FileUploadStatus.Pending } as FileModel, + { status: FileUploadStatus.Error } as FileModel, + { status: FileUploadStatus.Error } as FileModel ]; expect(component.isUploadCancelled()).toBe(false); }); it('should return true when all files are aborted', () => { - component.files = [ - { status: FileUploadStatus.Aborted } + component.files = [ + { status: FileUploadStatus.Aborted } as FileModel ]; expect(component.isUploadCancelled()).toBe(true); }); it('should return true when all files are cancelled', () => { - component.files = [ - { status: FileUploadStatus.Cancelled }, - { status: FileUploadStatus.Cancelled }, - { status: FileUploadStatus.Aborted } + component.files = [ + { status: FileUploadStatus.Cancelled } as FileModel, + { status: FileUploadStatus.Cancelled } as FileModel, + { status: FileUploadStatus.Aborted } as FileModel ]; expect(component.isUploadCancelled()).toBe(true); diff --git a/lib/content-services/src/lib/upload/components/file-uploading-list.component.ts b/lib/content-services/src/lib/upload/components/file-uploading-list.component.ts index 406f1e19828..180b28b1e8b 100644 --- a/lib/content-services/src/lib/upload/components/file-uploading-list.component.ts +++ b/lib/content-services/src/lib/upload/components/file-uploading-list.component.ts @@ -39,6 +39,7 @@ import { map, catchError } from 'rxjs/operators'; styleUrls: ['./file-uploading-list.component.scss'] }) export class FileUploadingListComponent { + // eslint-disable-next-line @typescript-eslint/naming-convention FileUploadStatus = FileUploadStatus; @ContentChild(TemplateRef) diff --git a/lib/content-services/src/lib/upload/components/upload-button.component.spec.ts b/lib/content-services/src/lib/upload/components/upload-button.component.spec.ts index 571d21ea0e2..0b01cb226c4 100644 --- a/lib/content-services/src/lib/upload/components/upload-button.component.spec.ts +++ b/lib/content-services/src/lib/upload/components/upload-button.component.spec.ts @@ -216,8 +216,8 @@ describe('UploadButtonComponent', () => { describe('fileSize', () => { const files: File[] = [ - { name: 'bigFile.png', size: 1000 }, - { name: 'smallFile.png', size: 10 } + { name: 'bigFile.png', size: 1000 } as File, + { name: 'smallFile.png', size: 10 } as File ]; let addToQueueSpy; @@ -246,7 +246,7 @@ describe('UploadButtonComponent', () => { it('should allow file of 0 size when the max file size is set to 0', () => { const zeroFiles: File[] = [ - { name: 'zeroFile.png', size: 0 } + { name: 'zeroFile.png', size: 0 } as File ]; component.maxFilesSize = 0; @@ -286,9 +286,9 @@ describe('UploadButtonComponent', () => { describe('uploadFiles', () => { const files: File[] = [ - { name: 'phobos.jpg' }, - { name: 'deimos.png' }, - { name: 'ganymede.bmp' } + { name: 'phobos.jpg' } as File, + { name: 'deimos.png' } as File, + { name: 'ganymede.bmp' } as File ]; let addToQueueSpy; diff --git a/lib/content-services/src/lib/upload/components/upload-drag-area.component.spec.ts b/lib/content-services/src/lib/upload/components/upload-drag-area.component.spec.ts index 7a391e13b75..9345895bad8 100644 --- a/lib/content-services/src/lib/upload/components/upload-drag-area.component.spec.ts +++ b/lib/content-services/src/lib/upload/components/upload-drag-area.component.spec.ts @@ -22,72 +22,68 @@ import { ContentTestingModule } from '../../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; import { mockUploadSuccessPromise, mockUploadErrorPromise } from '../../mock/upload.service.mock'; -function getFakeShareDataRow(allowableOperations = ['delete', 'update', 'create']) { - return { - obj: { - entry: { - createdAt: '2017-06-04T04:32:15.597Z', - path: { - name: '/Company Home/User Homes/Test', - isComplete: true, - elements: [ - { - id: '94acfc73-7014-4475-9bd9-93a2162f0f8c', - name: 'Company Home' - }, - { - id: '55052317-7e59-4058-8e07-769f41e615e1', - name: 'User Homes' - }, - { - id: '70e1cc6a-6918-468a-b84a-1048093b06fd', - name: 'Test' - } - ] - }, - isFolder: true, - name: 'pippo', - id: '7462d28e-bd43-4b91-9e7b-0d71598680ac', - nodeType: 'cm:folder', - allowableOperations - } +const getFakeShareDataRow = (allowableOperations = ['delete', 'update', 'create']) => ({ + obj: { + entry: { + createdAt: '2017-06-04T04:32:15.597Z', + path: { + name: '/Company Home/User Homes/Test', + isComplete: true, + elements: [ + { + id: '94acfc73-7014-4475-9bd9-93a2162f0f8c', + name: 'Company Home' + }, + { + id: '55052317-7e59-4058-8e07-769f41e615e1', + name: 'User Homes' + }, + { + id: '70e1cc6a-6918-468a-b84a-1048093b06fd', + name: 'Test' + } + ] + }, + isFolder: true, + name: 'pippo', + id: '7462d28e-bd43-4b91-9e7b-0d71598680ac', + nodeType: 'cm:folder', + allowableOperations } - }; -} - -function getFakeFileShareRow(allowableOperations = ['delete', 'update', 'create']) { - return { - obj: { - entry: { - createdAt: '2017-06-04T04:32:15.597Z', - path: { - name: '/Company Home/User Homes/Test', - isComplete: true, - elements: [ - { - id: '94acfc73-7014-4475-9bd9-93a2162f0f8c', - name: 'Company Home' - }, - { - id: '55052317-7e59-4058-8e07-769f41e615e1', - name: 'User Homes' - }, - { - id: '70e1cc6a-6918-468a-b84a-1048093b06fd', - name: 'Test' - } - ] - }, - isFolder: false, - isFile: true, - name: 'pippo', - id: '7462d28e-bd43-4b91-9e7b-0d71598680ac', - nodeType: 'cm:folder', - allowableOperations - } + } +}); + +const getFakeFileShareRow = (allowableOperations = ['delete', 'update', 'create']) => ({ + obj: { + entry: { + createdAt: '2017-06-04T04:32:15.597Z', + path: { + name: '/Company Home/User Homes/Test', + isComplete: true, + elements: [ + { + id: '94acfc73-7014-4475-9bd9-93a2162f0f8c', + name: 'Company Home' + }, + { + id: '55052317-7e59-4058-8e07-769f41e615e1', + name: 'User Homes' + }, + { + id: '70e1cc6a-6918-468a-b84a-1048093b06fd', + name: 'Test' + } + ] + }, + isFolder: false, + isFile: true, + name: 'pippo', + id: '7462d28e-bd43-4b91-9e7b-0d71598680ac', + nodeType: 'cm:folder', + allowableOperations } - }; -} + } +}); describe('UploadDragAreaComponent', () => { @@ -153,13 +149,11 @@ describe('UploadDragAreaComponent', () => { const itemEntity = { isDirectory: true, - createReader: () => { - return { - readEntries: (cb) => { - cb([]); - } - }; - } + createReader: () => ({ + readEntries: (cb) => { + cb([]); + } + }) }; component.onFolderEntityDropped(itemEntity); @@ -230,9 +224,9 @@ describe('UploadDragAreaComponent', () => { component.acceptedFilesType = '.jpg,.pdf'; fixture.detectChanges(); const files: File[] = [ - { name: 'phobos.jpg' }, - { name: 'deimos.pdf' }, - { name: 'ganymede.bmp' } + { name: 'phobos.jpg' } as File, + { name: 'deimos.pdf' } as File, + { name: 'ganymede.bmp' } as File ]; component.onFilesDropped(files); diff --git a/lib/content-services/src/lib/upload/components/upload-drag-area.component.ts b/lib/content-services/src/lib/upload/components/upload-drag-area.component.ts index 5748da27dc6..63d7e488f10 100644 --- a/lib/content-services/src/lib/upload/components/upload-drag-area.component.ts +++ b/lib/content-services/src/lib/upload/components/upload-drag-area.component.ts @@ -26,7 +26,7 @@ import { UploadBase } from './base-upload/upload-base'; selector: 'adf-upload-drag-area', templateUrl: './upload-drag-area.component.html', styleUrls: ['./upload-drag-area.component.scss'], - host: {'class': 'adf-upload-drag-area'}, + host: { class: 'adf-upload-drag-area' }, viewProviders: [ {provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadDragAreaComponent)} ], diff --git a/lib/content-services/src/lib/upload/components/upload-version-button.component.ts b/lib/content-services/src/lib/upload/components/upload-version-button.component.ts index 7d8ca956473..963d5e61e7e 100644 --- a/lib/content-services/src/lib/upload/components/upload-version-button.component.ts +++ b/lib/content-services/src/lib/upload/components/upload-version-button.component.ts @@ -37,7 +37,7 @@ export class UploadVersionButtonComponent extends UploadButtonComponent implemen node: Node; protected createFileModel(file: File): FileModel { - const fileModel = super.createFileModel(file, this.rootFolderId, (( file).webkitRelativePath || '').replace(/\/[^\/]*$/, ''), this.node.id); + const fileModel = super.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^\/]*$/, ''), this.node.id); if (!this.isFileAcceptable(fileModel)) { const message = this.translationService.instant('FILE_UPLOAD.VERSION.MESSAGES.INCOMPATIBLE_VERSION'); diff --git a/lib/content-services/src/lib/upload/directives/file-draggable.directive.spec.ts b/lib/content-services/src/lib/upload/directives/file-draggable.directive.spec.ts index 52925a9d9c8..bd64e1a9f78 100644 --- a/lib/content-services/src/lib/upload/directives/file-draggable.directive.spec.ts +++ b/lib/content-services/src/lib/upload/directives/file-draggable.directive.spec.ts @@ -61,19 +61,17 @@ describe('FileDraggableDirective', () => { fixture.destroy(); }); - function createEvent(eventName: string): DragEvent { - return new DragEvent(eventName, { - bubbles: true, - cancelable: true, - dataTransfer: new DataTransfer() - }); - } + const createEvent = (eventName: string): DragEvent => new DragEvent(eventName, { + bubbles: true, + cancelable: true, + dataTransfer: new DataTransfer() + }); - function raiseEvent(eventName: string): DragEvent { + const raiseEvent = (eventName: string): DragEvent => { const event = createEvent(eventName); testContent.dispatchEvent(event); return event; - } + }; it('should always be enabled by default', () => { expect(directive.enabled).toBeTruthy(); diff --git a/lib/content-services/src/lib/upload/directives/file-draggable.directive.ts b/lib/content-services/src/lib/upload/directives/file-draggable.directive.ts index 10b883f0d95..55a14209520 100644 --- a/lib/content-services/src/lib/upload/directives/file-draggable.directive.ts +++ b/lib/content-services/src/lib/upload/directives/file-draggable.directive.ts @@ -66,6 +66,7 @@ export class FileDraggableDirective implements OnInit, OnDestroy { /** * Method called when files is dropped in the drag and drop area. + * * @param event DOM event. */ onDropFiles(event: any): void { @@ -77,6 +78,7 @@ export class FileDraggableDirective implements OnInit, OnDestroy { if (items) { const files: File[] = []; + // eslint-disable-next-line @typescript-eslint/prefer-for-of for (let i = 0; i < items.length; i++) { if (items[i].webkitGetAsEntry) { const item = items[i].webkitGetAsEntry(); diff --git a/lib/content-services/src/lib/version-manager/content-version.service.ts b/lib/content-services/src/lib/version-manager/content-version.service.ts index 7cd474f651c..3847b580eab 100644 --- a/lib/content-services/src/lib/version-manager/content-version.service.ts +++ b/lib/content-services/src/lib/version-manager/content-version.service.ts @@ -35,6 +35,7 @@ export class ContentVersionService { /** * Get content URL for the given nodeId and specific version. + * * @param nodeId The ID of the node * @param versionId The ID of the version * @param attachment Retrieve content as an attachment for download diff --git a/lib/content-services/src/lib/version-manager/version-list.component.spec.ts b/lib/content-services/src/lib/version-manager/version-list.component.spec.ts index fc373435bbc..cbb034d72c1 100644 --- a/lib/content-services/src/lib/version-manager/version-list.component.spec.ts +++ b/lib/content-services/src/lib/version-manager/version-list.component.spec.ts @@ -22,7 +22,7 @@ import { VersionListComponent } from './version-list.component'; import { setupTestBed } from '@alfresco/adf-core'; import { MatDialog } from '@angular/material/dialog'; import { of } from 'rxjs'; -import { Node, VersionPaging, VersionEntry, NodeEntry } from '@alfresco/js-api'; +import { Node, VersionPaging, VersionEntry } from '@alfresco/js-api'; import { ContentTestingModule } from '../testing/content.testing.module'; import { TranslateModule } from '@ngx-translate/core'; import { ContentVersionService } from './content-version.service'; @@ -37,12 +37,8 @@ describe('VersionListComponent', () => { const versionId = '1.0'; const versionTest = [ - { - entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } - }, - { - entry: { name: 'test-file-name-two', id: '1.0', versionComment: 'test-version-comment' } - } + { entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } } as VersionEntry, + { entry: { name: 'test-file-name-two', id: '1.0', versionComment: 'test-version-comment' } } as VersionEntry ]; setupTestBed({ @@ -64,10 +60,10 @@ describe('VersionListComponent', () => { contentVersionService = TestBed.inject(ContentVersionService); component = fixture.componentInstance; - component.node = { id: nodeId, allowableOperations: ['update'] }; + component.node = { id: nodeId, allowableOperations: ['update'] } as Node; spyOn(component, 'downloadContent').and.stub(); - spyOn(component['nodesApi'], 'getNode').and.returnValue(Promise.resolve( { entry: { id: 'nodeInfoId' } })); + spyOn(component['nodesApi'], 'getNode').and.returnValue(Promise.resolve({ entry: { id: 'nodeInfoId' } })); }); it('should raise confirmation dialog on delete', () => { @@ -75,9 +71,7 @@ describe('VersionListComponent', () => { component.versions = versionTest; spyOn(dialog, 'open').and.returnValue({ - afterClosed() { - return of(false); - } + afterClosed: () => of(false) } as any); component.deleteVersion('1'); @@ -89,9 +83,7 @@ describe('VersionListComponent', () => { fixture.detectChanges(); component.versions = versionTest; spyOn(dialog, 'open').and.returnValue({ - afterClosed() { - return of(true); - } + afterClosed: () => of(true) } as any); spyOn(component['versionsApi'], 'deleteVersion').and.returnValue(Promise.resolve(true)); @@ -106,9 +98,7 @@ describe('VersionListComponent', () => { component.versions = versionTest; spyOn(dialog, 'open').and.returnValue({ - afterClosed() { - return of(false); - } + afterClosed: () => of(false) } as any); spyOn(component['versionsApi'], 'deleteVersion').and.returnValue(Promise.resolve(true)); @@ -157,17 +147,15 @@ describe('VersionListComponent', () => { it('should show the versions after loading', (done) => { fixture.detectChanges(); - spyOn(component['versionsApi'], 'listVersionHistory').and.callFake(() => { - return Promise.resolve(new VersionPaging({ - list: { - entries: [ - { - entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } - } - ] - } - })); - }); + spyOn(component['versionsApi'], 'listVersionHistory').and.callFake(() => Promise.resolve(new VersionPaging({ + list: { + entries: [ + { + entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } + } + ] + } + }))); component.ngOnChanges(); @@ -311,7 +299,7 @@ describe('VersionListComponent', () => { fixture.detectChanges(); tick(); - expect(component.restored.emit).toHaveBeenCalledWith( { id: 'nodeInfoId' }); + expect(component.restored.emit).toHaveBeenCalledWith({ id: 'nodeInfoId' }); })); it('should reload the version list after a version restore', fakeAsync(() => { @@ -337,17 +325,15 @@ describe('VersionListComponent', () => { beforeEach(() => { fixture.detectChanges(); component.node = new Node({ id: nodeId }); - spyOn(component['versionsApi'], 'listVersionHistory').and.callFake(() => { - return Promise.resolve(new VersionPaging({ - list: { - entries: [ - { - entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } - } - ] - } - })); - }); + spyOn(component['versionsApi'], 'listVersionHistory').and.callFake(() => Promise.resolve(new VersionPaging({ + list: { + entries: [ + { + entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } + } + ] + } + }))); component.ngOnChanges(); }); @@ -385,21 +371,19 @@ describe('VersionListComponent', () => { beforeEach(() => { fixture.detectChanges(); - component.node = { id: nodeId }; - spyOn(component['versionsApi'], 'listVersionHistory').and.callFake(() => { - return Promise.resolve(new VersionPaging({ - list: { - entries: [ - { - entry: { name: 'test-file-two', id: '1.1', versionComment: 'test-version-comment' } - }, - { - entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } - } - ] - } - })); - }); + component.node = { id: nodeId } as Node; + spyOn(component['versionsApi'], 'listVersionHistory').and.callFake(() => Promise.resolve(new VersionPaging({ + list: { + entries: [ + { + entry: { name: 'test-file-two', id: '1.1', versionComment: 'test-version-comment' } + }, + { + entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } + } + ] + } + }))); component.ngOnChanges(); }); @@ -435,21 +419,19 @@ describe('VersionListComponent', () => { beforeEach(() => { fixture.detectChanges(); - component.node = { id: nodeId, allowableOperations: ['update', 'delete'] }; - spyOn(component['versionsApi'], 'listVersionHistory').and.callFake(() => { - return Promise.resolve(new VersionPaging({ - list: { - entries: [ - { - entry: { name: 'test-file-name', id: '1.1', versionComment: 'test-version-comment' } - }, - { - entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } - } - ] - } - })); - }); + component.node = { id: nodeId, allowableOperations: ['update', 'delete'] } as Node; + spyOn(component['versionsApi'], 'listVersionHistory').and.callFake(() => Promise.resolve(new VersionPaging({ + list: { + entries: [ + { + entry: { name: 'test-file-name', id: '1.1', versionComment: 'test-version-comment' } + }, + { + entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } + } + ] + } + }))); component.ngOnChanges(); }); diff --git a/lib/content-services/src/lib/version-manager/version-list.component.ts b/lib/content-services/src/lib/version-manager/version-list.component.ts index f5ca7cfca9a..de45c52723b 100644 --- a/lib/content-services/src/lib/version-manager/version-list.component.ts +++ b/lib/content-services/src/lib/version-manager/version-list.component.ts @@ -27,9 +27,7 @@ import { ContentVersionService } from './content-version.service'; templateUrl: './version-list.component.html', styleUrls: ['./version-list.component.scss'], encapsulation: ViewEncapsulation.None, - host: { - 'class': 'adf-version-list' - } + host: { class: 'adf-version-list' } }) export class VersionListComponent implements OnChanges { diff --git a/lib/content-services/src/lib/version-manager/version-upload.component.ts b/lib/content-services/src/lib/version-manager/version-upload.component.ts index 1ace3a00afe..b63048ec758 100644 --- a/lib/content-services/src/lib/version-manager/version-upload.component.ts +++ b/lib/content-services/src/lib/version-manager/version-upload.component.ts @@ -26,7 +26,7 @@ import { takeUntil } from 'rxjs/operators'; templateUrl: './version-upload.component.html', styleUrls: ['./version-upload.component.scss'], encapsulation: ViewEncapsulation.None, - host: { 'class': 'adf-version-upload' } + host: { class: 'adf-version-upload' } }) export class VersionUploadComponent implements OnInit, OnDestroy {