Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix favorite star tooltip translation #653

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading