From 9c4eae0b1050abfe0acca182baa41c7dd911a781 Mon Sep 17 00:00:00 2001 From: Dharan <14145706+dhrn@users.noreply.github.com> Date: Tue, 15 Jun 2021 13:51:32 +0530 Subject: [PATCH] [ACA-3541] show error message on empty search (#2164) * [ACA-3541] User is not able to reset the search to be able to display the entire list of results * * fixed lint --- .../search-input/search-input.component.spec.ts | 17 ++++++++++++++++- .../search-input/search-input.component.ts | 4 +++- src/assets/i18n/en.json | 10 +--------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/app/components/search/search-input/search-input.component.spec.ts b/src/app/components/search/search-input/search-input.component.spec.ts index 055a79446..8555e2087 100644 --- a/src/app/components/search/search-input/search-input.component.spec.ts +++ b/src/app/components/search/search-input/search-input.component.spec.ts @@ -28,7 +28,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing'; import { SearchInputComponent } from './search-input.component'; import { AppTestingModule } from '../../../testing/app-testing.module'; import { Actions, ofType } from '@ngrx/effects'; -import { SearchByTermAction, SearchActionTypes } from '@alfresco/aca-shared/store'; +import { SearchByTermAction, SearchActionTypes, SnackbarErrorAction, SnackbarActionTypes } from '@alfresco/aca-shared/store'; import { AppHookService } from '@alfresco/aca-shared'; import { map } from 'rxjs/operators'; import { SearchQueryBuilderService } from '@alfresco/adf-content-services'; @@ -139,6 +139,21 @@ describe('SearchInputComponent', () => { }); component.onSearchChange(searchedTerm); }); + + it('should show snack for empty search', (done) => { + const searchedTerm = ''; + actions$ + .pipe( + ofType(SnackbarActionTypes.Error), + map((action) => { + expect(action.payload).toBe('APP.BROWSE.SEARCH.EMPTY_SEARCH'); + }) + ) + .subscribe(() => { + done(); + }); + component.onSearchSubmit(searchedTerm); + }); }); describe('isLibrariesChecked()', () => { diff --git a/src/app/components/search/search-input/search-input.component.ts b/src/app/components/search/search-input/search-input.component.ts index 3c61b0ecc..d7a46be02 100644 --- a/src/app/components/search/search-input/search-input.component.ts +++ b/src/app/components/search/search-input/search-input.component.ts @@ -24,7 +24,7 @@ */ import { AppHookService } from '@alfresco/aca-shared'; -import { AppStore, SearchByTermAction, SearchOptionIds, SearchOptionModel } from '@alfresco/aca-shared/store'; +import { AppStore, SearchByTermAction, SearchOptionIds, SearchOptionModel, SnackbarErrorAction } from '@alfresco/aca-shared/store'; import { SearchQueryBuilderService } from '@alfresco/adf-content-services'; import { AppConfigService } from '@alfresco/adf-core'; import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; @@ -136,6 +136,8 @@ export class SearchInputComponent implements OnInit, OnDestroy { this.searchedWord = searchTerm; this.searchByOption(); + } else { + this.store.dispatch(new SnackbarErrorAction('APP.BROWSE.SEARCH.EMPTY_SEARCH')); } this.trigger.closeMenu(); } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 514204fd3..8ec0deb57 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -178,6 +178,7 @@ }, "UNKNOWN_LOCATION": "Unknown", "NO_RESULTS": "Your search returned 0 results", + "EMPTY_SEARCH": "Search term required", "NO_FILTER_RESULTS": "Your filter returned 0 results", "TOGGLE_SEARCH_FILTER": "Toggle search filter", "ERRORS": { @@ -403,15 +404,6 @@ } } }, - "PERMISSIONS": { - "DIALOG": { - "TITLE": "Manage Permissions", - "CLOSE": "Close", - "INHERIT_PERMISSIONS_BUTTON": "Inherit Permissions", - "INHERITED_PERMISSIONS_BUTTON": "Permissions Inherited", - "ADD_USER_OR_GROUP": "Add User or Group" - } - }, "SHARED_LINK": { "UNSHARE_PERMISSION_ERROR": "You don't have permission to unshare this file" },