mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACA-2850][ACA-2849] Viewer - document properties not refreshed after changes or uploading new version (#1286)
* update viewer on upload complete * prevent multiple same actions triggers * Display node again after upload was complete * Add e2e test for showing 'Editing Offline' when a new version was uploaded and the node was locked before * Add e2e test for showing 'Editing Offline' when a new version was uploaded and the node was locked before * Add e2e test for showing 'Editing Offline' when a new version was uploaded and the node was locked before * Update src/app/components/page.component.ts return type Co-Authored-By: Denys Vuika <denys.vuika@alfresco.com> * return type Co-Authored-By: Denys Vuika <denys.vuika@alfresco.com> * return type Co-Authored-By: Denys Vuika <denys.vuika@alfresco.com> Co-authored-by: Martin Muller <damadden88@googlemail.com> Co-authored-by: Denys Vuika <denys.vuika@gmail.com>
This commit is contained in:
co-authored by
Denys Vuika
Martin Muller
Denys Vuika
parent
0d0ddfcf37
commit
55547ed163
@@ -24,20 +24,29 @@
|
||||
*/
|
||||
|
||||
import { PageComponent } from './page.component';
|
||||
import {
|
||||
ReloadDocumentListAction,
|
||||
SetSelectedNodesAction
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { MinimalNodeEntity } from '@alfresco/js-api';
|
||||
|
||||
class TestClass extends PageComponent {
|
||||
node: any;
|
||||
|
||||
constructor() {
|
||||
super(null, null, null);
|
||||
constructor(store) {
|
||||
super(store, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
describe('PageComponent', () => {
|
||||
let component: TestClass;
|
||||
const store = {
|
||||
dispatch: jasmine.createSpy('dispatch'),
|
||||
select: jasmine.createSpy('select')
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
component = new TestClass();
|
||||
component = new TestClass(store);
|
||||
});
|
||||
|
||||
describe('getParentNodeId()', () => {
|
||||
@@ -53,4 +62,38 @@ describe('PageComponent', () => {
|
||||
expect(component.getParentNodeId()).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Reload', () => {
|
||||
const locationHref = location.href;
|
||||
|
||||
afterEach(() => {
|
||||
window.history.pushState({}, null, locationHref);
|
||||
});
|
||||
|
||||
it('should not reload if url contains viewer outlet', () => {
|
||||
window.history.pushState({}, null, `${locationHref}#test(viewer:view)`);
|
||||
component.reload();
|
||||
expect(store.dispatch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload if url does not contain viewer outlet', () => {
|
||||
component.reload();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(
|
||||
new ReloadDocumentListAction()
|
||||
);
|
||||
});
|
||||
|
||||
it('should set selection after reload if node is passed', () => {
|
||||
const node = {
|
||||
entry: {
|
||||
id: 'node-id'
|
||||
}
|
||||
} as MinimalNodeEntity;
|
||||
|
||||
component.reload(node);
|
||||
expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(
|
||||
new SetSelectedNodesAction([node])
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -133,6 +133,10 @@ export abstract class PageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
reload(selectedNode?: MinimalNodeEntity): void {
|
||||
if (this.isOutletPreviewUrl()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.store.dispatch(new ReloadDocumentListAction());
|
||||
if (selectedNode) {
|
||||
this.store.dispatch(new SetSelectedNodesAction([selectedNode]));
|
||||
@@ -146,4 +150,8 @@ export abstract class PageComponent implements OnInit, OnDestroy {
|
||||
trackById(_: number, obj: { id: string }) {
|
||||
return obj.id;
|
||||
}
|
||||
|
||||
private isOutletPreviewUrl(): boolean {
|
||||
return location.href.includes('viewer:view');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,10 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
||||
debounceTime(300),
|
||||
takeUntil(this.onDestroy$)
|
||||
)
|
||||
.subscribe(file => this.apiService.nodeUpdated.next(file.data.entry));
|
||||
.subscribe(file => {
|
||||
this.apiService.nodeUpdated.next(file.data.entry);
|
||||
this.displayNode(file.data.entry.id);
|
||||
});
|
||||
|
||||
this.previewLocation = this.router.url
|
||||
.substr(0, this.router.url.indexOf('/', 1))
|
||||
|
||||
Reference in New Issue
Block a user