Various code fixes (#1704)

* fix typings and missing lib

* fix i18n typo, add typings

* code improvements

* fix missing awaits

* more fixes

* fix bug in the evaluators, simplify code

* more fixes
This commit is contained in:
Denys Vuika
2020-10-04 18:09:27 +01:00
committed by GitHub
parent bf11489e0f
commit 9c7ac17161
46 changed files with 133 additions and 142 deletions

View File

@@ -36,6 +36,7 @@ import { SetCurrentFolderAction, isAdmin, AppStore, UploadFileVersionAction } fr
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { FilterSearch, ShareDataRow } from '@alfresco/adf-content-services';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';
@Component({
templateUrl: './files.component.html'
@@ -49,7 +50,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
private nodePath: PathElement[];
columns: any[] = [];
columns: DocumentListPresetRef[] = [];
constructor(
private router: Router,

View File

@@ -28,6 +28,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AppTestingModule } from '../../../testing/app-testing.module';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { NodePermissionService } from '@alfresco/aca-shared';
import { Node } from '@alfresco/js-api';
describe('CommentsTabComponent', () => {
let component: CommentsTabComponent;
@@ -66,44 +67,40 @@ describe('CommentsTabComponent', () => {
});
it('should return [false] if node selected is neither file or folder', () => {
const testNode: any = {
component.node = {
id: 'test-node-id',
isFile: false,
isFolder: false
};
component.node = testNode;
} as Node;
expect(component.canUpdateNode).toBe(false);
});
it('should return [false] if node selected is a locked file', () => {
const testNode: any = {
component.node = {
id: 'test-node-id',
isFile: true,
isFolder: false,
isLocked: true
};
component.node = testNode;
} as Node;
expect(component.canUpdateNode).toBe(false);
});
it('should check [update] permission if node selected is a not locked file', () => {
const testNode: any = {
component.node = {
id: 'test-node-id',
isFile: true,
isFolder: false
};
component.node = testNode;
} as Node;
expect(component.canUpdateNode).toBe(true);
expect(checked).toContain('update');
});
it('should check [update] permission if node selected is a folder', () => {
const testNode: any = {
component.node = {
id: 'test-node-id',
isFile: false,
isFolder: true
};
component.node = testNode;
} as Node;
expect(component.canUpdateNode).toBe(true);
expect(checked).toContain('update');
});

View File

@@ -70,7 +70,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
protected subscriptions: Subscription[] = [];
constructor(protected store: Store<AppStore>, protected extensions: AppExtensionService, protected content: ContentManagementService) {}
protected constructor(protected store: Store<AppStore>, protected extensions: AppExtensionService, protected content: ContentManagementService) {}
ngOnInit() {
this.sharedPreviewUrl$ = this.store.select(getSharedUrl);

View File

@@ -177,10 +177,10 @@ export class PreviewComponent extends PageComponent implements OnInit, OnDestroy
this.nodeId = this.node.id;
return;
}
this.router.navigate([this.previewLocation, id]);
await this.router.navigate([this.previewLocation, id]);
} catch (err) {
if (!err || err.status !== 401) {
this.router.navigate([this.previewLocation, id]);
await this.router.navigate([this.previewLocation, id]);
}
}
}

View File

@@ -31,7 +31,7 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { forkJoin, from, of } from 'rxjs';
import { catchError, flatMap } from 'rxjs/operators';
import { catchError, mergeMap } from 'rxjs/operators';
import { AppExtensionService } from '@alfresco/aca-shared';
@Component({
@@ -55,8 +55,10 @@ export class SharedLinkViewComponent implements OnInit {
ngOnInit() {
this.route.params
.pipe(
flatMap((params) =>
forkJoin(from(this.alfrescoApiService.sharedLinksApi.getSharedLink(params.id)), of(params.id)).pipe(catchError(() => of([null, params.id])))
mergeMap((params) =>
forkJoin([from(this.alfrescoApiService.sharedLinksApi.getSharedLink(params.id)), of(params.id)]).pipe(
catchError(() => of([null, params.id]))
)
)
)
.subscribe(([sharedEntry, sharedId]: [SharedLinkEntry, string]) => {

View File

@@ -56,7 +56,10 @@ describe('ButtonMenuComponent', () => {
it('should render action item', () => {
component.item = {
id: 'test-action-button',
url: 'dummy'
url: 'dummy',
icon: null,
title: null,
route: null
};
fixture.detectChanges();
@@ -68,16 +71,23 @@ describe('ButtonMenuComponent', () => {
it('should render action item with children', () => {
component.item = {
id: 'test-action-button',
icon: null,
title: null,
route: null,
children: [
{
id: 'child-1',
title: 'child-1',
url: 'dummy'
url: 'dummy',
icon: null,
route: null
},
{
id: 'child-2',
title: 'child-2',
url: 'dummy'
url: 'dummy',
icon: null,
route: null
}
]
};

View File

@@ -25,6 +25,7 @@
import { Component, Input, ViewEncapsulation, OnInit, ChangeDetectorRef } from '@angular/core';
import { OverlayContainer } from '@angular/cdk/overlay';
import { NavBarLinkRef } from '@alfresco/adf-extensions';
@Component({
selector: 'app-button-menu',
@@ -33,7 +34,8 @@ import { OverlayContainer } from '@angular/cdk/overlay';
encapsulation: ViewEncapsulation.None
})
export class ButtonMenuComponent implements OnInit {
@Input() item;
@Input()
item: NavBarLinkRef;
constructor(private cd: ChangeDetectorRef, private overlayContainer: OverlayContainer) {
this.overlayContainer.getContainerElement().classList.add('aca-menu-panel');

View File

@@ -52,7 +52,7 @@ import { SharedLinkEntry } from '@alfresco/js-api';
host: { class: 'app-view-node' }
})
export class ViewNodeComponent {
@Input() data: any;
@Input() data: { title?: string; menuButton?: boolean; iconButton?: boolean };
constructor(private store: Store<AppStore>, private router: Router) {}