diff --git a/demo-shell/src/app/app.routes.ts b/demo-shell/src/app/app.routes.ts
index d6005ad0eb..49381be768 100644
--- a/demo-shell/src/app/app.routes.ts
+++ b/demo-shell/src/app/app.routes.ts
@@ -93,7 +93,7 @@ export const appRoutes: Routes = [
children: [
{
path: '',
- loadChildren: 'app/components/blob-preview/blob-preview.module#BlobPreviewModule'
+ loadChildren: 'app/components/file-view/file-view.module#FileViewModule'
}
]
},
diff --git a/demo-shell/src/app/components/blob-preview/blob-preview.component.ts b/demo-shell/src/app/components/blob-preview/blob-preview.component.ts
deleted file mode 100644
index 15641cd71d..0000000000
--- a/demo-shell/src/app/components/blob-preview/blob-preview.component.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-/*!
- * @license
- * Copyright 2019 Alfresco Software, Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { Component } from '@angular/core';
-import { PreviewService } from '../../services/preview.service';
-import { Router } from '@angular/router';
-
-@Component({
- templateUrl: 'bob-preview.component.html'
-})
-export class BlobPreviewComponent {
- content: Blob;
- name: string;
-
- constructor(preview: PreviewService, router: Router) {
- if (preview.content === null || preview.name === null) {
- router.navigate([{ outlets: { overlay: null } }]);
- return;
- }
-
- this.content = preview.content;
- this.name = preview.name;
- }
-}
diff --git a/demo-shell/src/app/components/blob-preview/blob-preview.module.ts b/demo-shell/src/app/components/blob-preview/blob-preview.module.ts
deleted file mode 100644
index 9e056eac9c..0000000000
--- a/demo-shell/src/app/components/blob-preview/blob-preview.module.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/*!
- * @license
- * Copyright 2019 Alfresco Software, Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { NgModule } from '@angular/core';
-import { Routes, RouterModule } from '@angular/router';
-import { CommonModule } from '@angular/common';
-import { CoreModule, InfoDrawerModule } from '@alfresco/adf-core';
-import { ContentDirectiveModule, ContentMetadataModule, VersionManagerModule } from '@alfresco/adf-content-services';
-import { BlobPreviewComponent } from './blob-preview.component';
-
-const routes: Routes = [
- {
- path: '',
- component: BlobPreviewComponent
- }
-];
-
-@NgModule({
- imports: [
- CommonModule,
- RouterModule.forChild(routes),
- CoreModule.forChild(),
- InfoDrawerModule,
- ContentDirectiveModule,
- ContentMetadataModule,
- VersionManagerModule
- ],
- declarations: [
- BlobPreviewComponent
- ],
- exports: [
- BlobPreviewComponent
- ]
-})
-export class BlobPreviewModule {}
diff --git a/demo-shell/src/app/components/blob-preview/bob-preview.component.html b/demo-shell/src/app/components/blob-preview/bob-preview.component.html
deleted file mode 100644
index 50d2a1515f..0000000000
--- a/demo-shell/src/app/components/blob-preview/bob-preview.component.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
\ No newline at end of file
diff --git a/demo-shell/src/app/components/file-view/file-view.component.html b/demo-shell/src/app/components/file-view/file-view.component.html
index e6274e0b69..553ea01d97 100644
--- a/demo-shell/src/app/components/file-view/file-view.component.html
+++ b/demo-shell/src/app/components/file-view/file-view.component.html
@@ -1,4 +1,4 @@
-
+
@@ -284,14 +284,16 @@
-
-
- Hide Left Sidebar
+
+ Hide Left Sidebar
@@ -314,6 +316,7 @@
diff --git a/demo-shell/src/app/components/file-view/file-view.component.ts b/demo-shell/src/app/components/file-view/file-view.component.ts
index e5b4187f87..f5e46304e4 100644
--- a/demo-shell/src/app/components/file-view/file-view.component.ts
+++ b/demo-shell/src/app/components/file-view/file-view.component.ts
@@ -16,9 +16,10 @@
*/
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
-import { ActivatedRoute, Router } from '@angular/router';
+import { ActivatedRoute, Router, PRIMARY_OUTLET } from '@angular/router';
import { ContentService, AllowableOperationsEnum, PermissionsEnum, NodesApiService } from '@alfresco/adf-core';
import { MatSnackBar } from '@angular/material';
+import { PreviewService } from '../../services/preview.service';
@Component({
selector: 'app-file-view',
@@ -57,12 +58,15 @@ export class FileViewComponent implements OnInit {
showTabWithIconAndLabel = false;
desiredAspect: string = null;
showAspect: string = null;
+ content: Blob;
+ name: string;
constructor(private router: Router,
private route: ActivatedRoute,
private snackBar: MatSnackBar,
private nodeApiService: NodesApiService,
- private contentServices: ContentService) {
+ private contentServices: ContentService,
+ private preview: PreviewService) {
}
ngOnInit() {
@@ -81,10 +85,18 @@ export class FileViewComponent implements OnInit {
},
() => this.router.navigate(['/files', id])
);
+ } else if (this.preview.content) {
+ this.content = this.preview.content;
+ this.displayName = this.preview.name;
}
});
}
+ onViewerVisibilityChanged() {
+ const primaryUrl = this.router.parseUrl(this.router.url).root.children[PRIMARY_OUTLET].toString();
+ this.router.navigateByUrl(primaryUrl);
+ }
+
onUploadError(errorMessage: string) {
this.snackBar.open(errorMessage, '', { duration: 4000 });
}
diff --git a/e2e/core/viewer/viewer-content-services-component.e2e.ts b/e2e/core/viewer/viewer-content-services-component.e2e.ts
index ba4234cdc7..0dbfd9d8a4 100644
--- a/e2e/core/viewer/viewer-content-services-component.e2e.ts
+++ b/e2e/core/viewer/viewer-content-services-component.e2e.ts
@@ -401,4 +401,11 @@ describe('Content Services Viewer', () => {
viewerPage.clickCloseButton();
});
+
+ it('[C307985] Should close the viewer when password dialog is cancelled', () => {
+ viewerPage.viewFile(protectedFile.name);
+ viewerPage.checkPasswordDialogIsDisplayed();
+ viewerPage.clickClosePasswordDialog();
+ contentServicesPage.checkContentIsDisplayed(protectedFile.name);
+ });
});
diff --git a/e2e/pages/adf/viewerPage.ts b/e2e/pages/adf/viewerPage.ts
index 0604d3bea2..6666141db4 100644
--- a/e2e/pages/adf/viewerPage.ts
+++ b/e2e/pages/adf/viewerPage.ts
@@ -50,6 +50,7 @@ export class ViewerPage {
lastThumbnailDisplayed = element.all(by.css('adf-pdf-thumb')).last();
passwordDialog = element(by.css('adf-pdf-viewer-password-dialog'));
passwordSubmit = element(by.css('button[data-automation-id="adf-password-dialog-submit"]'));
+ passwordDialogClose = element(by.css('button[data-automation-id="adf-password-dialog-close"]'));
passwordSubmitDisabled = element(by.css('button[data-automation-id="adf-password-dialog-submit"][disabled]'));
passwordInput = element(by.css('input[data-automation-id="adf-password-dialog-input"]'));
passwordError = element(by.css('mat-error[data-automation-id="adf-password-dialog-error"]'));
@@ -149,6 +150,11 @@ export class ViewerPage {
BrowserVisibility.waitUntilElementIsVisible(this.pdfPageLoaded, 30000, `not loaded ${fileName}`);
}
+ clickClosePasswordDialog() {
+ BrowserVisibility.waitUntilElementIsVisible(this.passwordDialogClose);
+ this.passwordDialogClose.click();
+ }
+
checkImgViewerIsDisplayed() {
BrowserVisibility.waitUntilElementIsOnPage(this.imgViewer);
}
diff --git a/e2e/process-services/task-attachmentList-actionMenu.e2e.ts b/e2e/process-services/task-attachmentList-actionMenu.e2e.ts
index f497d81c57..7ffde50b45 100644
--- a/e2e/process-services/task-attachmentList-actionMenu.e2e.ts
+++ b/e2e/process-services/task-attachmentList-actionMenu.e2e.ts
@@ -101,15 +101,11 @@ describe('Attachment list action menu for tasks', () => {
viewerPage.checkFileNameIsDisplayed(pngFile.name);
viewerPage.clickCloseButton();
- taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
-
attachmentListPage.doubleClickFile(pngFile.name);
viewerPage.checkFileNameIsDisplayed(pngFile.name);
viewerPage.clickCloseButton();
- taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
-
attachmentListPage.downloadFile(pngFile.name);
browser.driver.sleep(1000);
@@ -139,9 +135,6 @@ describe('Attachment list action menu for tasks', () => {
viewerPage.checkFileNameIsDisplayed(pngFile.name);
viewerPage.clickCloseButton();
- taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.COMPLETED_TASKS);
- taskPage.tasksListPage().selectRow(taskName.completed);
-
attachmentListPage.downloadFile(pngFile.name);
browser.driver.sleep(1000);
diff --git a/lib/core/services/previous-route.service.spec.ts b/lib/core/services/previous-route.service.spec.ts
deleted file mode 100644
index 5972b95d1e..0000000000
--- a/lib/core/services/previous-route.service.spec.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-/*!
- * @license
- * Copyright 2019 Alfresco Software, Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { TestBed } from '@angular/core/testing';
-import { setupTestBed } from '../testing/setupTestBed';
-import { PreviousRouteService } from './previous-route.service';
-import { Router, NavigationEnd } from '@angular/router';
-import { Observable } from 'rxjs';
-import { CoreTestingModule } from 'core/testing/core.testing.module';
-
-class MockRouter {
- firstUrl = new NavigationEnd(0, '/files', '/files');
- secondUrl = new NavigationEnd(0, '/home', '/home');
- events = new Observable((observer) => {
- observer.next(this.firstUrl);
- observer.next(this.secondUrl);
- observer.complete();
- });
-}
-
-describe('Previous route service ', () => {
-
- let previousRouteService: PreviousRouteService;
-
- setupTestBed({
- imports: [
- CoreTestingModule
- ],
- providers: [
- { provide: Router, useClass: MockRouter },
- PreviousRouteService
- ]
- });
-
- beforeEach(() => {
- previousRouteService = TestBed.get(PreviousRouteService);
- });
-
- it('should be able to create the service', () => {
- expect(previousRouteService).not.toBeNull();
- expect(previousRouteService).toBeDefined();
- });
-
- it('should set curent url when new page loads', () => {
- expect(previousRouteService.getPreviousUrl()).toBe('/files');
- });
-});
diff --git a/lib/core/services/previous-route.service.ts b/lib/core/services/previous-route.service.ts
deleted file mode 100644
index d545943723..0000000000
--- a/lib/core/services/previous-route.service.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-/*!
- * @license
- * Copyright 2019 Alfresco Software, Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { Injectable } from '@angular/core';
-import { Router, NavigationEnd } from '@angular/router';
-
-@Injectable({
- providedIn: 'root'
-})
-export class PreviousRouteService {
-
- private previousUrl: string;
- private currentUrl: string;
-
- constructor(private router: Router) {
- this.currentUrl = this.router.url;
- this.router.events.subscribe((event) => {
- if (event instanceof NavigationEnd) {
- this.previousUrl = this.currentUrl;
- this.currentUrl = event.url;
- }
- });
- }
-
- public getPreviousUrl(): string {
- return this.previousUrl;
- }
-}
diff --git a/lib/core/services/public-api.ts b/lib/core/services/public-api.ts
index 462642fb8f..60dae7989d 100644
--- a/lib/core/services/public-api.ts
+++ b/lib/core/services/public-api.ts
@@ -55,5 +55,4 @@ export * from './jwt-helper.service';
export * from './download-zip.service';
export * from './lock.service';
export * from './automation.service';
-export * from './previous-route.service';
export * from './automation.service';
diff --git a/lib/core/viewer/components/pdfViewer-password-dialog.html b/lib/core/viewer/components/pdfViewer-password-dialog.html
index dbb92bcbc0..a6c488cfc3 100644
--- a/lib/core/viewer/components/pdfViewer-password-dialog.html
+++ b/lib/core/viewer/components/pdfViewer-password-dialog.html
@@ -19,7 +19,7 @@
- {{ 'ADF_VIEWER.PDF_DIALOG.CLOSE' | translate }}
+ {{ 'ADF_VIEWER.PDF_DIALOG.CLOSE' | translate }} {
let fixtureUrlTestPasswordComponent: ComponentFixture;
let componentUrlTestPasswordComponent: UrlTestPasswordComponent;
- beforeEach((done) => {
- fixtureUrlTestPasswordComponent = TestBed.createComponent(UrlTestPasswordComponent);
- componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance;
+ describe('Open password dialog', () => {
+ beforeEach((done) => {
+ fixtureUrlTestPasswordComponent = TestBed.createComponent(UrlTestPasswordComponent);
+ componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance;
- spyOn(dialog, 'open').and.callFake((comp, context) => {
- if (context.data.reason === pdfjsLib.PasswordResponses.NEED_PASSWORD) {
- return {
- afterClosed: () => of('wrong_password')
- };
- }
+ spyOn(dialog, 'open').and.callFake((comp, context) => {
+ if (context.data.reason === pdfjsLib.PasswordResponses.NEED_PASSWORD) {
+ return {
+ afterClosed: () => of('wrong_password')
+ };
+ }
- if (context.data.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
- return {
- afterClosed: () => of('password')
- };
- }
- });
-
- fixtureUrlTestPasswordComponent.detectChanges();
-
- componentUrlTestPasswordComponent.pdfViewerComponent.rendered.subscribe(() => {
- done();
- });
- });
-
- afterEach(() => {
- document.body.removeChild(fixtureUrlTestPasswordComponent.nativeElement);
- });
-
- it('should try to access protected pdf', (done) => {
- fixture.detectChanges();
- fixture.whenStable().then(() => {
- fixture.detectChanges();
-
- expect(dialog.open).toHaveBeenCalledTimes(2);
- done();
- });
- });
-
- it('should raise dialog asking for password', (done) => {
- fixture.detectChanges();
- fixture.whenStable().then(() => {
- fixture.detectChanges();
- expect(dialog.open['calls'].all()[0].args[1].data).toEqual({
- reason: pdfjsLib.PasswordResponses.NEED_PASSWORD
+ if (context.data.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
+ return {
+ afterClosed: () => of('password')
+ };
+ }
+ });
+
+ fixtureUrlTestPasswordComponent.detectChanges();
+
+ componentUrlTestPasswordComponent.pdfViewerComponent.rendered.subscribe(() => {
+ done();
+ });
+ });
+
+ afterEach(() => {
+ document.body.removeChild(fixtureUrlTestPasswordComponent.nativeElement);
+ });
+
+ it('should try to access protected pdf', (done) => {
+ fixture.detectChanges();
+ fixture.whenStable().then(() => {
+ fixture.detectChanges();
+
+ expect(dialog.open).toHaveBeenCalledTimes(2);
+ done();
+ });
+ });
+
+ it('should raise dialog asking for password', (done) => {
+ fixture.detectChanges();
+ fixture.whenStable().then(() => {
+ fixture.detectChanges();
+ expect(dialog.open['calls'].all()[0].args[1].data).toEqual({
+ reason: pdfjsLib.PasswordResponses.NEED_PASSWORD
+ });
+ done();
+ });
+ });
+
+ it('it should raise dialog with incorrect password', (done) => {
+ fixture.detectChanges();
+ fixture.whenStable().then(() => {
+ fixture.detectChanges();
+ expect(dialog.open['calls'].all()[1].args[1].data).toEqual({
+ reason: pdfjsLib.PasswordResponses.INCORRECT_PASSWORD
+ });
+ done();
});
- done();
});
});
- it('it should raise dialog with incorrect password', (done) => {
- fixture.detectChanges();
- fixture.whenStable().then(() => {
- fixture.detectChanges();
- expect(dialog.open['calls'].all()[1].args[1].data).toEqual({
- reason: pdfjsLib.PasswordResponses.INCORRECT_PASSWORD
+ describe('Close password dialog ', () => {
+ beforeEach((done) => {
+ fixtureUrlTestPasswordComponent = TestBed.createComponent(UrlTestPasswordComponent);
+ componentUrlTestPasswordComponent = fixtureUrlTestPasswordComponent.componentInstance;
+
+ spyOn(dialog, 'open').and.callFake(() => {
+ return {
+ afterClosed: () => {
+ done();
+ return of('');
+ }
+ };
+ });
+
+ spyOn(componentUrlTestPasswordComponent.pdfViewerComponent.close, 'emit');
+
+ fixtureUrlTestPasswordComponent.detectChanges();
+
+ componentUrlTestPasswordComponent.pdfViewerComponent.rendered.subscribe(() => {
+ done();
+ });
+ });
+
+ afterEach(() => {
+ document.body.removeChild(fixtureUrlTestPasswordComponent.nativeElement);
+ });
+
+ it('should try to access protected pdf', (done) => {
+ fixture.detectChanges();
+ fixture.whenStable().then(() => {
+ fixture.detectChanges();
+
+ expect(componentUrlTestPasswordComponent.pdfViewerComponent.close.emit).toHaveBeenCalledWith();
+ done();
});
- done();
});
});
});
diff --git a/lib/core/viewer/components/pdfViewer.component.ts b/lib/core/viewer/components/pdfViewer.component.ts
index e0799de6d5..deb1767818 100644
--- a/lib/core/viewer/components/pdfViewer.component.ts
+++ b/lib/core/viewer/components/pdfViewer.component.ts
@@ -79,6 +79,9 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
@Output()
error = new EventEmitter();
+ @Output()
+ close = new EventEmitter();
+
loadingTask: any;
currentPdfDocument: any;
page: number;
@@ -188,11 +191,11 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
this.currentPdfDocument.getPage(1).then(() => {
this.scalePage('auto');
- }, (error) => {
+ }, () => {
this.error.emit();
});
- }, (error) => {
+ }, () => {
this.error.emit();
});
}
@@ -461,13 +464,14 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
this.dialog
.open(PdfPasswordDialogComponent, {
width: '400px',
- disableClose: true,
data: { reason }
})
.afterClosed().subscribe((password) => {
- if (password) {
- callback(password);
- }
+ if (password) {
+ callback(password);
+ } else {
+ this.close.emit();
+ }
});
}
diff --git a/lib/core/viewer/components/viewer.component.html b/lib/core/viewer/components/viewer.component.html
index 009caaf978..1f6396a514 100644
--- a/lib/core/viewer/components/viewer.component.html
+++ b/lib/core/viewer/components/viewer.component.html
@@ -171,7 +171,7 @@
-
+
diff --git a/lib/core/viewer/components/viewer.component.spec.ts b/lib/core/viewer/components/viewer.component.spec.ts
index 4fee2fb8d5..a0172bdb10 100644
--- a/lib/core/viewer/components/viewer.component.spec.ts
+++ b/lib/core/viewer/components/viewer.component.spec.ts
@@ -23,16 +23,14 @@ import { AlfrescoApiService, RenditionsService } from '../../services';
import { CoreModule } from '../../core.module';
-import { throwError, Observable } from 'rxjs';
+import { throwError } from 'rxjs';
import { EventMock } from '../../mock/event.mock';
import { RenderingQueueServices } from '../services/rendering-queue.services';
import { ViewerComponent } from './viewer.component';
import { setupTestBed } from '../../testing/setupTestBed';
import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock';
import { NodeEntry } from '@alfresco/js-api';
-import { PreviousRouteService } from 'core/services/previous-route.service';
import { RouterTestingModule } from '@angular/router/testing';
-import { Router, NavigationEnd } from '@angular/router';
@Component({
selector: 'adf-viewer-container-toolbar',
@@ -123,22 +121,11 @@ class ViewerWithCustomOpenWithComponent {
class ViewerWithCustomMoreActionsComponent {
}
-class MockRouter {
- navigate = jasmine.createSpy('navigate');
- firstUrl = new NavigationEnd(0, '/files', '/files');
- events = new Observable((observer) => {
- observer.next(this.firstUrl);
- observer.complete();
- });
-}
-
describe('ViewerComponent', () => {
let component: ViewerComponent;
let fixture: ComponentFixture;
let alfrescoApiService: AlfrescoApiService;
- let previousRouteService: PreviousRouteService;
- let router: Router;
let element: HTMLElement;
setupTestBed({
@@ -162,9 +149,7 @@ describe('ViewerComponent', () => {
}
}
},
- { provide: Router, useClass: MockRouter },
RenderingQueueServices,
- PreviousRouteService,
{ provide: Location, useClass: SpyLocation }
]
});
@@ -175,8 +160,6 @@ describe('ViewerComponent', () => {
component = fixture.componentInstance;
alfrescoApiService = TestBed.get(AlfrescoApiService);
- previousRouteService = TestBed.get(PreviousRouteService);
- router = TestBed.get(Router);
});
describe('Extension Type Test', () => {
@@ -661,9 +644,9 @@ describe('ViewerComponent', () => {
});
});
- it('should go back when back button is clicked', async(() => {
+ it('should emit `showViewerChange` event on close', async(() => {
- spyOn(previousRouteService, 'getPreviousUrl').and.returnValue('home');
+ spyOn(component.showViewerChange, 'emit');
const button: HTMLButtonElement = element.querySelector('[data-automation-id="adf-toolbar-back"]') as HTMLButtonElement;
button.click();
@@ -671,11 +654,11 @@ describe('ViewerComponent', () => {
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
- expect(router.navigate).toHaveBeenCalled();
+ expect(component.showViewerChange.emit).toHaveBeenCalled();
});
}));
- it('should render close viewer button if it is a shared link', (done) => {
+ it('should not render close viewer button if it is a shared link', (done) => {
spyOn(alfrescoApiService.getInstance().core.sharedlinksApi, 'getSharedLink')
.and.returnValue(Promise.reject({}));
diff --git a/lib/core/viewer/components/viewer.component.ts b/lib/core/viewer/components/viewer.component.ts
index 1b95a7c66d..573f798d88 100644
--- a/lib/core/viewer/components/viewer.component.ts
+++ b/lib/core/viewer/components/viewer.component.ts
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-import { Location } from '@angular/common';
import {
Component, ContentChild, EventEmitter, HostListener, ElementRef,
Input, OnChanges, Output, SimpleChanges, TemplateRef,
@@ -25,7 +24,6 @@ import { RenditionPaging, SharedLinkEntry, Node, RenditionEntry, NodeEntry } fro
import { BaseEvent } from '../../events';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { LogService } from '../../services/log.service';
-import { PreviousRouteService } from '../../services/previous-route.service';
import { ViewerMoreActionsComponent } from './viewer-more-actions.component';
import { ViewerOpenWithComponent } from './viewer-open-with.component';
import { ViewerSidebarComponent } from './viewer-sidebar.component';
@@ -33,7 +31,6 @@ import { ViewerToolbarComponent } from './viewer-toolbar.component';
import { Subscription } from 'rxjs';
import { ViewUtilService } from '../services/view-util.service';
import { AppExtensionService, ViewerExtensionRef } from '@alfresco/adf-extensions';
-import { Router } from '@angular/router';
@Component({
selector: 'adf-viewer',
@@ -98,6 +95,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
@Input()
displayName: string;
+ /** @deprecated 3.2.0 */
/** Allows `back` navigation */
@Input()
allowGoBack = true;
@@ -239,11 +237,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
constructor(private apiService: AlfrescoApiService,
private viewUtils: ViewUtilService,
private logService: LogService,
- private location: Location,
private extensionService: AppExtensionService,
- private el: ElementRef,
- private router: Router,
- private previousRouteService: PreviousRouteService) {
+ private el: ElementRef) {
}
isSourceDefined(): boolean {
@@ -477,23 +472,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
}
onBackButtonClick() {
- if (this.overlayMode) {
- this.close();
- } else {
- const event = new BaseEvent();
- this.goBack.next(event);
-
- if (!event.defaultPrevented) {
-
- const previousUrl = this.previousRouteService.getPreviousUrl();
-
- if (previousUrl && previousUrl.includes('login') || window.history.length <= 2) {
- this.router.navigate([{outlets: {overlay: null, primary: ['home']}}]);
- } else {
- this.location.back();
- }
- }
- }
+ this.close();
}
onNavigateBeforeClick() {
@@ -719,7 +698,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
}
checkExtensions(extensionAllowed) {
- if (typeof extensionAllowed === 'string') {
+ if (typeof extensionAllowed === 'string') {
return this.extension.toLowerCase() === extensionAllowed.toLowerCase();
} else if (extensionAllowed.length > 0) {
return extensionAllowed.find((currentExtension) => {