feat: translate domain events in watchlistsList

This commit is contained in:
Maël Gangloff 2024-08-03 02:21:11 +02:00
parent ee47f9aac6
commit 9afaf11476
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
3 changed files with 42 additions and 35 deletions

View File

@ -21,31 +21,33 @@ export function actionToColor(a: EventAction) {
a === 'last changed' ? 'blue' : 'default'
}
export const domainEvent = () => ({
registration: t`Registration`,
reregistration: t`Reregistration`,
'last changed': t`Last changed`,
expiration: t`Expiration`,
deletion: t`Deletion`,
reinstantiation: t`Reinstantiation`,
transfer: t`Transfer`,
locked: t`Locked`,
unlocked: t`Unlocked`,
'registrar expiration': t`Registrar expiration`,
'enum validation expiration': t`ENUM validation expiration`
})
export function EventTimeline({domain}: { domain: Domain }) {
const sm = useBreakpoint('sm')
const domainEvent = {
registration: t`Registration`,
reregistration: t`Reregistration`,
'last changed': t`Last changed`,
expiration: t`Expiration`,
deletion: t`Deletion`,
reinstantiation: t`Reinstantiation`,
transfer: t`Transfer`,
locked: t`Locked`,
unlocked: t`Unlocked`,
'registrar expiration': t`Registrar expiration`,
'enum validation expiration': t`ENUM validation expiration`
}
const locale = navigator.language.split('-')[0]
const domainEventTranslated = domainEvent()
return <Timeline
mode={sm ? "left" : "right"}
items={domain.events
.sort((e1, e2) => new Date(e2.date).getTime() - new Date(e1.date).getTime())
.map(({action, date}) => {
let dot
if (action === 'registration') {
dot = <SignatureOutlined style={{fontSize: '16px'}}/>
@ -61,7 +63,7 @@ export function EventTimeline({domain}: { domain: Domain }) {
dot = <ReloadOutlined style={{fontSize: '16px'}}/>
}
const eventName = Object.keys(domainEvent).includes(action) ? domainEvent[action as keyof typeof domainEvent] : action
const eventName = Object.keys(domainEventTranslated).includes(action) ? domainEventTranslated[action as keyof typeof domainEventTranslated] : action
const dateStr = new Date(date).toLocaleString(locale)
const text = sm ? {

View File

@ -4,7 +4,7 @@ import {deleteWatchlist} from "../../utils/api";
import {DeleteFilled} from "@ant-design/icons";
import React from "react";
import useBreakpoint from "../../hooks/useBreakpoint";
import {actionToColor} from "../search/EventTimeline";
import {actionToColor, domainEvent} from "../search/EventTimeline";
import {Watchlist} from "../../pages/tracking/WatchlistPage";
const {useToken} = theme;
@ -14,6 +14,8 @@ export function WatchlistsList({watchlists, onDelete}: { watchlists: Watchlist[]
const {token} = useToken()
const sm = useBreakpoint('sm')
const domainEventTranslated = domainEvent()
const columns = [
{
title: t`Domain names`,
@ -49,7 +51,10 @@ export function WatchlistsList({watchlists, onDelete}: { watchlists: Watchlist[]
dataSource={[{
domains: watchlist.domains.map(d => <Tag>{d.ldhName}</Tag>),
events: watchlist.triggers?.filter(t => t.action === 'email')
.map(t => <Tag color={actionToColor(t.event)}>{t.event}</Tag>)
.map(t => <Tag color={actionToColor(t.event)}>
{domainEventTranslated[t.event as keyof typeof domainEventTranslated]}
</Tag>
)
}]}
{...(sm ? {scroll: {y: 'max-content'}} : {scroll: {y: 240}})}
/>

View File

@ -3,47 +3,47 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
#: assets/components/search/EventTimeline.tsx:28
#: assets/components/search/EventTimeline.tsx:25
msgid "Registration"
msgstr ""
#: assets/components/search/EventTimeline.tsx:29
#: assets/components/search/EventTimeline.tsx:26
msgid "Reregistration"
msgstr ""
#: assets/components/search/EventTimeline.tsx:30
#: assets/components/search/EventTimeline.tsx:27
msgid "Last changed"
msgstr ""
#: assets/components/search/EventTimeline.tsx:31
#: assets/components/search/EventTimeline.tsx:28
msgid "Expiration"
msgstr ""
#: assets/components/search/EventTimeline.tsx:32
#: assets/components/search/EventTimeline.tsx:29
msgid "Deletion"
msgstr ""
#: assets/components/search/EventTimeline.tsx:33
#: assets/components/search/EventTimeline.tsx:30
msgid "Reinstantiation"
msgstr ""
#: assets/components/search/EventTimeline.tsx:34
#: assets/components/search/EventTimeline.tsx:31
msgid "Transfer"
msgstr ""
#: assets/components/search/EventTimeline.tsx:35
#: assets/components/search/EventTimeline.tsx:32
msgid "Locked"
msgstr ""
#: assets/components/search/EventTimeline.tsx:36
#: assets/components/search/EventTimeline.tsx:33
msgid "Unlocked"
msgstr ""
#: assets/components/search/EventTimeline.tsx:37
#: assets/components/search/EventTimeline.tsx:34
msgid "Registrar expiration"
msgstr ""
#: assets/components/search/EventTimeline.tsx:38
#: assets/components/search/EventTimeline.tsx:35
msgid "ENUM validation expiration"
msgstr ""
@ -158,7 +158,7 @@ msgid "At least one domain name"
msgstr ""
#: assets/components/tracking/WatchlistForm.tsx:101
#: assets/components/tracking/WatchlistsList.tsx:19
#: assets/components/tracking/WatchlistsList.tsx:21
msgid "Domain names"
msgstr ""
@ -257,29 +257,29 @@ msgid ""
"names via the Provider's API"
msgstr ""
#: assets/components/tracking/WatchlistsList.tsx:23
#: assets/components/tracking/WatchlistsList.tsx:25
msgid "Tracked events"
msgstr ""
#: assets/components/tracking/WatchlistsList.tsx:32
#: assets/components/tracking/WatchlistsList.tsx:34
msgid "Watchlist"
msgstr ""
#: assets/components/tracking/WatchlistsList.tsx:35
#: assets/components/tracking/WatchlistsList.tsx:37
msgid "Delete the Watchlist"
msgstr ""
#: assets/components/tracking/WatchlistsList.tsx:36
#: assets/components/tracking/WatchlistsList.tsx:38
msgid "Are you sure to delete this Watchlist?"
msgstr ""
#: assets/components/tracking/ConnectorsList.tsx:33
#: assets/components/tracking/WatchlistsList.tsx:38
#: assets/components/tracking/WatchlistsList.tsx:40
msgid "Yes"
msgstr ""
#: assets/components/tracking/ConnectorsList.tsx:34
#: assets/components/tracking/WatchlistsList.tsx:39
#: assets/components/tracking/WatchlistsList.tsx:41
msgid "No"
msgstr ""