[ACA-2194] better custom aspects in metadata tab (#985)

* better custom aspects in metadata tab

* update test
This commit is contained in:
Denys Vuika 2019-03-01 19:12:50 +00:00 committed by GitHub
parent 830357e892
commit ab860cf7b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 44 deletions

View File

@ -35,9 +35,9 @@ import { of } from 'rxjs';
describe('InfoDrawerComponent', () => { describe('InfoDrawerComponent', () => {
let fixture: ComponentFixture<InfoDrawerComponent>; let fixture: ComponentFixture<InfoDrawerComponent>;
let component: InfoDrawerComponent; let component: InfoDrawerComponent;
let contentApiService; let contentApiService: ContentApiService;
let tab; let tab;
let appExtensionService; let appExtensionService: AppExtensionService;
const storeMock = { const storeMock = {
dispatch: jasmine.createSpy('dispatch') dispatch: jasmine.createSpy('dispatch')
}; };
@ -66,6 +66,10 @@ describe('InfoDrawerComponent', () => {
spyOn(appExtensionService, 'getSidebarTabs').and.returnValue([tab]); spyOn(appExtensionService, 'getSidebarTabs').and.returnValue([tab]);
}); });
afterEach(() => {
fixture.destroy();
});
it('should get tabs configuration on initialization', () => { it('should get tabs configuration on initialization', () => {
fixture.detectChanges(); fixture.detectChanges();
@ -83,7 +87,7 @@ describe('InfoDrawerComponent', () => {
it('should set displayNode when node is from personal list', () => { it('should set displayNode when node is from personal list', () => {
spyOn(contentApiService, 'getNodeInfo'); spyOn(contentApiService, 'getNodeInfo');
const nodeMock = <any>{ entry: { id: 'nodeId' } }; const nodeMock = <any>{ entry: { id: 'nodeId', aspectNames: [] } };
component.node = nodeMock; component.node = nodeMock;
fixture.detectChanges(); fixture.detectChanges();

View File

@ -33,7 +33,6 @@ import { ContentApiService } from '../../services/content-api.service';
import { AppExtensionService } from '../../extensions/extension.service'; import { AppExtensionService } from '../../extensions/extension.service';
import { SidebarTabRef } from '@alfresco/adf-extensions'; import { SidebarTabRef } from '@alfresco/adf-extensions';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppStore } from '../../store/states/app.state';
import { SetInfoDrawerStateAction } from '../../store/actions'; import { SetInfoDrawerStateAction } from '../../store/actions';
@Component({ @Component({
@ -51,7 +50,7 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy {
tabs: Array<SidebarTabRef> = []; tabs: Array<SidebarTabRef> = [];
constructor( constructor(
private store: Store<AppStore>, private store: Store<any>,
private contentApi: ContentApiService, private contentApi: ContentApiService,
private extensions: AppExtensionService private extensions: AppExtensionService
) {} ) {}
@ -66,39 +65,21 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy {
ngOnChanges() { ngOnChanges() {
if (this.node) { if (this.node) {
const entry: any = this.node.entry; if (this.node['isLibrary']) {
if (this.isLibraryListNode(this.node)) {
return this.setDisplayNode(this.node); return this.setDisplayNode(this.node);
} }
if (this.isSharedFilesNode(this.node)) { const entry: any = this.node.entry;
return this.loadNodeInfo(entry.nodeId);
}
if (this.isFavoriteListNode(this.node)) { if (!entry.aspectNames) {
return this.loadNodeInfo(entry.id); const id = entry.nodeId || entry.id;
} return this.loadNodeInfo(id);
if (this.isRecentListFileNode(this.node)) {
return this.loadNodeInfo(entry.id);
} }
this.setDisplayNode(entry); this.setDisplayNode(entry);
} }
} }
private hasAspectNames(entry: MinimalNodeEntryEntity): boolean {
return entry.aspectNames && entry.aspectNames.includes('exif:exif');
}
private isTypeImage(entry: MinimalNodeEntryEntity): boolean {
if (entry && entry.content && entry.content.mimeType) {
return entry.content.mimeType.includes('image/');
}
return false;
}
private loadNodeInfo(nodeId: string) { private loadNodeInfo(nodeId: string) {
if (nodeId) { if (nodeId) {
this.isLoading = true; this.isLoading = true;
@ -116,20 +97,4 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy {
private setDisplayNode(node: any) { private setDisplayNode(node: any) {
this.displayNode = node; this.displayNode = node;
} }
private isLibraryListNode(node: any): boolean {
return node.isLibrary;
}
private isFavoriteListNode(node: MinimalNodeEntity): boolean {
return !this.isLibraryListNode(node) && (<any>node).entry.guid;
}
private isSharedFilesNode(node: any): boolean {
return !!node.entry.nodeId;
}
private isRecentListFileNode(node: MinimalNodeEntity): boolean {
return this.isTypeImage(node.entry) && !this.hasAspectNames(node.entry);
}
} }