mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-1532] make Preview command available to extensions (#502)
* view file action and effect * integrate view action with search input/row * deprecate old ViewNode action/effect * preview file command as extension * reorder commands
This commit is contained in:
@@ -29,7 +29,7 @@ import { TestBed, async, ComponentFixture, fakeAsync, tick } from '@angular/core
|
||||
import { SearchInputComponent } from './search-input.component';
|
||||
import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||
import { Actions, ofType } from '@ngrx/effects';
|
||||
import { ViewNodeAction, VIEW_NODE, NAVIGATE_FOLDER, NavigateToFolder } from '../../../store/actions';
|
||||
import { NAVIGATE_FOLDER, NavigateToFolder, VIEW_FILE, ViewFileAction } from '../../../store/actions';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
describe('SearchInputComponent', () => {
|
||||
@@ -59,9 +59,9 @@ describe('SearchInputComponent', () => {
|
||||
describe('onItemClicked()', () => {
|
||||
it('opens preview if node is file', fakeAsync(done => {
|
||||
actions$.pipe(
|
||||
ofType<ViewNodeAction>(VIEW_NODE),
|
||||
ofType<ViewFileAction>(VIEW_FILE),
|
||||
map(action => {
|
||||
expect(action.payload.id).toBe('node-id');
|
||||
expect(action.payload.entry.id).toBe('node-id');
|
||||
done();
|
||||
})
|
||||
);
|
||||
|
@@ -32,7 +32,7 @@ import { MinimalNodeEntity } from 'alfresco-js-api';
|
||||
import { SearchInputControlComponent } from '../search-input-control/search-input-control.component';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../../../store/states/app.state';
|
||||
import { SearchByTermAction, ViewNodeAction, NavigateToFolder } from '../../../store/actions';
|
||||
import { SearchByTermAction, NavigateToFolder, ViewFileAction } from '../../../store/actions';
|
||||
|
||||
@Component({
|
||||
selector: 'aca-search-input',
|
||||
@@ -90,15 +90,9 @@ export class SearchInputComponent implements OnInit {
|
||||
|
||||
onItemClicked(node: MinimalNodeEntity) {
|
||||
if (node && node.entry) {
|
||||
const { id, nodeId, name, isFile, isFolder, parentId } = node.entry;
|
||||
const { isFile, isFolder } = node.entry;
|
||||
if (isFile) {
|
||||
this.store.dispatch(new ViewNodeAction({
|
||||
parentId,
|
||||
id: nodeId || id,
|
||||
name,
|
||||
isFile,
|
||||
isFolder
|
||||
}));
|
||||
this.store.dispatch(new ViewFileAction(node));
|
||||
} else if (isFolder) {
|
||||
this.store.dispatch(new NavigateToFolder(node));
|
||||
}
|
||||
|
@@ -24,8 +24,8 @@
|
||||
*/
|
||||
|
||||
import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { ViewNodeAction } from '../../../store/actions/viewer.actions';
|
||||
import { MinimalNodeEntity } from 'alfresco-js-api';
|
||||
import { ViewFileAction } from '../../../store/actions';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../../../store/states/app.state';
|
||||
|
||||
@@ -38,14 +38,14 @@ import { AppStore } from '../../../store/states/app.state';
|
||||
host: { class: 'aca-search-results-row' }
|
||||
})
|
||||
export class SearchResultsRowComponent implements OnInit {
|
||||
private node: MinimalNodeEntryEntity;
|
||||
private node: MinimalNodeEntity;
|
||||
|
||||
@Input() context: any;
|
||||
|
||||
constructor(private store: Store<AppStore>) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.node = this.context.row.node.entry;
|
||||
this.node = this.context.row.node;
|
||||
}
|
||||
|
||||
get name() {
|
||||
@@ -89,13 +89,8 @@ export class SearchResultsRowComponent implements OnInit {
|
||||
}
|
||||
|
||||
showPreview() {
|
||||
const { id, name } = this.node;
|
||||
|
||||
this.store.dispatch(
|
||||
new ViewNodeAction({
|
||||
id,
|
||||
name
|
||||
})
|
||||
new ViewFileAction(this.node)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -106,6 +101,6 @@ export class SearchResultsRowComponent implements OnInit {
|
||||
.replace('[', '.')
|
||||
.replace(']', '')
|
||||
.split('.')
|
||||
.reduce((acc, part) => (acc ? acc[part] : null), this.node);
|
||||
.reduce((acc, part) => (acc ? acc[part] : null), this.node.entry);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user