mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACA-2471] - close preview action (#1129)
This commit is contained in:
parent
e6b959df7b
commit
5491545ac9
@ -122,3 +122,4 @@ Below is the list of public actions types you can use in the plugin definitions
|
|||||||
| 1.7.0 | SHOW_SEARCH_FILTER | n/a | Show Filter component in Search Results. |
|
| 1.7.0 | SHOW_SEARCH_FILTER | n/a | Show Filter component in Search Results. |
|
||||||
| 1.7.0 | HIDE_SEARCH_FILTER | n/a | Hide Filter component in Search Results |
|
| 1.7.0 | HIDE_SEARCH_FILTER | n/a | Hide Filter component in Search Results |
|
||||||
| 1.8.0 | VIEW_NODE | string | Lightweight preview of a node by id. Can be invoked from extensions. |
|
| 1.8.0 | VIEW_NODE | string | Lightweight preview of a node by id. Can be invoked from extensions. |
|
||||||
|
| 1.8.0 | CLOSE_PREVIEW | n/a | Closes the viewer ( preview of the item ) |
|
||||||
|
@ -29,7 +29,8 @@ import { MinimalNodeEntity } from '@alfresco/js-api';
|
|||||||
export enum ViewerActionTypes {
|
export enum ViewerActionTypes {
|
||||||
ViewFile = 'VIEW_FILE',
|
ViewFile = 'VIEW_FILE',
|
||||||
ViewNode = 'VIEW_NODE',
|
ViewNode = 'VIEW_NODE',
|
||||||
FullScreen = 'FULLSCREEN_VIEWER'
|
FullScreen = 'FULLSCREEN_VIEWER',
|
||||||
|
ClosePreview = 'CLOSE_PREVIEW'
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ViewFileAction implements Action {
|
export class ViewFileAction implements Action {
|
||||||
@ -49,3 +50,8 @@ export class FullscreenViewerAction implements Action {
|
|||||||
|
|
||||||
constructor(public payload: MinimalNodeEntity) {}
|
constructor(public payload: MinimalNodeEntity) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ClosePreviewAction implements Action {
|
||||||
|
readonly type = ViewerActionTypes.ClosePreview;
|
||||||
|
constructor(public payload?: MinimalNodeEntity) {}
|
||||||
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
"/alfresco": {
|
'/alfresco': {
|
||||||
"target": "http://0.0.0.0:8080",
|
target: 'http://0.0.0.0:8080',
|
||||||
"secure": false,
|
secure: false,
|
||||||
"changeOrigin": true,
|
changeOrigin: true,
|
||||||
// workaround for REPO-2260
|
// workaround for REPO-2260
|
||||||
onProxyRes: function (proxyRes, req, res) {
|
onProxyRes: function(proxyRes, req, res) {
|
||||||
const header = proxyRes.headers['www-authenticate'];
|
const header = proxyRes.headers['www-authenticate'];
|
||||||
if (header && header.startsWith('Basic')) {
|
if (header && header.startsWith('Basic')) {
|
||||||
proxyRes.headers['www-authenticate'] = 'x' + header;
|
proxyRes.headers['www-authenticate'] = 'x' + header;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -39,6 +39,7 @@ import {
|
|||||||
UploadService,
|
UploadService,
|
||||||
AlfrescoApiService
|
AlfrescoApiService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
|
import { ClosePreviewAction } from '@alfresco/aca-shared/store';
|
||||||
import { PreviewComponent } from './preview.component';
|
import { PreviewComponent } from './preview.component';
|
||||||
import { of, throwError } from 'rxjs';
|
import { of, throwError } from 'rxjs';
|
||||||
import { EffectsModule } from '@ngrx/effects';
|
import { EffectsModule } from '@ngrx/effects';
|
||||||
@ -46,6 +47,7 @@ import { NodeEffects } from '../../store/effects/node.effects';
|
|||||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||||
import { ContentApiService } from '@alfresco/aca-shared';
|
import { ContentApiService } from '@alfresco/aca-shared';
|
||||||
import { ContentManagementService } from '../../services/content-management.service';
|
import { ContentManagementService } from '../../services/content-management.service';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
describe('PreviewComponent', () => {
|
describe('PreviewComponent', () => {
|
||||||
let fixture: ComponentFixture<PreviewComponent>;
|
let fixture: ComponentFixture<PreviewComponent>;
|
||||||
@ -57,6 +59,7 @@ describe('PreviewComponent', () => {
|
|||||||
let uploadService: UploadService;
|
let uploadService: UploadService;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
let contentManagementService: ContentManagementService;
|
let contentManagementService: ContentManagementService;
|
||||||
|
let store: Store<any>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@ -76,6 +79,7 @@ describe('PreviewComponent', () => {
|
|||||||
uploadService = TestBed.get(UploadService);
|
uploadService = TestBed.get(UploadService);
|
||||||
alfrescoApiService = TestBed.get(AlfrescoApiService);
|
alfrescoApiService = TestBed.get(AlfrescoApiService);
|
||||||
contentManagementService = TestBed.get(ContentManagementService);
|
contentManagementService = TestBed.get(ContentManagementService);
|
||||||
|
store = TestBed.get(Store);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should extract the property path root', () => {
|
it('should extract the property path root', () => {
|
||||||
@ -732,4 +736,11 @@ describe('PreviewComponent', () => {
|
|||||||
|
|
||||||
expect(alfrescoApiService.nodeUpdated.next).toHaveBeenCalled();
|
expect(alfrescoApiService.nodeUpdated.next).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should return to parent folder when event emitted from extension', async(() => {
|
||||||
|
spyOn(component, 'navigateToFileLocation');
|
||||||
|
fixture.detectChanges();
|
||||||
|
store.dispatch(new ClosePreviewAction());
|
||||||
|
expect(component.navigateToFileLocation).toHaveBeenCalled();
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
@ -38,7 +38,7 @@ import {
|
|||||||
UrlSegment,
|
UrlSegment,
|
||||||
PRIMARY_OUTLET
|
PRIMARY_OUTLET
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
import { debounceTime, map, takeUntil } from 'rxjs/operators';
|
||||||
import {
|
import {
|
||||||
UserPreferencesService,
|
UserPreferencesService,
|
||||||
ObjectUtils,
|
ObjectUtils,
|
||||||
@ -46,7 +46,11 @@ import {
|
|||||||
AlfrescoApiService
|
AlfrescoApiService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppStore } from '@alfresco/aca-shared/store';
|
import {
|
||||||
|
AppStore,
|
||||||
|
ClosePreviewAction,
|
||||||
|
ViewerActionTypes
|
||||||
|
} from '@alfresco/aca-shared/store';
|
||||||
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
|
||||||
import { PageComponent } from '../page.component';
|
import { PageComponent } from '../page.component';
|
||||||
import { ContentApiService } from '@alfresco/aca-shared';
|
import { ContentApiService } from '@alfresco/aca-shared';
|
||||||
@ -55,6 +59,7 @@ import { ContentManagementService } from '../../services/content-management.serv
|
|||||||
import { ContentActionRef, ViewerExtensionRef } from '@alfresco/adf-extensions';
|
import { ContentActionRef, ViewerExtensionRef } from '@alfresco/adf-extensions';
|
||||||
import { SearchRequest } from '@alfresco/js-api';
|
import { SearchRequest } from '@alfresco/js-api';
|
||||||
import { from } from 'rxjs';
|
import { from } from 'rxjs';
|
||||||
|
import { Actions, ofType } from '@ngrx/effects';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-preview',
|
selector: 'app-preview',
|
||||||
@ -115,6 +120,7 @@ export class PreviewComponent extends PageComponent
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private apiService: AlfrescoApiService,
|
private apiService: AlfrescoApiService,
|
||||||
private uploadService: UploadService,
|
private uploadService: UploadService,
|
||||||
|
private actions$: Actions,
|
||||||
store: Store<AppStore>,
|
store: Store<AppStore>,
|
||||||
extensions: AppExtensionService,
|
extensions: AppExtensionService,
|
||||||
content: ContentManagementService
|
content: ContentManagementService
|
||||||
@ -167,7 +173,14 @@ export class PreviewComponent extends PageComponent
|
|||||||
|
|
||||||
this.uploadService.fileUploadComplete
|
this.uploadService.fileUploadComplete
|
||||||
.pipe(debounceTime(300))
|
.pipe(debounceTime(300))
|
||||||
.subscribe(file => this.apiService.nodeUpdated.next(file.data.entry))
|
.subscribe(file => this.apiService.nodeUpdated.next(file.data.entry)),
|
||||||
|
|
||||||
|
this.actions$
|
||||||
|
.pipe(
|
||||||
|
ofType<ClosePreviewAction>(ViewerActionTypes.ClosePreview),
|
||||||
|
map(() => this.navigateToFileLocation(true))
|
||||||
|
)
|
||||||
|
.subscribe(() => {})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.openWith = this.extensions.openWithActions;
|
this.openWith = this.extensions.openWithActions;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user