From 8b9c3eeefe3f47f9862437c8a825851ccdb99c74 Mon Sep 17 00:00:00 2001 From: CDS Translator Agent Date: Fri, 27 Sep 2024 11:01:04 +0000 Subject: [PATCH 1/9] fix(i18n): add missing translations [CDS 3343] Signed-off-by: CDS Translator Agent From 7a3ae3f32841da0704aa30a732d823fd39711f9b Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Tue, 10 Sep 2024 14:42:27 +0200 Subject: [PATCH 2/9] fix(pci.rancher): fix dash and date ref: TAPC-1615 Signed-off-by: Pierre-Philippe --- .../manager/apps/pci-rancher/package.json | 1 + .../RancherDetail/RancherDetail.component.tsx | 31 +++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/packages/manager/apps/pci-rancher/package.json b/packages/manager/apps/pci-rancher/package.json index 86e74616cf92..bddfc5225105 100644 --- a/packages/manager/apps/pci-rancher/package.json +++ b/packages/manager/apps/pci-rancher/package.json @@ -27,6 +27,7 @@ "@ovh-ux/manager-react-components": "^1.36.0", "@ovh-ux/manager-react-core-application": "^0.10.2", "@ovh-ux/manager-react-shell-client": "^0.7.2", + "@ovh-ux/manager-core-utils": "*", "@ovh-ux/request-tagger": "^0.3.0", "@ovh-ux/shell": "^3.8.0", "@ovhcloud/ods-common-core": "17.2.2", diff --git a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx index 46dbb5fad2ed..28877828551e 100644 --- a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx @@ -1,4 +1,6 @@ import { format } from 'date-fns'; +import * as dateFnsLocales from 'date-fns/locale'; +import { getDateFnsLocale } from '@ovh-ux/manager-core-utils'; import { CommonTitle, @@ -22,7 +24,7 @@ import { OsdsText, OsdsTile, } from '@ovhcloud/ods-components/react'; -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { useHref } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; @@ -120,11 +122,28 @@ const RancherDetail = ({ const onAccessRancherUrl = () => trackAction(TrackingPageView.DetailRancher, TrackingEvent.accessUi); - + const { i18n } = useTranslation('common'); const shouldDisplayUpdateSoftware = getLatestVersionAvailable(rancher, versions) && isReadyStatus && !updateSoftwareResponseType; + const locales = useRef({ ...dateFnsLocales }).current; + const userLocale = getDateFnsLocale(i18n.language); + + const displayDate = useCallback( + (value: string) => { + if (userLocale in locales) { + const localeId = userLocale as keyof typeof locales; + return format(new Date(dateUsage), value, { + locale: locales[localeId], + }); + } + return format(new Date(dateUsage), value, { + locale: locales.fr, + }); + }, + [userLocale, locales], + ); const isEligibleForUpgrade = plan === RancherPlanName.OVHCLOUD_EDITION; @@ -243,14 +262,14 @@ const RancherDetail = ({ - {rancher.currentState.usage?.orchestratedVcpus || '-'} + {rancher.currentState.usage?.orchestratedVcpus} - {dateUsage && ( + {displayDate && (
{t('last_update_date', { - date: format(dateUsage, 'yyyy_MM_dd'), - hour: format(dateUsage, 'HH:mm:ss'), + date: displayDate('PP'), + hour: displayDate('HH:mm:ss'), })}
From a176d3dcc3d7c447923ebb871ce8238eccc88e35 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Tue, 10 Sep 2024 15:29:34 +0200 Subject: [PATCH 3/9] fix(pci.rancher): delete useless translation hook ref: TAPC-1615 Signed-off-by: Pierre-Philippe --- .../Dashboard/RancherDetail/RancherDetail.component.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx index 28877828551e..33ba95bc0296 100644 --- a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx @@ -61,7 +61,11 @@ const RancherDetail = ({ updateOfferErrorMessage, versions, }: RancherDetailProps) => { - const { t } = useTranslation(['dashboard', 'updateSoftware', 'listing']); + const { t, i18n } = useTranslation([ + 'dashboard', + 'updateSoftware', + 'listing', + ]); const trackAction = useTrackingAction(); const hrefEdit = useHref('./edit'); const hrefUpdateSoftware = useHref('./update-software'); @@ -122,7 +126,6 @@ const RancherDetail = ({ const onAccessRancherUrl = () => trackAction(TrackingPageView.DetailRancher, TrackingEvent.accessUi); - const { i18n } = useTranslation('common'); const shouldDisplayUpdateSoftware = getLatestVersionAvailable(rancher, versions) && isReadyStatus && From f0d406cfcddaea45fda138c05278426bb08e546a Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Tue, 10 Sep 2024 15:35:04 +0200 Subject: [PATCH 4/9] fix(pci.rancher): add displaydate dependency ref: TAPC-1615 Signed-off-by: Pierre-Philippe --- .../Dashboard/RancherDetail/RancherDetail.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx index 33ba95bc0296..49f61c75dfbf 100644 --- a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx @@ -145,7 +145,7 @@ const RancherDetail = ({ locale: locales.fr, }); }, - [userLocale, locales], + [userLocale, locales, dateUsage], ); const isEligibleForUpgrade = plan === RancherPlanName.OVHCLOUD_EDITION; From 4d8d3e8547fb0b694c1e1845bbbbaa3f34d9dc7f Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Tue, 10 Sep 2024 15:54:14 +0200 Subject: [PATCH 5/9] fix(pci.rancher): more descriptive on date ref: TAPC-1615 Signed-off-by: Pierre-Philippe --- .../Dashboard/RancherDetail/RancherDetail.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx index 49f61c75dfbf..dfce1ba6fab8 100644 --- a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx @@ -271,7 +271,7 @@ const RancherDetail = ({
{t('last_update_date', { - date: displayDate('PP'), + date: displayDate('PPPP'), hour: displayDate('HH:mm:ss'), })} From 41d69fa91c4117ca8fe4a502010a456b1406d099 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Prevost Date: Wed, 18 Sep 2024 10:02:40 +0200 Subject: [PATCH 6/9] fix(pci.rancher): pr review ref: TAPC-1615 Signed-off-by: Pierre-Philippe --- .../RancherDetail/RancherDetail.component.tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx index dfce1ba6fab8..614976733b1f 100644 --- a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx @@ -134,17 +134,13 @@ const RancherDetail = ({ const userLocale = getDateFnsLocale(i18n.language); const displayDate = useCallback( - (value: string) => { - if (userLocale in locales) { - const localeId = userLocale as keyof typeof locales; - return format(new Date(dateUsage), value, { - locale: locales[localeId], - }); - } - return format(new Date(dateUsage), value, { - locale: locales.fr, - }); - }, + (value: string) => + format(new Date(dateUsage), value, { + locale: + userLocale in locales + ? locales[userLocale as keyof typeof locales] + : locales.fr, + }), [userLocale, locales, dateUsage], ); From 92be18cca2c3cf87e1567a977a7b3c3495808fcf Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Tue, 24 Sep 2024 17:51:51 +0200 Subject: [PATCH 7/9] fix(pci.rancher): add component and add to list the 0 if no vCPUs ref: TAPC-1615 Signed-off-by: Pierre-Philippe --- .../Table/NumberCell/NumberCell.component.tsx | 17 +++++++++++++++++ .../TableContainer/TableContainer.component.tsx | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 packages/manager/apps/pci-rancher/src/components/Table/NumberCell/NumberCell.component.tsx diff --git a/packages/manager/apps/pci-rancher/src/components/Table/NumberCell/NumberCell.component.tsx b/packages/manager/apps/pci-rancher/src/components/Table/NumberCell/NumberCell.component.tsx new file mode 100644 index 000000000000..102f7746414c --- /dev/null +++ b/packages/manager/apps/pci-rancher/src/components/Table/NumberCell/NumberCell.component.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; +import { OsdsText } from '@ovhcloud/ods-components/react'; +import { Cell } from '@tanstack/react-table'; +import { RancherService } from '@/types/api.type'; +import '../Table.scss'; + +interface DisplayCellInterface { + cell: Cell; +} + +function DisplayCellNumber({ cell }: Readonly) { + const number = cell.renderValue() as number; + return {number}; +} + +export default DisplayCellNumber; diff --git a/packages/manager/apps/pci-rancher/src/components/Table/TableContainer/TableContainer.component.tsx b/packages/manager/apps/pci-rancher/src/components/Table/TableContainer/TableContainer.component.tsx index 0d4f7aaf6546..f10a8bbfa256 100644 --- a/packages/manager/apps/pci-rancher/src/components/Table/TableContainer/TableContainer.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/Table/TableContainer/TableContainer.component.tsx @@ -22,6 +22,7 @@ import DisplayCellText from '../TextCell/TextCell.component'; import '../Table.scss'; import { deleteRancherServiceQueryKey } from '@/data/api/services'; import StatusChip from '../../StatusChip/StatusChip.component'; +import DisplayCellNumber from '../NumberCell/NumberCell.component'; export default function TableContainer({ data, @@ -71,7 +72,7 @@ export default function TableContainer({ id: 'numberOfCpu', header: t('numberOfCpu'), accessorFn: (row) => row.currentState.usage?.orchestratedVcpus, - cell: DisplayCellText, + cell: DisplayCellNumber, }, { id: 'status', From 844dba074cb468f70017fa619269e8edf26c612c Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Tue, 24 Sep 2024 17:59:25 +0200 Subject: [PATCH 8/9] fix(pci.rancher): update ts ref: TAPC-1615 Signed-off-by: Pierre-Philippe --- .../src/components/Table/NumberCell/NumberCell.component.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/manager/apps/pci-rancher/src/components/Table/NumberCell/NumberCell.component.tsx b/packages/manager/apps/pci-rancher/src/components/Table/NumberCell/NumberCell.component.tsx index 102f7746414c..c627d6512725 100644 --- a/packages/manager/apps/pci-rancher/src/components/Table/NumberCell/NumberCell.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/Table/NumberCell/NumberCell.component.tsx @@ -6,11 +6,11 @@ import { RancherService } from '@/types/api.type'; import '../Table.scss'; interface DisplayCellInterface { - cell: Cell; + cell: Cell; } function DisplayCellNumber({ cell }: Readonly) { - const number = cell.renderValue() as number; + const number = cell.renderValue(); return {number}; } From a4d8cd55cb5c151d0f8bb6e2ae6a795f4f0f8344 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Wed, 2 Oct 2024 11:06:20 +0200 Subject: [PATCH 9/9] fix(pci.rancher): delete useless useref ref: TAPC-1615 Signed-off-by: Pierre-Philippe --- .../Dashboard/RancherDetail/RancherDetail.component.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx index 614976733b1f..7c4efcbf8077 100644 --- a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx +++ b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.component.tsx @@ -1,5 +1,5 @@ import { format } from 'date-fns'; -import * as dateFnsLocales from 'date-fns/locale'; +import * as locales from 'date-fns/locale'; import { getDateFnsLocale } from '@ovh-ux/manager-core-utils'; import { @@ -24,7 +24,7 @@ import { OsdsText, OsdsTile, } from '@ovhcloud/ods-components/react'; -import React, { useCallback, useEffect, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { useHref } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; @@ -130,7 +130,7 @@ const RancherDetail = ({ getLatestVersionAvailable(rancher, versions) && isReadyStatus && !updateSoftwareResponseType; - const locales = useRef({ ...dateFnsLocales }).current; + const userLocale = getDateFnsLocale(i18n.language); const displayDate = useCallback(