mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-06-16 17:54:45 +00:00
Merge pull request #1328 from Alfresco/dev-pionnegru-ACA-2910
[ACA-2910] Viewer - Info Drawer action triggers parent side panel
This commit is contained in:
commit
b72a98e3d4
@ -23,30 +23,55 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||||
import { PageComponent } from './page.component';
|
import { PageComponent } from './page.component';
|
||||||
import {
|
import {
|
||||||
ReloadDocumentListAction,
|
ReloadDocumentListAction,
|
||||||
SetSelectedNodesAction
|
SetSelectedNodesAction,
|
||||||
|
SetInfoDrawerStateAction,
|
||||||
|
AppState,
|
||||||
|
AppStore
|
||||||
} from '@alfresco/aca-shared/store';
|
} from '@alfresco/aca-shared/store';
|
||||||
import { MinimalNodeEntity } from '@alfresco/js-api';
|
import { MinimalNodeEntity } from '@alfresco/js-api';
|
||||||
|
import { ContentManagementService } from '../services/content-management.service';
|
||||||
|
import { EffectsModule } from '@ngrx/effects';
|
||||||
|
import { ViewerEffects } from '../store/effects';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { AppExtensionService } from '../extensions/extension.service';
|
||||||
|
import { AppTestingModule } from '../testing/app-testing.module';
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
class TestClass extends PageComponent {
|
@Component({
|
||||||
|
selector: 'aca-test',
|
||||||
|
template: ''
|
||||||
|
})
|
||||||
|
class TestComponent extends PageComponent {
|
||||||
node: any;
|
node: any;
|
||||||
|
|
||||||
constructor(store) {
|
constructor(
|
||||||
super(store, null, null);
|
store: Store<AppStore>,
|
||||||
|
extensions: AppExtensionService,
|
||||||
|
content: ContentManagementService
|
||||||
|
) {
|
||||||
|
super(store, extensions, content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('PageComponent', () => {
|
describe('PageComponent', () => {
|
||||||
let component: TestClass;
|
let component: TestComponent;
|
||||||
const store = {
|
let store: Store<AppState>;
|
||||||
dispatch: jasmine.createSpy('dispatch'),
|
let fixture: ComponentFixture<TestComponent>;
|
||||||
select: jasmine.createSpy('select')
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component = new TestClass(store);
|
TestBed.configureTestingModule({
|
||||||
|
imports: [AppTestingModule, EffectsModule.forRoot([ViewerEffects])],
|
||||||
|
declarations: [TestComponent],
|
||||||
|
providers: [ContentManagementService, AppExtensionService]
|
||||||
|
});
|
||||||
|
|
||||||
|
store = TestBed.get(Store);
|
||||||
|
fixture = TestBed.createComponent(TestComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getParentNodeId()', () => {
|
describe('getParentNodeId()', () => {
|
||||||
@ -63,6 +88,42 @@ describe('PageComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Info Drawer state', () => {
|
||||||
|
const locationHref = location.href;
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
window.history.pushState({}, null, locationHref);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should open info drawer on action event', done => {
|
||||||
|
window.history.pushState({}, null, `${locationHref}#test`);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
component.infoDrawerOpened$.subscribe(state => {
|
||||||
|
expect(state).toBe(true);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
store.dispatch(new SetInfoDrawerStateAction(true));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not open info drawer if viewer outlet is active', done => {
|
||||||
|
window.history.pushState({}, null, `${locationHref}#test(viewer:view)`);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
component.infoDrawerOpened$.subscribe(state => {
|
||||||
|
expect(state).toBe(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
store.dispatch(new SetInfoDrawerStateAction(true));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Reload', () => {
|
describe('Reload', () => {
|
||||||
const locationHref = location.href;
|
const locationHref = location.href;
|
||||||
|
|
||||||
@ -72,11 +133,15 @@ describe('PageComponent', () => {
|
|||||||
|
|
||||||
it('should not reload if url contains viewer outlet', () => {
|
it('should not reload if url contains viewer outlet', () => {
|
||||||
window.history.pushState({}, null, `${locationHref}#test(viewer:view)`);
|
window.history.pushState({}, null, `${locationHref}#test(viewer:view)`);
|
||||||
|
spyOn(store, 'dispatch');
|
||||||
|
|
||||||
component.reload();
|
component.reload();
|
||||||
expect(store.dispatch).not.toHaveBeenCalled();
|
expect(store.dispatch).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reload if url does not contain viewer outlet', () => {
|
it('should reload if url does not contain viewer outlet', () => {
|
||||||
|
spyOn(store, 'dispatch');
|
||||||
|
|
||||||
component.reload();
|
component.reload();
|
||||||
expect(store.dispatch).toHaveBeenCalledWith(
|
expect(store.dispatch).toHaveBeenCalledWith(
|
||||||
new ReloadDocumentListAction()
|
new ReloadDocumentListAction()
|
||||||
@ -89,6 +154,7 @@ describe('PageComponent', () => {
|
|||||||
id: 'node-id'
|
id: 'node-id'
|
||||||
}
|
}
|
||||||
} as MinimalNodeEntity;
|
} as MinimalNodeEntity;
|
||||||
|
spyOn(store, 'dispatch');
|
||||||
|
|
||||||
component.reload(node);
|
component.reload(node);
|
||||||
expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(
|
expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(
|
||||||
|
@ -32,7 +32,7 @@ import { OnDestroy, OnInit, ViewChild } from '@angular/core';
|
|||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { MinimalNodeEntity, MinimalNodeEntryEntity } from '@alfresco/js-api';
|
import { MinimalNodeEntity, MinimalNodeEntryEntity } from '@alfresco/js-api';
|
||||||
import { Observable, Subject, Subscription } from 'rxjs';
|
import { Observable, Subject, Subscription } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil, map } from 'rxjs/operators';
|
||||||
import { AppExtensionService } from '../extensions/extension.service';
|
import { AppExtensionService } from '../extensions/extension.service';
|
||||||
import { ContentManagementService } from '../services/content-management.service';
|
import { ContentManagementService } from '../services/content-management.service';
|
||||||
import {
|
import {
|
||||||
@ -76,7 +76,12 @@ export abstract class PageComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.sharedPreviewUrl$ = this.store.select(getSharedUrl);
|
this.sharedPreviewUrl$ = this.store.select(getSharedUrl);
|
||||||
this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened);
|
this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened).pipe(
|
||||||
|
map(infoDrawerState => {
|
||||||
|
return !this.isOutletPreviewUrl() && infoDrawerState;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
this.documentDisplayMode$ = this.store.select(getDocumentDisplayMode);
|
this.documentDisplayMode$ = this.store.select(getDocumentDisplayMode);
|
||||||
|
|
||||||
this.store
|
this.store
|
||||||
|
Loading…
x
Reference in New Issue
Block a user