Skip to content

Commit

Permalink
Merge pull request #653 from geonetwork/fix-i18n-metadata
Browse files Browse the repository at this point in the history
Fix favorite star tooltip translation
  • Loading branch information
fgravin authored Oct 19, 2023
2 parents 13bd9db + c3234f2 commit 4c3057d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FavoritesServiceMock {

class TranslateServiceMock {
currentLang = 'fr'
instant = jest.fn(() => 'You can log in here')
get = jest.fn(() => of('You can log in here'))
}

describe('FavoriteStarComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
OnDestroy,
ViewChild,
} from '@angular/core'
import { map, pairwise } from 'rxjs/operators'
import { map, pairwise, withLatestFrom } from 'rxjs/operators'
import tippy from 'tippy.js'
import { TranslateService } from '@ngx-translate/core'
import { StarToggleComponent } from '@geonetwork-ui/ui/inputs'
import { Subscription } from 'rxjs'
import { Observable, Subscription } from 'rxjs'
import { CatalogRecord } from '@geonetwork-ui/common/domain/record'
import {
AuthService,
Expand Down Expand Up @@ -44,7 +44,7 @@ export class FavoriteStarComponent implements AfterViewInit, OnDestroy {
favoriteCount: number | null
loading = false
loginUrl = this.authService.loginUrl
loginMessage = this.translateService.instant(
loginMessage$: Observable<string> = this.translateService.get(
'favorite.not.authenticated.tooltip',
{
link: this.loginUrl,
Expand All @@ -67,18 +67,20 @@ export class FavoriteStarComponent implements AfterViewInit, OnDestroy {
) {}

ngAfterViewInit(): void {
this.subscription = this.isAnonymous$.subscribe((anonymous) => {
if (anonymous) {
tippy(this.starToggleRef.nativeElement, {
appendTo: () => document.body,
content: this.loginMessage,
allowHTML: true,
interactive: true,
zIndex: 40,
maxWidth: 250,
})
}
})
this.subscription = this.isAnonymous$
.pipe(withLatestFrom(this.loginMessage$))
.subscribe(([anonymous, loginMessage]) => {
if (anonymous) {
tippy(this.starToggleRef.nativeElement, {
appendTo: () => document.body,
content: loginMessage,
allowHTML: true,
interactive: true,
zIndex: 40,
maxWidth: 250,
})
}
})
this.countSubscription = this.favoritesService.myFavoritesUuid$
.pipe(pairwise())
.subscribe(([oldFavs, newFavs]) => {
Expand Down

0 comments on commit 4c3057d

Please sign in to comment.