mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3324] added redirect to 404 page when the shared link is invalid (#3749)
* [ADF-3324] added redirect to 404 page when the shared link is invalid * [ADF-3324] removed fdescribe * [ADF-3324] fixed documentation adding the new event
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<ng-container *ngIf="sharedLinkId">
|
<ng-container *ngIf="sharedLinkId">
|
||||||
<adf-viewer
|
<adf-viewer
|
||||||
|
(invalidSharedLink)="redirectTo404()"
|
||||||
[sharedLinkId]="sharedLinkId"
|
[sharedLinkId]="sharedLinkId"
|
||||||
[allowGoBack]="false">
|
[allowGoBack]="false">
|
||||||
</adf-viewer>
|
</adf-viewer>
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
|
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-shared-link-view',
|
selector: 'app-shared-link-view',
|
||||||
@@ -30,7 +30,7 @@ export class SharedLinkViewComponent implements OnInit {
|
|||||||
|
|
||||||
sharedLinkId: string = null;
|
sharedLinkId: string = null;
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute) {}
|
constructor(private route: ActivatedRoute, private router: Router) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.params.subscribe(params => {
|
this.route.params.subscribe(params => {
|
||||||
@@ -38,4 +38,8 @@ export class SharedLinkViewComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redirectTo404() {
|
||||||
|
this.router.navigate(['error/404']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -112,6 +112,7 @@ URL with `urlFile`.
|
|||||||
| print | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`BaseEvent`](../../lib/core/events/base.event.ts)`<any>>` | Emitted when user clicks the 'Print' button. |
|
| print | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`BaseEvent`](../../lib/core/events/base.event.ts)`<any>>` | Emitted when user clicks the 'Print' button. |
|
||||||
| share | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`BaseEvent`](../../lib/core/events/base.event.ts)`<any>>` | Emitted when user clicks the 'Share' button. |
|
| share | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`BaseEvent`](../../lib/core/events/base.event.ts)`<any>>` | Emitted when user clicks the 'Share' button. |
|
||||||
| showViewerChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<boolean>` | Emitted when the viewer is shown or hidden. |
|
| showViewerChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<boolean>` | Emitted when the viewer is shown or hidden. |
|
||||||
|
| invalidSharedLink | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<Object>` | Emitted when the shared link used is not valid. |
|
||||||
|
|
||||||
## Keyboard shortcuts
|
## Keyboard shortcuts
|
||||||
|
|
||||||
|
@@ -624,6 +624,21 @@ describe('ViewerComponent', () => {
|
|||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should raise an event when the shared link is invalid', (done) => {
|
||||||
|
spyOn(alfrescoApiService.getInstance().core.sharedlinksApi, 'getSharedLink')
|
||||||
|
.and.returnValue(Promise.reject({}));
|
||||||
|
|
||||||
|
component.invalidSharedLink.subscribe(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
component.sharedLinkId = 'the-Shared-Link-id';
|
||||||
|
component.urlFile = null;
|
||||||
|
component.mimeType = null;
|
||||||
|
|
||||||
|
component.ngOnChanges(null);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('MimeType handling', () => {
|
describe('MimeType handling', () => {
|
||||||
|
@@ -209,6 +209,9 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
@Output()
|
@Output()
|
||||||
navigateNext = new EventEmitter();
|
navigateNext = new EventEmitter();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
invalidSharedLink = new EventEmitter();
|
||||||
|
|
||||||
viewerType = 'unknown';
|
viewerType = 'unknown';
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
node: MinimalNodeEntryEntity;
|
node: MinimalNodeEntryEntity;
|
||||||
@@ -307,6 +310,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
() => {
|
() => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.logService.error('This sharedLink does not exist');
|
this.logService.error('This sharedLink does not exist');
|
||||||
|
this.invalidSharedLink.next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user