From b7ba7b94b246e79ce75043c1ad825e233f3b847f Mon Sep 17 00:00:00 2001 From: Vito Date: Wed, 16 Jun 2021 15:21:29 +0100 Subject: [PATCH] [ACA-4471] - Added show preview action for files in search results (#2169) * [ACA-4472] - added preview button on info drawer * [ACA-4472] - added preview button on info drawer * [ACA-4472] - added preview button on info drawer * [ACA-4472] - fixed lint * [ACA-4472] - fixed unit test * [ACA-4472] - fixed wrong import * [ACA-4472] - reverted app.config * [ACA-4472] - added some upgrades for styling * [ACA-4472] - added some upgrades for styling * [ACA-4472] - start fixing e2e * [ACA-4472] - wrong whitespace * [ACA-4471] - readded view button and fixed bug on closing * [ACA-4471] - readded action * [ACA-4238] - fix e2e #2 * [ACA-4471] - readded view button for e2e * [ACA-4471] - readded view button for e2e --- projects/aca-shared/rules/src/app.rules.ts | 13 ++++++++ .../info-drawer/info-drawer.component.html | 2 +- .../info-drawer/info-drawer.component.ts | 15 +++++++-- .../store/src/actions/app.actions.ts | 14 ++++++++- .../store/src/selectors/app.selectors.ts | 1 + .../aca-shared/store/src/states/app.state.ts | 1 + .../search-results.component.html | 29 +++++++++++++++-- .../search-results.component.scss | 29 +++++++++++++++++ .../search-results.component.ts | 22 ++++++++++++- .../toggle-info-drawer.component.ts | 2 +- src/app/extensions/core.extensions.module.ts | 2 ++ src/app/material.module.ts | 5 +-- src/app/store/initial-state.ts | 1 + src/app/store/reducers/app.reducer.ts | 31 ++++++++++++++++++- src/assets/app.extensions.json | 24 +++++++++++++- src/assets/i18n/en.json | 3 +- 16 files changed, 180 insertions(+), 14 deletions(-) diff --git a/projects/aca-shared/rules/src/app.rules.ts b/projects/aca-shared/rules/src/app.rules.ts index cb8c78070..567bac9d8 100644 --- a/projects/aca-shared/rules/src/app.rules.ts +++ b/projects/aca-shared/rules/src/app.rules.ts @@ -495,3 +495,16 @@ export function canShowLogout(context: AcaRuleContext): boolean { export function isLibraryManager(context: RuleContext): boolean { return hasLibrarySelected(context) && context.selection.library.entry && context.selection.library.entry.role === 'SiteManager'; } + +/** + * Checks if the preview button for search results can be showed + * JSON ref: `canInfoPreview` + * @param context Rule execution context + */ +export function canInfoPreview(context: RuleContext): boolean { + return navigation.isSearchResults(context) && !isMultiselection(context) && !hasFolderSelected(context) && !navigation.isPreview(context); +} + +export function showInfoSelectionButton(context: RuleContext): boolean { + return navigation.isSearchResults(context) && !navigation.isPreview(context); +} diff --git a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.html b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.html index 47e911092..0a309120a 100644 --- a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.html +++ b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.html @@ -9,7 +9,7 @@ > - + diff --git a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts index c1ade264c..96f5beca8 100644 --- a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts +++ b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts @@ -27,12 +27,11 @@ import { Component, HostListener, Input, OnChanges, OnDestroy, OnInit } from '@a import { MinimalNodeEntity, MinimalNodeEntryEntity, SiteEntry } from '@alfresco/js-api'; import { ContentActionRef, SidebarTabRef } from '@alfresco/adf-extensions'; import { Store } from '@ngrx/store'; -import { getAppSelection, SetInfoDrawerStateAction, ToggleInfoDrawerAction } from '@alfresco/aca-shared/store'; +import { getAppSelection, SetInfoDrawerStateAction, ToggleInfoDrawerAction, infoDrawerPreview } from '@alfresco/aca-shared/store'; import { AppExtensionService } from '../../services/app.extension.service'; import { ContentApiService } from '../../services/content-api.service'; import { takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs'; - @Component({ selector: 'aca-info-drawer', templateUrl: './info-drawer.component.html' @@ -49,6 +48,7 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy { tabs: Array = []; actions: Array = []; onDestroy$ = new Subject(); + preventFromClosing = false; @HostListener('keydown.escape') onEscapeKeyboardEvent(): void { @@ -65,12 +65,21 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy { .subscribe(() => { this.actions = this.extensions.getAllowedSidebarActions(); }); + + this.store + .select(infoDrawerPreview) + .pipe(takeUntil(this.onDestroy$)) + .subscribe((isInfoDrawerPreviewOpened) => { + this.preventFromClosing = isInfoDrawerPreviewOpened; + }); } ngOnDestroy() { this.onDestroy$.next(true); this.onDestroy$.complete(); - this.store.dispatch(new SetInfoDrawerStateAction(false)); + if (!this.preventFromClosing) { + this.store.dispatch(new SetInfoDrawerStateAction(false)); + } } ngOnChanges() { diff --git a/projects/aca-shared/store/src/actions/app.actions.ts b/projects/aca-shared/store/src/actions/app.actions.ts index 01679f437..6f4ac3b2a 100644 --- a/projects/aca-shared/store/src/actions/app.actions.ts +++ b/projects/aca-shared/store/src/actions/app.actions.ts @@ -44,7 +44,9 @@ export enum AppActionTypes { SetInfoDrawerState = 'SET_INFO_DRAWER_STATE', SetInfoDrawerMetadataAspect = 'SET_INFO_DRAWER_METADATA_ASPECT', CloseModalDialogs = 'CLOSE_MODAL_DIALOGS', - SetFileUploadingDialog = 'SET_FILE_UPLOADING_DIALOG' + SetFileUploadingDialog = 'SET_FILE_UPLOADING_DIALOG', + ShowInfoDrawerPreview = 'SHOW_INFO_DRAWER_PREVIEW', + SetInfoDrawerPreviewState = 'SET_INFO_DRAWER_PREVIEW_STATE' } export class SetSettingsParameterAction implements Action { @@ -134,3 +136,13 @@ export class SetFileUploadingDialogAction implements Action { constructor(public payload: boolean) {} } + +export class ShowInfoDrawerPreviewAction implements Action { + readonly type = AppActionTypes.ShowInfoDrawerPreview; +} + +export class SetInfoDrawerPreviewStateAction implements Action { + readonly type = AppActionTypes.SetInfoDrawerPreviewState; + + constructor(public payload: boolean) {} +} diff --git a/projects/aca-shared/store/src/selectors/app.selectors.ts b/projects/aca-shared/store/src/selectors/app.selectors.ts index 709311fc2..6b57b7113 100644 --- a/projects/aca-shared/store/src/selectors/app.selectors.ts +++ b/projects/aca-shared/store/src/selectors/app.selectors.ts @@ -39,6 +39,7 @@ export const getAppSelection = createSelector(selectApp, (state) => state.select export const getSharedUrl = createSelector(selectApp, (state) => state.sharedUrl); export const getNavigationState = createSelector(selectApp, (state) => state.navigation); export const isInfoDrawerOpened = createSelector(selectApp, (state) => state.infoDrawerOpened); +export const infoDrawerPreview = createSelector(selectApp, (state) => state.infoDrawerPreview); export const showFacetFilter = createSelector(selectApp, (state) => state.showFacetFilter); export const getDocumentDisplayMode = createSelector(selectApp, (state) => state.documentDisplayMode); export const getRepositoryStatus = createSelector(selectApp, (state) => state.repository); diff --git a/projects/aca-shared/store/src/states/app.state.ts b/projects/aca-shared/store/src/states/app.state.ts index 9b30803aa..984c8570b 100644 --- a/projects/aca-shared/store/src/states/app.state.ts +++ b/projects/aca-shared/store/src/states/app.state.ts @@ -37,6 +37,7 @@ export interface AppState { user: ProfileState; navigation: NavigationState; infoDrawerOpened: boolean; + infoDrawerPreview: boolean; infoDrawerMetadataAspect: string; showFacetFilter: boolean; documentDisplayMode: string; diff --git a/src/app/components/search/search-results/search-results.component.html b/src/app/components/search/search-results/search-results.component.html index af905470b..04350b64d 100644 --- a/src/app/components/search/search-results/search-results.component.html +++ b/src/app/components/search/search-results/search-results.component.html @@ -112,8 +112,33 @@ -