-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MNT-23433] configure position for close button on Viewer #9143
Changes from 13 commits
2d89b98
ead6b43
81b37e4
4268827
a3fa887
b0c5122
8e6e01d
6370e11
fd60fc9
ab72cd7
c24834b
7aa061b
3daf9bc
1b78238
fdbadb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ import { MatButtonModule } from '@angular/material/button'; | |
import { MatIconModule } from '@angular/material/icon'; | ||
import { ContentInfo, Node, NodeEntry, VersionEntry } from '@alfresco/js-api'; | ||
import { AlfrescoViewerComponent, NodeActionsService, RenditionService } from '@alfresco/adf-content-services'; | ||
import { CoreTestingModule, EventMock, ViewUtilService, ViewerComponent } from '@alfresco/adf-core'; | ||
import { CloseButtonPosition, CoreTestingModule, EventMock, ViewUtilService, ViewerComponent } from '@alfresco/adf-core'; | ||
import { NodesApiService } from '../../common/services/nodes-api.service'; | ||
import { UploadService } from '../../common/services/upload.service'; | ||
import { FileModel } from '../../common/models/file.model'; | ||
|
@@ -691,11 +691,12 @@ describe('AlfrescoViewerComponent', () => { | |
}); | ||
|
||
it('should render close viewer button if it is not a shared link', (done) => { | ||
component.closeButtonPosition = CloseButtonPosition.Left; | ||
fixture.detectChanges(); | ||
fixture.whenStable().then(() => { | ||
fixture.detectChanges(); | ||
expect(element.querySelector('[data-automation-id="adf-toolbar-back"]')).toBeDefined(); | ||
expect(element.querySelector('[data-automation-id="adf-toolbar-back"]')).not.toBeNull(); | ||
expect(element.querySelector('[data-automation-id="adf-toolbar-left-back"]')).toBeDefined(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of those statements is obsolete, first you check if the element is defined and then if it's not a null There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed obsolete statements |
||
expect(element.querySelector('[data-automation-id="adf-toolbar-left-back"]')).not.toBeNull(); | ||
done(); | ||
}); | ||
}); | ||
|
@@ -709,7 +710,7 @@ describe('AlfrescoViewerComponent', () => { | |
component.ngOnChanges(); | ||
fixture.whenStable().then(() => { | ||
fixture.detectChanges(); | ||
expect(element.querySelector('[data-automation-id="adf-toolbar-back"]')).toBeNull(); | ||
expect(element.querySelector('[data-automation-id="adf-toolbar-left-back"]')).toBeNull(); | ||
done(); | ||
}); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,9 @@ | |
</button> | ||
</ng-container> | ||
|
||
<button *ngIf="allowGoBack" | ||
<button *ngIf="allowGoBack && closeButtonPosition === 'left'" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
class="adf-viewer-close-button" | ||
data-automation-id="adf-toolbar-back" | ||
data-automation-id="adf-toolbar-left-back" | ||
[attr.aria-label]="'ADF_VIEWER.ACTIONS.CLOSE' | translate" | ||
mat-icon-button | ||
title="{{ 'ADF_VIEWER.ACTIONS.CLOSE' | translate }}" | ||
|
@@ -90,7 +90,7 @@ | |
<mat-icon>fullscreen</mat-icon> | ||
</button> | ||
|
||
<ng-container *ngIf="allowRightSidebar"> | ||
<ng-container *ngIf="allowRightSidebar && !hideInfoButton"> | ||
<adf-toolbar-divider></adf-toolbar-divider> | ||
|
||
<button mat-icon-button | ||
|
@@ -120,6 +120,19 @@ | |
</mat-menu> | ||
</ng-container> | ||
|
||
<ng-container *ngIf="allowGoBack && closeButtonPosition === 'right'"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
<adf-toolbar-divider></adf-toolbar-divider> | ||
|
||
<button class="adf-viewer-close-button" | ||
data-automation-id="adf-toolbar-right-back" | ||
[attr.aria-label]="'ADF_VIEWER.ACTIONS.CLOSE' | translate" | ||
mat-icon-button | ||
title="{{ 'ADF_VIEWER.ACTIONS.CLOSE' | translate }}" | ||
(click)="onClose()"> | ||
<mat-icon>close</mat-icon> | ||
</button> | ||
</ng-container> | ||
|
||
</adf-toolbar> | ||
</ng-container> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,8 @@ import { | |
ViewUtilService, | ||
AppConfigService, | ||
DownloadPromptDialogComponent, | ||
DownloadPromptActions | ||
DownloadPromptActions, | ||
CloseButtonPosition | ||
} from '@alfresco/adf-core'; | ||
import { of } from 'rxjs'; | ||
import { ViewerWithCustomMoreActionsComponent } from './mock/adf-viewer-container-more-actions.component.mock'; | ||
|
@@ -351,11 +352,12 @@ describe('ViewerComponent', () => { | |
}); | ||
|
||
it('should render close viewer button if it is not a shared link', (done) => { | ||
component.closeButtonPosition = CloseButtonPosition.Left; | ||
fixture.detectChanges(); | ||
fixture.whenStable().then(() => { | ||
fixture.detectChanges(); | ||
expect(element.querySelector('[data-automation-id="adf-toolbar-back"]')).toBeDefined(); | ||
expect(element.querySelector('[data-automation-id="adf-toolbar-back"]')).not.toBeNull(); | ||
expect(element.querySelector('[data-automation-id="adf-toolbar-left-back"]')).toBeDefined(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here for obsolete check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed obsolete statements |
||
expect(element.querySelector('[data-automation-id="adf-toolbar-left-back"]')).not.toBeNull(); | ||
done(); | ||
}); | ||
}); | ||
|
@@ -422,6 +424,26 @@ describe('ViewerComponent', () => { | |
}); | ||
}); | ||
|
||
describe('Info Button', () => { | ||
const infoButton = () => element.querySelector<HTMLButtonElement>('[data-automation-id="adf-toolbar-sidebar"]'); | ||
|
||
it('should NOT display info button on the right side', () => { | ||
component.allowRightSidebar = true; | ||
component.hideInfoButton = true; | ||
fixture.detectChanges(); | ||
|
||
expect(infoButton()).toBeNull(); | ||
}); | ||
|
||
it('should display info button on the right side', () => { | ||
component.allowRightSidebar = true; | ||
component.hideInfoButton = false; | ||
fixture.detectChanges(); | ||
|
||
expect(infoButton()).not.toBeNull(); | ||
}); | ||
}); | ||
|
||
describe('View', () => { | ||
|
||
describe('Overlay mode true', () => { | ||
|
@@ -525,6 +547,38 @@ describe('ViewerComponent', () => { | |
}); | ||
}); | ||
|
||
describe('Close Button', () => { | ||
|
||
const getRightCloseButton = () => element.querySelector<HTMLButtonElement>('[data-automation-id="adf-toolbar-right-back"]'); | ||
const getLeftCloseButton = () => element.querySelector<HTMLButtonElement>('[data-automation-id="adf-toolbar-left-back"]'); | ||
|
||
it('should show close button on left side when closeButtonPosition is left and allowGoBack is true', () => { | ||
AleksanderSklorz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
component.allowGoBack = true; | ||
component.closeButtonPosition = CloseButtonPosition.Left; | ||
fixture.detectChanges(); | ||
|
||
expect(getLeftCloseButton()).not.toBeNull(); | ||
expect(getRightCloseButton()).toBeNull(); | ||
}); | ||
|
||
it('should show close button on right side when closeButtonPosition is right and allowGoBack is true', () => { | ||
AleksanderSklorz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
component.allowGoBack = true; | ||
component.closeButtonPosition = CloseButtonPosition.Right; | ||
fixture.detectChanges(); | ||
|
||
expect(getRightCloseButton()).not.toBeNull(); | ||
expect(getLeftCloseButton()).toBeNull(); | ||
}); | ||
|
||
it('should hide close button allowGoBack is false', () => { | ||
component.allowGoBack = false; | ||
fixture.detectChanges(); | ||
|
||
expect(getRightCloseButton()).toBeNull(); | ||
expect(getLeftCloseButton()).toBeNull(); | ||
}); | ||
}); | ||
|
||
describe('Viewer component - Full Screen Mode - Mocking fixture element', () => { | ||
|
||
beforeEach(() => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done