From 92b6c712fd7528ab76428cbd27539bba4eb81b6a Mon Sep 17 00:00:00 2001 From: Harmit Goswami Date: Thu, 27 Jun 2024 12:08:38 -0400 Subject: [PATCH 1/5] Added review_time info when hovering reviewed strings --- translate/public/locale/en-US/translate.ftl | 8 ++++---- .../src/modules/history/components/HistoryTranslation.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/translate/public/locale/en-US/translate.ftl b/translate/public/locale/en-US/translate.ftl index 81d8a36c62..27a023558f 100644 --- a/translate/public/locale/en-US/translate.ftl +++ b/translate/public/locale/en-US/translate.ftl @@ -369,13 +369,13 @@ history-Translation--span-copied = .title = Copied ({ $machinerySources }) history-translation--approved = - .title = Approved by { $user } + .title = Approved by { $user } on { $reviewedDate } history-translation--approved-anonymous = - .title = Approved + .title = Approved on { $reviewedDate } history-translation--rejected = - .title = Rejected by { $user } + .title = Rejected by { $user } on { $reviewedDate } history-translation--rejected-anonymous = - .title = Rejected + .title = Rejected on { $reviewedDate } history-translation--unreviewed = .title = Not reviewed yet diff --git a/translate/src/modules/history/components/HistoryTranslation.tsx b/translate/src/modules/history/components/HistoryTranslation.tsx index a001ade186..915efb5aac 100644 --- a/translate/src/modules/history/components/HistoryTranslation.tsx +++ b/translate/src/modules/history/components/HistoryTranslation.tsx @@ -196,7 +196,7 @@ export function HistoryTranslationBase({ const review = { id: 'history-translation--unreviewed', - vars: { user: '' }, + vars: { user: '', reviewedDate: translation.date }, attrs: { title: true }, }; if (translation.approved) { From 22373e813d7754fe422f9c806093931baaa5547f Mon Sep 17 00:00:00 2001 From: Harmit Goswami Date: Thu, 27 Jun 2024 13:28:46 -0400 Subject: [PATCH 2/5] Changed time format to be consistent with comment header --- .../src/modules/history/components/HistoryTranslation.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/translate/src/modules/history/components/HistoryTranslation.tsx b/translate/src/modules/history/components/HistoryTranslation.tsx index 915efb5aac..2d5418ee1d 100644 --- a/translate/src/modules/history/components/HistoryTranslation.tsx +++ b/translate/src/modules/history/components/HistoryTranslation.tsx @@ -2,6 +2,7 @@ import { Localized } from '@fluent/react'; import classNames from 'classnames'; import React, { useCallback, useContext, useState } from 'react'; import ReactTimeAgo from 'react-time-ago'; +import {format} from 'date-fns'; import type { Entity } from '~/api/entity'; import type { ChangeOperation, HistoryTranslation } from '~/api/translation'; @@ -194,9 +195,13 @@ export function HistoryTranslationBase({ setEditorFromHistory(translation.string); }, [isReadOnlyEditor, setEditorFromHistory, translation.string]); + const customDateString = (dateIso: string) => { + return format(new Date(dateIso), "EEEE, MMMM d yyyy 'at' h:mm a"); + }; + const review = { id: 'history-translation--unreviewed', - vars: { user: '', reviewedDate: translation.date }, + vars: { user: '', reviewedDate: customDateString(translation.dateIso) }, attrs: { title: true }, }; if (translation.approved) { From d82c6470a3768384a532f095ad24d377aa5121d6 Mon Sep 17 00:00:00 2001 From: Harmit Goswami Date: Thu, 27 Jun 2024 13:29:20 -0400 Subject: [PATCH 3/5] Formatting fixes --- translate/src/modules/history/components/HistoryTranslation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translate/src/modules/history/components/HistoryTranslation.tsx b/translate/src/modules/history/components/HistoryTranslation.tsx index 2d5418ee1d..02fbd255bf 100644 --- a/translate/src/modules/history/components/HistoryTranslation.tsx +++ b/translate/src/modules/history/components/HistoryTranslation.tsx @@ -2,7 +2,7 @@ import { Localized } from '@fluent/react'; import classNames from 'classnames'; import React, { useCallback, useContext, useState } from 'react'; import ReactTimeAgo from 'react-time-ago'; -import {format} from 'date-fns'; +import { format } from 'date-fns'; import type { Entity } from '~/api/entity'; import type { ChangeOperation, HistoryTranslation } from '~/api/translation'; From ca53d2c2a80569e5ea2b2d9fe596af96cde97590 Mon Sep 17 00:00:00 2001 From: Harmit Goswami Date: Thu, 27 Jun 2024 13:38:48 -0400 Subject: [PATCH 4/5] Added validity check for dateIso string --- .../src/modules/history/components/HistoryTranslation.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/translate/src/modules/history/components/HistoryTranslation.tsx b/translate/src/modules/history/components/HistoryTranslation.tsx index 02fbd255bf..250a469397 100644 --- a/translate/src/modules/history/components/HistoryTranslation.tsx +++ b/translate/src/modules/history/components/HistoryTranslation.tsx @@ -2,7 +2,7 @@ import { Localized } from '@fluent/react'; import classNames from 'classnames'; import React, { useCallback, useContext, useState } from 'react'; import ReactTimeAgo from 'react-time-ago'; -import { format } from 'date-fns'; +import { format, isValid } from 'date-fns'; import type { Entity } from '~/api/entity'; import type { ChangeOperation, HistoryTranslation } from '~/api/translation'; @@ -196,7 +196,11 @@ export function HistoryTranslationBase({ }, [isReadOnlyEditor, setEditorFromHistory, translation.string]); const customDateString = (dateIso: string) => { - return format(new Date(dateIso), "EEEE, MMMM d yyyy 'at' h:mm a"); + const date = new Date(dateIso); + if (!isValid(date)) { + return ' '; + } + return format(date, "EEEE, MMMM d yyyy 'at' h:mm a"); }; const review = { From 233c8cd6f555c9f093518bab6a26d91ac18c6bee Mon Sep 17 00:00:00 2001 From: Harmit Goswami Date: Mon, 1 Jul 2024 13:09:00 -0400 Subject: [PATCH 5/5] Changed datetime printing mechanism --- translate/public/locale/en-US/translate.ftl | 8 ++++---- .../modules/history/components/HistoryTranslation.tsx | 11 +---------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/translate/public/locale/en-US/translate.ftl b/translate/public/locale/en-US/translate.ftl index 27a023558f..8706941039 100644 --- a/translate/public/locale/en-US/translate.ftl +++ b/translate/public/locale/en-US/translate.ftl @@ -369,13 +369,13 @@ history-Translation--span-copied = .title = Copied ({ $machinerySources }) history-translation--approved = - .title = Approved by { $user } on { $reviewedDate } + .title = Approved by { $user } on { DATETIME($reviewedDate, dateStyle:"long", timeStyle:"medium") } history-translation--approved-anonymous = - .title = Approved on { $reviewedDate } + .title = Approved on { DATETIME($reviewedDate, dateStyle:"long", timeStyle:"medium") } history-translation--rejected = - .title = Rejected by { $user } on { $reviewedDate } + .title = Rejected by { $user } on { DATETIME($reviewedDate, dateStyle:"long", timeStyle:"medium") } history-translation--rejected-anonymous = - .title = Rejected on { $reviewedDate } + .title = Rejected on { DATETIME($reviewedDate, dateStyle:"long", timeStyle:"medium") } history-translation--unreviewed = .title = Not reviewed yet diff --git a/translate/src/modules/history/components/HistoryTranslation.tsx b/translate/src/modules/history/components/HistoryTranslation.tsx index 250a469397..69b2757e2c 100644 --- a/translate/src/modules/history/components/HistoryTranslation.tsx +++ b/translate/src/modules/history/components/HistoryTranslation.tsx @@ -2,7 +2,6 @@ import { Localized } from '@fluent/react'; import classNames from 'classnames'; import React, { useCallback, useContext, useState } from 'react'; import ReactTimeAgo from 'react-time-ago'; -import { format, isValid } from 'date-fns'; import type { Entity } from '~/api/entity'; import type { ChangeOperation, HistoryTranslation } from '~/api/translation'; @@ -195,17 +194,9 @@ export function HistoryTranslationBase({ setEditorFromHistory(translation.string); }, [isReadOnlyEditor, setEditorFromHistory, translation.string]); - const customDateString = (dateIso: string) => { - const date = new Date(dateIso); - if (!isValid(date)) { - return ' '; - } - return format(date, "EEEE, MMMM d yyyy 'at' h:mm a"); - }; - const review = { id: 'history-translation--unreviewed', - vars: { user: '', reviewedDate: customDateString(translation.dateIso) }, + vars: { user: '', reviewedDate: new Date(translation.dateIso) }, attrs: { title: true }, }; if (translation.approved) {