diff --git a/src/app/suggestion-notifications/suggestions-notification/suggestions-notification.component.html b/src/app/suggestion-notifications/suggestions-notification/suggestions-notification.component.html index 3eac8d2099..838bdb95ad 100644 --- a/src/app/suggestion-notifications/suggestions-notification/suggestions-notification.component.html +++ b/src/app/suggestion-notifications/suggestions-notification/suggestions-notification.component.html @@ -1,8 +1,9 @@ 0"> - - + + {{ 'notification.suggestion.please' | translate }} + {{ 'notification.suggestion.review' | translate}} diff --git a/src/app/suggestion-notifications/suggestions-notification/suggestions-notification.component.ts b/src/app/suggestion-notifications/suggestions-notification/suggestions-notification.component.ts index e123f8f87f..357a6ca34e 100644 --- a/src/app/suggestion-notifications/suggestions-notification/suggestions-notification.component.ts +++ b/src/app/suggestion-notifications/suggestions-notification/suggestions-notification.component.ts @@ -1,8 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { SuggestionTarget } from '../../core/suggestion-notifications/models/suggestion-target.model'; -import { TranslateService } from '@ngx-translate/core'; import { SuggestionTargetsStateService } from '../suggestion-targets/suggestion-targets.state.service'; -import { NotificationsService } from '../../shared/notifications/notifications.service'; import { SuggestionsService } from '../suggestions.service'; import { Observable } from 'rxjs'; @@ -22,9 +20,7 @@ export class SuggestionsNotificationComponent implements OnInit { suggestionsRD$: Observable; constructor( - private translateService: TranslateService, private suggestionTargetsStateService: SuggestionTargetsStateService, - private notificationsService: NotificationsService, private suggestionsService: SuggestionsService ) { } diff --git a/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.html b/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.html index 8b13789179..474dfa329e 100644 --- a/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.html +++ b/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.html @@ -1 +1,27 @@ + + + + × + + + + + + + + + + 0"> + + {{ 'notification.suggestion.please' | translate }} + {{ 'notification.suggestion.review' | translate}} + + + + + + + + diff --git a/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.spec.ts b/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.spec.ts index 8a5721968b..c8d59115d8 100644 --- a/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.spec.ts +++ b/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.spec.ts @@ -3,8 +3,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { SuggestionsPopupComponent } from './suggestions-popup.component'; import { TranslateModule } from '@ngx-translate/core'; import { SuggestionTargetsStateService } from '../suggestion-targets/suggestion-targets.state.service'; -import { NotificationsService } from '../../shared/notifications/notifications.service'; -import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { of as observableOf } from 'rxjs'; import { mockSuggestionTargetsObjectOne } from '../../shared/mocks/publication-claim-targets.mock'; @@ -13,7 +11,6 @@ import { SuggestionsService } from '../suggestions.service'; describe('SuggestionsPopupComponent', () => { let component: SuggestionsPopupComponent; let fixture: ComponentFixture; - let notificationsService: NotificationsService; const suggestionStateService = jasmine.createSpyObj('SuggestionTargetsStateService', { hasUserVisitedSuggestions: jasmine.createSpy('hasUserVisitedSuggestions'), @@ -35,7 +32,6 @@ describe('SuggestionsPopupComponent', () => { providers: [ { provide: SuggestionTargetsStateService, useValue: suggestionStateService }, { provide: SuggestionsService, useValue: suggestionService }, - { provide: NotificationsService, useValue: new NotificationsServiceStub() }, ], schemas: [NO_ERRORS_SCHEMA] @@ -69,12 +65,10 @@ describe('SuggestionsPopupComponent', () => { fixture = TestBed.createComponent(SuggestionsPopupComponent); component = fixture.componentInstance; - notificationsService = (component as any).notificationsService; fixture.detectChanges(); }); it('should show a notification when new publication suggestions are available', () => { - expect(notificationsService.success).toHaveBeenCalled(); expect(suggestionStateService.dispatchRefreshUserSuggestionsAction).toHaveBeenCalled(); expect(suggestionStateService.dispatchMarkUserSuggestionsAsVisitedAction).toHaveBeenCalled(); }); diff --git a/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.ts b/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.ts index 0b2176ea89..2cf3db128e 100644 --- a/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.ts +++ b/src/app/suggestion-notifications/suggestions-popup/suggestions-popup.component.ts @@ -1,12 +1,14 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; -import { TranslateService } from '@ngx-translate/core'; import { SuggestionTargetsStateService } from '../suggestion-targets/suggestion-targets.state.service'; -import { NotificationsService } from '../../shared/notifications/notifications.service'; import { SuggestionsService } from '../suggestions.service'; import { take, takeUntil } from 'rxjs/operators'; import { SuggestionTarget } from '../../core/suggestion-notifications/models/suggestion-target.model'; import { isNotEmpty } from '../../shared/empty.util'; -import { combineLatest, Subject } from 'rxjs'; +import { combineLatest, Observable, of, Subject } from 'rxjs'; +import { trigger } from '@angular/animations'; + + +import { fromTopEnter } from '../../shared/animations/fromTop'; /** * Show suggestions on a popover window, used on the homepage @@ -14,7 +16,12 @@ import { combineLatest, Subject } from 'rxjs'; @Component({ selector: 'ds-suggestions-popup', templateUrl: './suggestions-popup.component.html', - styleUrls: ['./suggestions-popup.component.scss'] + styleUrls: ['./suggestions-popup.component.scss'], + animations: [ + trigger('enterLeave', [ + fromTopEnter + ]) + ], }) export class SuggestionsPopupComponent implements OnInit, OnDestroy { @@ -22,10 +29,11 @@ export class SuggestionsPopupComponent implements OnInit, OnDestroy { subscription; + suggestionsRD$: Observable; + + constructor( - private translateService: TranslateService, private suggestionTargetsStateService: SuggestionTargetsStateService, - private notificationsService: NotificationsService, private suggestionsService: SuggestionsService ) { } @@ -42,7 +50,7 @@ export class SuggestionsPopupComponent implements OnInit, OnDestroy { this.suggestionTargetsStateService.dispatchRefreshUserSuggestionsAction(); if (isNotEmpty(suggestions)) { if (!visited) { - suggestions.forEach((suggestionTarget: SuggestionTarget) => this.showNotificationForNewSuggestions(suggestionTarget)); + this.suggestionsRD$ = of(suggestions); this.suggestionTargetsStateService.dispatchMarkUserSuggestionsAsVisitedAction(); notifier.next(null); notifier.complete(); @@ -51,21 +59,24 @@ export class SuggestionsPopupComponent implements OnInit, OnDestroy { }); } - /** - * Show a notification to user for a new suggestions detected - * @param suggestionTarget - * @private - */ - private showNotificationForNewSuggestions(suggestionTarget: SuggestionTarget): void { - const content = this.translateService.instant(this.labelPrefix + 'suggestion', - this.suggestionsService.getNotificationSuggestionInterpolation(suggestionTarget)); - this.notificationsService.success('', content, {timeOut:0}, true); - } - ngOnDestroy() { if (this.subscription) { this.subscription.unsubscribe(); } } + /** + * Interpolated params to build the notification suggestions notification. + * @param suggestionTarget + */ + public getNotificationSuggestionInterpolation(suggestionTarget: SuggestionTarget): any { + return this.suggestionsService.getNotificationSuggestionInterpolation(suggestionTarget); + } + + /** + * Hide popup from view + */ + public removePopup() { + this.suggestionsRD$ = null; + } } diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 15134a01fd..05b3964a17 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3120,7 +3120,11 @@ "mydspace.import": "Import", - "notification.suggestion": "We found {{count}} publications in the {{source}} that seems to be related to your profile. Please review the suggestions", + "notification.suggestion": "We found {{count}} publications in the {{source}} that seems to be related to your profile.", + + "notification.suggestion.review": "review the suggestions", + + "notification.suggestion.please": "Please", "nav.browse.header": "All of DSpace",