From 187bff8496410e0e880ae3772fce68f80aa78a99 Mon Sep 17 00:00:00 2001 From: Anukriti Singh Date: Thu, 7 Dec 2023 11:55:09 +0530 Subject: [PATCH] [MNT-23433] removed close button from toolbar --- docs/extending/rules.md | 1 - .../context-submenus-ext.json | 17 ---- .../document-presets-ext.json | 17 ---- .../extensibility-configs/header-ext.json | 17 ---- .../info-drawer-ext.json | 17 ---- .../info-drawer-no-tabs-ext.json | 17 ---- .../extensibility-configs/metadata-ext.json | 17 ---- .../extensibility-configs/viewer-ext.json | 17 ---- .../aca-content/assets/app.extensions.json | 43 ++++----- projects/aca-content/assets/i18n/en.json | 3 +- .../aca-content/src/lib/aca-content.module.ts | 5 +- .../components/viewer/viewer.component.html | 2 +- .../components/viewer/viewer.component.scss | 6 +- .../components/viewer.component.ts | 2 +- .../aca-shared/rules/src/app.rules.spec.ts | 88 ++++++++++++++----- projects/aca-shared/rules/src/app.rules.ts | 16 +--- .../src/components/viewer/viewer.ts | 14 +-- 17 files changed, 105 insertions(+), 194 deletions(-) diff --git a/docs/extending/rules.md b/docs/extending/rules.md index 8b09985270..2c63e0d030 100644 --- a/docs/extending/rules.md +++ b/docs/extending/rules.md @@ -168,7 +168,6 @@ The button will be visible only when the linked rule evaluates to `true`. | 1.8.0 | user.isAdmin | Checks if user is admin. | | 1.9.0 | app.canShowLogout | Whether logout action should be present or not. | | 1.12.0 | app.isLibraryManager | Checks if user is library manager. | -| 4.4.0 | canClosePreview | Conditionally show/hide the right side viewer close button. | ## Navigation Evaluators diff --git a/e2e/protractor/resources/extensibility-configs/context-submenus-ext.json b/e2e/protractor/resources/extensibility-configs/context-submenus-ext.json index d4a5839247..336f324a71 100644 --- a/e2e/protractor/resources/extensibility-configs/context-submenus-ext.json +++ b/e2e/protractor/resources/extensibility-configs/context-submenus-ext.json @@ -1058,23 +1058,6 @@ } } ] - }, - { - "id": "app.viewer.separator.1", - "type": "separator", - "order": 11000 - }, - { - "id": "app.viewer.close", - "order": 12000, - "title": "APP.ACTIONS.CLOSE", - "icon": "close", - "actions": { - "click": "CLOSE_PREVIEW" - }, - "rules": { - "visible": "canClosePreview" - } } ], "shared": { diff --git a/e2e/protractor/resources/extensibility-configs/document-presets-ext.json b/e2e/protractor/resources/extensibility-configs/document-presets-ext.json index a0b0994c15..84229b582a 100644 --- a/e2e/protractor/resources/extensibility-configs/document-presets-ext.json +++ b/e2e/protractor/resources/extensibility-configs/document-presets-ext.json @@ -986,23 +986,6 @@ } } ] - }, - { - "id": "app.viewer.separator.1", - "type": "separator", - "order": 11000 - }, - { - "id": "app.viewer.close", - "order": 12000, - "title": "APP.ACTIONS.CLOSE", - "icon": "close", - "actions": { - "click": "CLOSE_PREVIEW" - }, - "rules": { - "visible": "canClosePreview" - } } ], "shared": { diff --git a/e2e/protractor/resources/extensibility-configs/header-ext.json b/e2e/protractor/resources/extensibility-configs/header-ext.json index a0f1fcade9..7d265f8289 100644 --- a/e2e/protractor/resources/extensibility-configs/header-ext.json +++ b/e2e/protractor/resources/extensibility-configs/header-ext.json @@ -1013,23 +1013,6 @@ } } ] - }, - { - "id": "app.viewer.separator.1", - "type": "separator", - "order": 11000 - }, - { - "id": "app.viewer.close", - "order": 12000, - "title": "APP.ACTIONS.CLOSE", - "icon": "close", - "actions": { - "click": "CLOSE_PREVIEW" - }, - "rules": { - "visible": "canClosePreview" - } } ], "shared": { diff --git a/e2e/protractor/resources/extensibility-configs/info-drawer-ext.json b/e2e/protractor/resources/extensibility-configs/info-drawer-ext.json index 4ef3fc8de4..3339338772 100644 --- a/e2e/protractor/resources/extensibility-configs/info-drawer-ext.json +++ b/e2e/protractor/resources/extensibility-configs/info-drawer-ext.json @@ -986,23 +986,6 @@ } } ] - }, - { - "id": "app.viewer.separator.1", - "type": "separator", - "order": 11000 - }, - { - "id": "app.viewer.close", - "order": 12000, - "title": "APP.ACTIONS.CLOSE", - "icon": "close", - "actions": { - "click": "CLOSE_PREVIEW" - }, - "rules": { - "visible": "canClosePreview" - } } ], "shared": { diff --git a/e2e/protractor/resources/extensibility-configs/info-drawer-no-tabs-ext.json b/e2e/protractor/resources/extensibility-configs/info-drawer-no-tabs-ext.json index 79b600cf5b..531c134f54 100644 --- a/e2e/protractor/resources/extensibility-configs/info-drawer-no-tabs-ext.json +++ b/e2e/protractor/resources/extensibility-configs/info-drawer-no-tabs-ext.json @@ -986,23 +986,6 @@ } } ] - }, - { - "id": "app.viewer.separator.1", - "type": "separator", - "order": 11000 - }, - { - "id": "app.viewer.close", - "order": 12000, - "title": "APP.ACTIONS.CLOSE", - "icon": "close", - "actions": { - "click": "CLOSE_PREVIEW" - }, - "rules": { - "visible": "canClosePreview" - } } ], "shared": { diff --git a/e2e/protractor/resources/extensibility-configs/metadata-ext.json b/e2e/protractor/resources/extensibility-configs/metadata-ext.json index f4fc101034..3fc4312a94 100644 --- a/e2e/protractor/resources/extensibility-configs/metadata-ext.json +++ b/e2e/protractor/resources/extensibility-configs/metadata-ext.json @@ -986,23 +986,6 @@ } } ] - }, - { - "id": "app.viewer.separator.1", - "type": "separator", - "order": 11000 - }, - { - "id": "app.viewer.close", - "order": 12000, - "title": "APP.ACTIONS.CLOSE", - "icon": "close", - "actions": { - "click": "CLOSE_PREVIEW" - }, - "rules": { - "visible": "canClosePreview" - } } ], "shared": { diff --git a/e2e/protractor/resources/extensibility-configs/viewer-ext.json b/e2e/protractor/resources/extensibility-configs/viewer-ext.json index e981c93d01..141e1c8c31 100644 --- a/e2e/protractor/resources/extensibility-configs/viewer-ext.json +++ b/e2e/protractor/resources/extensibility-configs/viewer-ext.json @@ -1012,23 +1012,6 @@ } } ] - }, - { - "id": "app.viewer.separator.1", - "type": "separator", - "order": 11000 - }, - { - "id": "app.viewer.close", - "order": 12000, - "title": "APP.ACTIONS.CLOSE", - "icon": "close", - "actions": { - "click": "CLOSE_PREVIEW" - }, - "rules": { - "visible": "canClosePreview" - } } ], "shared": { diff --git a/projects/aca-content/assets/app.extensions.json b/projects/aca-content/assets/app.extensions.json index 9eab6f6386..a52f7c55b5 100644 --- a/projects/aca-content/assets/app.extensions.json +++ b/projects/aca-content/assets/app.extensions.json @@ -1177,23 +1177,6 @@ } } ] - }, - { - "id": "app.viewer.separator.1", - "type": "separator", - "order": 11000 - }, - { - "id": "app.viewer.close", - "order": 12000, - "title": "APP.ACTIONS.CLOSE", - "icon": "close", - "actions": { - "click": "CLOSE_PREVIEW" - }, - "rules": { - "visible": "canClosePreview" - } } ], "shared": { @@ -1512,6 +1495,9 @@ "allowOnlyPredefinedValues": true, "field": "TAG" } + }, + "rules": { + "visible": "app.areTagsEnabled" } }, { @@ -1526,6 +1512,9 @@ "allowOnlyPredefinedValues": true, "field": "cm:categories" } + }, + "rules": { + "visible": "app.areCategoriesEnabled" } } ] @@ -2177,7 +2166,10 @@ "type": "text", "sortable": false, "desktopOnly": true, - "order": 60 + "order": 60, + "rules": { + "visible": "app.areTagsEnabled" + } } ], "libraries": [ @@ -2374,7 +2366,10 @@ "type": "text", "sortable": false, "desktopOnly": true, - "order": 80 + "order": 80, + "rules": { + "visible": "app.areTagsEnabled" + } } ], "recent": [ @@ -2439,7 +2434,10 @@ "type": "text", "sortable": false, "desktopOnly": true, - "order": 60 + "order": 60, + "rules": { + "visible": "app.areTagsEnabled" + } } ], "favorites": [ @@ -2514,7 +2512,10 @@ "type": "text", "sortable": false, "desktopOnly": true, - "order": 70 + "order": 70, + "rules": { + "visible": "app.areTagsEnabled" + } } ], "trashcan": [ diff --git a/projects/aca-content/assets/i18n/en.json b/projects/aca-content/assets/i18n/en.json index 786e0265d2..a3a48e7ad3 100644 --- a/projects/aca-content/assets/i18n/en.json +++ b/projects/aca-content/assets/i18n/en.json @@ -259,8 +259,7 @@ "LEAVE": "Leave Library", "EDIT_OFFLINE": "Edit Offline", "EDIT_OFFLINE_CANCEL": "Cancel Editing", - "CHANGE_ASPECT": "Edit Aspects", - "CLOSE": "Close" + "CHANGE_ASPECT": "Edit Aspects" }, "DIALOGS": { "CONFIRM_PURGE": { diff --git a/projects/aca-content/src/lib/aca-content.module.ts b/projects/aca-content/src/lib/aca-content.module.ts index 939b8abca4..87ade007ff 100644 --- a/projects/aca-content/src/lib/aca-content.module.ts +++ b/projects/aca-content/src/lib/aca-content.module.ts @@ -194,7 +194,6 @@ export class ContentServiceExtensionModule { canEditAspects: rules.canEditAspects, canInfoPreview: rules.canInfoPreview, showInfoSelectionButton: rules.showInfoSelectionButton, - canClosePreview: rules.canClosePreview, 'app.selection.canDelete': rules.canDeleteSelection, 'app.selection.file.canUnlock': rules.canUnlockFile, @@ -245,7 +244,9 @@ export class ContentServiceExtensionModule { 'app.isContentServiceEnabled': rules.isContentServiceEnabled, 'app.isUploadSupported': rules.isUploadSupported, 'app.canCreateLibrary': rules.canCreateLibrary, - 'app.isSearchSupported': rules.isSearchSupported + 'app.isSearchSupported': rules.isSearchSupported, + 'app.areTagsEnabled': rules.areTagsEnabled, + 'app.areCategoriesEnabled': rules.areCategoriesEnabled }); } } diff --git a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.html b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.html index f34e00c0c8..7b0793b48f 100644 --- a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.html +++ b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.html @@ -13,7 +13,7 @@ [allowDownload]="false" [allowFullScreen]="false" [overlayMode]="true" - [allowGoBack]="'viewer.isCloseButtonOnLeft' | adfAppConfig: true" + [allowGoBack]="'viewer.isCloseButtonOnLeft' | adfAppConfig: false" (showViewerChange)="onViewerVisibilityChanged()" [canNavigateBefore]="!!previousNodeId" [canNavigateNext]="!!nextNodeId" diff --git a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.scss b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.scss index 31ae358f5d..f2fcaea1c1 100644 --- a/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.scss +++ b/projects/aca-content/viewer/src/lib/components/viewer/viewer.component.scss @@ -16,8 +16,12 @@ } } + .adf-viewer-close-button { + padding-left: 12px; + } + // todo: remove this when viewer supports extensions - .adf-viewer-toolbar > * > button:last-child { + .adf-viewer-toolbar > * > button:nth-last-child(3) { display: none; } diff --git a/projects/aca-playwright-shared/src/page-objects/components/viewer.component.ts b/projects/aca-playwright-shared/src/page-objects/components/viewer.component.ts index a5114193e2..8c06ae37a4 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/viewer.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/viewer.component.ts @@ -31,7 +31,7 @@ export class ViewerComponent extends BaseComponent { private static rootElement = 'adf-viewer'; private viewerLocator = this.getChild('.adf-viewer-render-layout-content'); - public closeButtonLocator = this.getChild('button[title="Close"]'); + public closeButtonLocator = this.getChild('.adf-viewer-close-button'); public fileTitleButtonLocator = this.getChild('.adf-viewer__file-title'); public pdfViewerContentPages = this.getChild('.adf-pdf-viewer__content .page'); public shareButton = this.getChild('button[id="share-action-button"]'); diff --git a/projects/aca-shared/rules/src/app.rules.spec.ts b/projects/aca-shared/rules/src/app.rules.spec.ts index 8a9ed9c0ee..4f3a848a60 100644 --- a/projects/aca-shared/rules/src/app.rules.spec.ts +++ b/projects/aca-shared/rules/src/app.rules.spec.ts @@ -519,28 +519,6 @@ describe('app.evaluators', () => { }); }); - describe('canClosePreview', () => { - it('should return false when viewer.isCloseButtonOnLeft is true', () => { - const context: any = { - appConfig: { - get: () => true - } - }; - - expect(app.canClosePreview(context)).toBe(false); - }); - - it('should return true when viewer.isCloseButtonOnLeft is false', () => { - const context: any = { - appConfig: { - get: () => false - } - }; - - expect(app.canClosePreview(context)).toBe(true); - }); - }); - describe('isLibraryManager', () => { it('should return true when role is SiteManager', () => { const context: any = { @@ -880,6 +858,72 @@ describe('app.evaluators', () => { expect(app.canManagePermissions(context)).toBe(true); }); }); + + describe('areTagsEnabled', () => { + it('should call context.appConfig.get with correct parameters', () => { + const context: any = { + appConfig: { + get: jasmine.createSpy() + } + }; + + app.areTagsEnabled(context); + expect(context.appConfig.get).toHaveBeenCalledWith('plugins.tags', true); + }); + + it('should return true if get from appConfig returns true', () => { + expect( + app.areTagsEnabled({ + appConfig: { + get: () => true + } + } as any) + ).toBeTrue(); + }); + + it('should return false if get from appConfig returns false', () => { + expect( + app.areTagsEnabled({ + appConfig: { + get: () => false + } + } as any) + ).toBeFalse(); + }); + }); + + describe('areCategoriesEnabled', () => { + it('should call context.appConfig.get with correct parameters', () => { + const context: any = { + appConfig: { + get: jasmine.createSpy() + } + }; + + app.areCategoriesEnabled(context); + expect(context.appConfig.get).toHaveBeenCalledWith('plugins.categories', true); + }); + + it('should return true if get from appConfig returns true', () => { + expect( + app.areCategoriesEnabled({ + appConfig: { + get: () => true + } + } as any) + ).toBeTrue(); + }); + + it('should return false if get from appConfig returns false', () => { + expect( + app.areCategoriesEnabled({ + appConfig: { + get: () => false + } + } as any) + ).toBeFalse(); + }); + }); }); function createTestContext(): TestRuleContext { diff --git a/projects/aca-shared/rules/src/app.rules.ts b/projects/aca-shared/rules/src/app.rules.ts index 90ebbc9f37..df9e89374d 100644 --- a/projects/aca-shared/rules/src/app.rules.ts +++ b/projects/aca-shared/rules/src/app.rules.ts @@ -448,18 +448,6 @@ export const isTrashcanItemSelected = (context: RuleContext): boolean => [naviga */ export const canViewFile = (context: RuleContext): boolean => [hasFileSelected(context), navigation.isNotTrashcan(context)].every(Boolean); -/** - * Checks if user can **Close** opened file. - * JSON ref: `canClosePreview` - * - * @param context Rule execution context - */ -export const canClosePreview = (context: AcaRuleContext): boolean => { - const flag = context.appConfig.get('viewer.isCloseButtonOnLeft', true); - - return !flag; -}; - /** * Checks if user can **Leave** selected library. * JSON ref: `canLeaveLibrary` @@ -648,3 +636,7 @@ export function isSmartFolder(context: RuleContext): boolean { } return false; } + +export const areTagsEnabled = (context: AcaRuleContext): boolean => context.appConfig.get('plugins.tags', true); + +export const areCategoriesEnabled = (context: AcaRuleContext): boolean => context.appConfig.get('plugins.categories', true); diff --git a/projects/aca-testing-shared/src/components/viewer/viewer.ts b/projects/aca-testing-shared/src/components/viewer/viewer.ts index 293f299796..54d0467dda 100755 --- a/projects/aca-testing-shared/src/components/viewer/viewer.ts +++ b/projects/aca-testing-shared/src/components/viewer/viewer.ts @@ -32,10 +32,9 @@ export class Viewer extends Component { root = browser.$('adf-viewer'); viewerLayout = this.byCss('.adf-viewer-render-layout-content'); viewerContainer = this.byCss('.adf-viewer-render-content-container'); - closeButton = this.byCss('button[title="Close"]'); + closeButton = this.byCss('.adf-viewer-close-button'); fileTitle = this.byCss('.adf-viewer__file-title'); viewerExtensionContent = this.byCss('adf-preview-extension'); - pdfViewerContentPages = this.allByCss('.adf-pdf-viewer__content .page'); txtViewerContent = this.byCss('.adf-txt-viewer-content'); toolbar = new Toolbar('adf-viewer'); @@ -87,10 +86,6 @@ export class Viewer extends Component { return browser.isElementPresent(this.fileTitle); } - async getCloseButtonTooltip(): Promise { - return this.toolbar.getButtonTooltip(this.closeButton); - } - async getFileTitle(): Promise { return this.fileTitle.getText(); } @@ -107,13 +102,8 @@ export class Viewer extends Component { return ''; } - async isPdfViewerContentDisplayed(): Promise { - const count = await this.pdfViewerContentPages.count(); - return count > 0; - } - async clickCloseButton(): Promise { - const closeButton: ElementFinder = element(by.css('button[title="Close"]')); + const closeButton: ElementFinder = element(by.css('button[data-automation-id="adf-toolbar-back"]')); await BrowserActions.click(closeButton); } }