From dde40c843ac007916f1ac11a37b26ac008fed4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vilcot?= Date: Tue, 31 Dec 2024 09:47:39 +0100 Subject: [PATCH 01/10] ci: build and run tests only on pci-common MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Frédéric Vilcot --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index edd1fa90857c..e96f802f0ea7 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "scripts": { "build": "yarn run build:turbo", - "build:turbo": "turbo run build --concurrency=5", + "build:turbo": "turbo run build --concurrency=5 --filter=\"@ovh-ux/manager-pci-common\"", "dev": "turbo run dev", "clean": "lerna clean -y && yarn run clean:dist && rimraf node_modules", "clean:dist": "rimraf \"packages/**/dist\"", @@ -51,7 +51,7 @@ "start": "node -r esm scripts/start-application.js", "test:jest": "jest --runInBand", "test": "yarn lint", - "test:turbo": "turbo run test --concurrency=1", + "test:turbo": "turbo run test --concurrency=1 --filter=\"@ovh-ux/manager-pci-common\"", "test:scripts": "make test", "test:playwright:run": "lerna run test:e2e:ci --stream --concurrency=1 --no-bail" }, From 516a71ed8cce35876c441f105e2f2e2d68bf4fb7 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Mon, 30 Dec 2024 15:04:48 +0100 Subject: [PATCH 02/10] feat(pci-common): add pci saving plan banner Signed-off-by: Pierre-Philippe --- .../PciSavingPlanBanner.spec.tsx | 46 +++++++++++++++++++ .../PciSavingPlanBanner.tsx | 32 +++++++++++++ .../saving-plan-banner/Messages_fr_FR.json | 5 ++ .../translations/saving-plan-banner/index.ts | 27 +++++++++++ 4 files changed, 110 insertions(+) create mode 100644 packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx create mode 100644 packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx create mode 100644 packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_FR.json create mode 100644 packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/index.ts diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx new file mode 100644 index 000000000000..2749b7e0dd68 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx @@ -0,0 +1,46 @@ +import '@testing-library/jest-dom'; +import { render, screen, fireEvent } from '@testing-library/react'; +import { describe, it, Mock, vi } from 'vitest'; +import { useNavigation } from '@ovh-ux/manager-react-shell-client'; +import PciSavingPlanBanner from './PciSavingPlanBanner'; + +const mockNavigateTo = vi.fn(); +vi.mock('@ovh-ux/manager-react-shell-client', () => ({ + useNavigation: () => ({ + navigateTo: mockNavigateTo, + }), +})); + +describe('PciSavingPlanBanner tests', () => { + it('should render the banner with the correct message and CTA', () => { + const { container } = render( + , + ); + + expect( + screen.getByText('pci_projects_project_activate_project_banner_message'), + ).toBeInTheDocument(); + + expect( + screen.getByText('pci_projects_project_activate_project_banner_cta'), + ).toBeInTheDocument(); + + expect(container.querySelector('.test-class')).toBeInTheDocument(); + }); + + it('should call navigateToSavingsPlan on CTA click', async () => { + render(); + + const ctaButton = screen.getByText( + 'pci_projects_project_activate_project_banner_cta', + ); + + fireEvent.click(ctaButton); + + expect(mockNavigateTo).toHaveBeenCalledWith( + 'public-cloud', + `#/pci/projects/mockProjectUrl/savings-plan`, + {}, + ); + }); +}); diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx new file mode 100644 index 000000000000..9dda6be7a52b --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx @@ -0,0 +1,32 @@ +import { ActionBanner, useProjectUrl } from '@ovh-ux/manager-react-components'; +import { useNavigation } from '@ovh-ux/manager-react-shell-client'; +import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components'; +import { useTranslation } from 'react-i18next'; + +const PciSavingPlanBanner = ({ className }: { className: string }) => { + const { t } = useTranslation(); + + const projectURL = useProjectUrl('public-cloud'); + + const { navigateTo } = useNavigation(); + + const navigateToSavingsPlan = async () => { + await navigateTo( + 'public-cloud', + `#/pci/projects/${projectURL}/savings-plan`, + {}, + ); + }; + + return ( + + ); +}; + +export default PciSavingPlanBanner; diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_FR.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_FR.json new file mode 100644 index 000000000000..c2e9f4d9d347 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_FR.json @@ -0,0 +1,5 @@ +{ + "pci_projects_trusted_zone_banner_info": "Le prix affiché correspond au prix du service. La majoration liée à la zone de confiance est ajoutée à la facturation mensuelle globale.", + "pci_projects_savings_plan_banner": "Bénéficiez de tarifs mensuels avantageux grâce aux Savings Plans, tout en gardant la flexibilité des instances à l'heure.", + "pci_projects_savings_plan_cta": "Configurez vos Savings Plans" +} diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/index.ts b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/index.ts new file mode 100644 index 000000000000..dc5e760f4ba1 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/index.ts @@ -0,0 +1,27 @@ +import i18next from 'i18next'; + +import de_DE from './Messages_de_DE.json'; +import en_GB from './Messages_en_GB.json'; +import es_ES from './Messages_es_ES.json'; +import fr_CA from './Messages_fr_CA.json'; +import fr_FR from './Messages_fr_FR.json'; +import it_IT from './Messages_it_IT.json'; +import pl_PL from './Messages_pl_PL.json'; +import pt_PT from './Messages_pt_PT.json'; + +function addTranslations() { + i18next.addResources('de_DE', 'saving-plan-banner', de_DE); + i18next.addResources('en_GB', 'saving-plan-banner', en_GB); + i18next.addResources('es_ES', 'saving-plan-banner', es_ES); + i18next.addResources('fr_CA', 'saving-plan-banner', fr_CA); + i18next.addResources('fr_FR', 'saving-plan-banner', fr_FR); + i18next.addResources('it_IT', 'saving-plan-banner', it_IT); + i18next.addResources('pl_PL', 'saving-plan-banner', pl_PL); + i18next.addResources('pt_PT', 'saving-plan-banner', pt_PT); +} + +if (i18next.isInitialized) { + addTranslations(); +} else { + i18next.on('initialized', addTranslations); +} From cc1403eaa3923e6445fd46b70f9d7b8efee12058 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Mon, 30 Dec 2024 15:38:17 +0100 Subject: [PATCH 03/10] feat(pci-common): fix translation Signed-off-by: Pierre-Philippe --- .../banner/saving-plan-banner/PciSavingPlanBanner.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx index 9dda6be7a52b..dccaf2124e83 100644 --- a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx +++ b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx @@ -4,7 +4,7 @@ import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components'; import { useTranslation } from 'react-i18next'; const PciSavingPlanBanner = ({ className }: { className: string }) => { - const { t } = useTranslation(); + const { t } = useTranslation('saving-plan-banner'); const projectURL = useProjectUrl('public-cloud'); @@ -20,9 +20,9 @@ const PciSavingPlanBanner = ({ className }: { className: string }) => { return ( From aa88f33ebe284bfb682c3111b2c9d8bf90bd2260 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Mon, 30 Dec 2024 15:47:14 +0100 Subject: [PATCH 04/10] feat(pci-common): fix translation Signed-off-by: Pierre-Philippe --- .../banner/saving-plan-banner/PciSavingPlanBanner.tsx | 4 ++-- .../src/translations/saving-plan-banner/Messages_fr_FR.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx index dccaf2124e83..b22d0535513a 100644 --- a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx +++ b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx @@ -20,8 +20,8 @@ const PciSavingPlanBanner = ({ className }: { className: string }) => { return ( Date: Mon, 30 Dec 2024 16:01:41 +0100 Subject: [PATCH 05/10] feat(pci-common): fix tests Signed-off-by: Pierre-Philippe --- .../saving-plan-banner/PciSavingPlanBanner.spec.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx index 2749b7e0dd68..d5a9d9d5a1cb 100644 --- a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx +++ b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx @@ -18,11 +18,11 @@ describe('PciSavingPlanBanner tests', () => { ); expect( - screen.getByText('pci_projects_project_activate_project_banner_message'), + screen.getByText('pci_projects_savings_plan_banner'), ).toBeInTheDocument(); expect( - screen.getByText('pci_projects_project_activate_project_banner_cta'), + screen.getByText('pci_projects_savings_plan_cta'), ).toBeInTheDocument(); expect(container.querySelector('.test-class')).toBeInTheDocument(); @@ -31,9 +31,7 @@ describe('PciSavingPlanBanner tests', () => { it('should call navigateToSavingsPlan on CTA click', async () => { render(); - const ctaButton = screen.getByText( - 'pci_projects_project_activate_project_banner_cta', - ); + const ctaButton = screen.getByText('pci_projects_savings_plan_cta'); fireEvent.click(ctaButton); From 130a139b0823b4c6e9e7289511db2a75a9a9580d Mon Sep 17 00:00:00 2001 From: CDS Translator Agent Date: Mon, 30 Dec 2024 15:26:38 +0000 Subject: [PATCH 06/10] fix(i18n): add missing translations [CDS 171] Signed-off-by: CDS Translator Agent --- .../src/translations/saving-plan-banner/Messages_de_DE.json | 4 ++++ .../src/translations/saving-plan-banner/Messages_en_GB.json | 4 ++++ .../src/translations/saving-plan-banner/Messages_es_ES.json | 4 ++++ .../src/translations/saving-plan-banner/Messages_fr_CA.json | 4 ++++ .../src/translations/saving-plan-banner/Messages_it_IT.json | 4 ++++ .../src/translations/saving-plan-banner/Messages_pl_PL.json | 4 ++++ .../src/translations/saving-plan-banner/Messages_pt_PT.json | 4 ++++ 7 files changed, 28 insertions(+) create mode 100644 packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json create mode 100644 packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json create mode 100644 packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json create mode 100644 packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_CA.json create mode 100644 packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json create mode 100644 packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json create mode 100644 packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json new file mode 100644 index 000000000000..6da5a95ce1b2 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json @@ -0,0 +1,4 @@ +{ + "pci_projects_savings_plan_banner": "Profitieren Sie von günstigen monatlichen Preisen mit den Savings Plans und behalten Sie die Flexibilität der Instanzen auf Stundenbasis bei.", + "pci_projects_savings_plan_cta": "Konfigurieren Sie Ihre Savings-Pläne" +} diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json new file mode 100644 index 000000000000..43cb2c924ecf --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json @@ -0,0 +1,4 @@ +{ + "pci_projects_savings_plan_banner": "Get low monthly rates with Savings Plans, while keeping the flexibility of instances on time.", + "pci_projects_savings_plan_cta": "Configure your Savings Plans" +} diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json new file mode 100644 index 000000000000..cddb9a2dbac3 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json @@ -0,0 +1,4 @@ +{ + "pci_projects_savings_plan_banner": "Disfrute de tarifas mensuales más bajas gracias a los Savings Plans, conservando la flexibilidad de las instancias por horas.", + "pci_projects_savings_plan_cta": "Configure sus planes de ahorro" +} diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_CA.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_CA.json new file mode 100644 index 000000000000..9255adbec625 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_CA.json @@ -0,0 +1,4 @@ +{ + "pci_projects_savings_plan_banner": "Bénéficiez de tarifs mensuels avantageux grâce aux Savings Plans, tout en gardant la flexibilité des instances à l'heure.", + "pci_projects_savings_plan_cta": "Configurez vos Savings Plans" +} diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json new file mode 100644 index 000000000000..a76b066fa5f9 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json @@ -0,0 +1,4 @@ +{ + "pci_projects_savings_plan_banner": "Usufruisci di tariffe mensili vantaggiose grazie ai Savings Plans, mantenendo la flessibilità delle istanze su base oraria.", + "pci_projects_savings_plan_cta": "Configura i tuoi Savings Plan" +} diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json new file mode 100644 index 000000000000..f557aa9a5ae3 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json @@ -0,0 +1,4 @@ +{ + "pci_projects_savings_plan_banner": "Korzystaj z atrakcyjnych cen miesięcznych dzięki Savings Plan, zachowując jednocześnie elastyczność instancji na godzinę.", + "pci_projects_savings_plan_cta": "Skonfiguruj swoje plany Savings" +} diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json new file mode 100644 index 000000000000..e14f11209440 --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json @@ -0,0 +1,4 @@ +{ + "pci_projects_savings_plan_banner": "Beneficie de preços mensais vantajosos graças aos Savings Plans, mantendo a flexibilidade das instâncias à hora.", + "pci_projects_savings_plan_cta": "Configure os seus Savings Plans" +} From 1c4fefdcc28366f07edf0fc95f5e4c0d2503721d Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Mon, 30 Dec 2024 16:43:24 +0100 Subject: [PATCH 07/10] feat(pci-common): add translation and context shell Signed-off-by: Pierre-Philippe --- .../saving-plan-banner/PciSavingPlanBanner.tsx | 14 +++++++------- .../saving-plan-banner/Messages_de_DE.json | 2 +- .../saving-plan-banner/Messages_en_GB.json | 4 ++-- .../saving-plan-banner/Messages_es_ES.json | 4 ++-- .../saving-plan-banner/Messages_it_IT.json | 2 +- .../saving-plan-banner/Messages_pl_PL.json | 2 +- .../saving-plan-banner/Messages_pt_PT.json | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx index b22d0535513a..1d589d5ecb1e 100644 --- a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx +++ b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx @@ -1,15 +1,15 @@ import { ActionBanner, useProjectUrl } from '@ovh-ux/manager-react-components'; -import { useNavigation } from '@ovh-ux/manager-react-shell-client'; +import { ShellContext } from '@ovh-ux/manager-react-shell-client'; +import { useContext } from 'react'; import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components'; import { useTranslation } from 'react-i18next'; -const PciSavingPlanBanner = ({ className }: { className: string }) => { +const PciSavingsPlanBanner = ({ className }: { className: string }) => { const { t } = useTranslation('saving-plan-banner'); - const projectURL = useProjectUrl('public-cloud'); - - const { navigateTo } = useNavigation(); - + const { + navigation: { navigateTo }, + } = useContext(ShellContext).shell; const navigateToSavingsPlan = async () => { await navigateTo( 'public-cloud', @@ -29,4 +29,4 @@ const PciSavingPlanBanner = ({ className }: { className: string }) => { ); }; -export default PciSavingPlanBanner; +export default PciSavingsPlanBanner; diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json index 6da5a95ce1b2..9967c4116313 100644 --- a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json @@ -1,4 +1,4 @@ { "pci_projects_savings_plan_banner": "Profitieren Sie von günstigen monatlichen Preisen mit den Savings Plans und behalten Sie die Flexibilität der Instanzen auf Stundenbasis bei.", - "pci_projects_savings_plan_cta": "Konfigurieren Sie Ihre Savings-Pläne" + "pci_projects_savings_plan_cta": "Ihre Savings Plans konfigurieren" } diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json index 43cb2c924ecf..23f163aefd93 100644 --- a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json @@ -1,4 +1,4 @@ { - "pci_projects_savings_plan_banner": "Get low monthly rates with Savings Plans, while keeping the flexibility of instances on time.", - "pci_projects_savings_plan_cta": "Configure your Savings Plans" + "pci_projects_savings_plan_banner": "Take advantage of low monthly rates with Savings Plans — save money without sacrificing the flexibility to use instances whenever you need them.", + "pci_projects_savings_plan_cta": "Set up your Savings Plans" } diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json index cddb9a2dbac3..b354ff2537ee 100644 --- a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json @@ -1,4 +1,4 @@ { - "pci_projects_savings_plan_banner": "Disfrute de tarifas mensuales más bajas gracias a los Savings Plans, conservando la flexibilidad de las instancias por horas.", - "pci_projects_savings_plan_cta": "Configure sus planes de ahorro" + "pci_projects_savings_plan_banner": "Disfrute de tarifas mensuales más económicas gracias a los Savings Plans, manteniendo la flexibilidad de las instancias por horas.", + "pci_projects_savings_plan_cta": "Configure sus Savings Plans" } diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json index a76b066fa5f9..1a1bc8f59fbe 100644 --- a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json @@ -1,4 +1,4 @@ { - "pci_projects_savings_plan_banner": "Usufruisci di tariffe mensili vantaggiose grazie ai Savings Plans, mantenendo la flessibilità delle istanze su base oraria.", + "pci_projects_savings_plan_banner": "Usufruisci di tariffe mensili vantaggiose grazie ai Savings Plan, conservando la flessibilità delle istanze all’ora.", "pci_projects_savings_plan_cta": "Configura i tuoi Savings Plan" } diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json index f557aa9a5ae3..ecfc5053421a 100644 --- a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json @@ -1,4 +1,4 @@ { - "pci_projects_savings_plan_banner": "Korzystaj z atrakcyjnych cen miesięcznych dzięki Savings Plan, zachowując jednocześnie elastyczność instancji na godzinę.", + "pci_projects_savings_plan_banner": "Dzięki Savings Plan zyskujesz korzystne opłaty miesięczne, a jednocześnie zachowujesz możliwość płatności za instancje w trybie za godzinę.", "pci_projects_savings_plan_cta": "Skonfiguruj swoje plany Savings" } diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json index e14f11209440..07cf1fa5bbf7 100644 --- a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json +++ b/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json @@ -1,4 +1,4 @@ { - "pci_projects_savings_plan_banner": "Beneficie de preços mensais vantajosos graças aos Savings Plans, mantendo a flexibilidade das instâncias à hora.", + "pci_projects_savings_plan_banner": "Graças aos Savings Plans, beneficie de preços mensais vantajosos, enquanto conserva a flexibilidade das instâncias à hora.", "pci_projects_savings_plan_cta": "Configure os seus Savings Plans" } From d4e28fefffa196aeac34f373164f1b5fa5a64e59 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Mon, 30 Dec 2024 16:51:50 +0100 Subject: [PATCH 08/10] feat(pci-common): rename savings plan Signed-off-by: Pierre-Philippe --- .../PciSavingPlanBanner.spec.tsx | 44 ------------------- .../PciSavingPlanBanner.tsx | 32 -------------- 2 files changed, 76 deletions(-) delete mode 100644 packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx delete mode 100644 packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx deleted file mode 100644 index d5a9d9d5a1cb..000000000000 --- a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.spec.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import '@testing-library/jest-dom'; -import { render, screen, fireEvent } from '@testing-library/react'; -import { describe, it, Mock, vi } from 'vitest'; -import { useNavigation } from '@ovh-ux/manager-react-shell-client'; -import PciSavingPlanBanner from './PciSavingPlanBanner'; - -const mockNavigateTo = vi.fn(); -vi.mock('@ovh-ux/manager-react-shell-client', () => ({ - useNavigation: () => ({ - navigateTo: mockNavigateTo, - }), -})); - -describe('PciSavingPlanBanner tests', () => { - it('should render the banner with the correct message and CTA', () => { - const { container } = render( - , - ); - - expect( - screen.getByText('pci_projects_savings_plan_banner'), - ).toBeInTheDocument(); - - expect( - screen.getByText('pci_projects_savings_plan_cta'), - ).toBeInTheDocument(); - - expect(container.querySelector('.test-class')).toBeInTheDocument(); - }); - - it('should call navigateToSavingsPlan on CTA click', async () => { - render(); - - const ctaButton = screen.getByText('pci_projects_savings_plan_cta'); - - fireEvent.click(ctaButton); - - expect(mockNavigateTo).toHaveBeenCalledWith( - 'public-cloud', - `#/pci/projects/mockProjectUrl/savings-plan`, - {}, - ); - }); -}); diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx deleted file mode 100644 index 1d589d5ecb1e..000000000000 --- a/packages/manager/modules/manager-pci-common/src/components/banner/saving-plan-banner/PciSavingPlanBanner.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { ActionBanner, useProjectUrl } from '@ovh-ux/manager-react-components'; -import { ShellContext } from '@ovh-ux/manager-react-shell-client'; -import { useContext } from 'react'; -import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components'; -import { useTranslation } from 'react-i18next'; - -const PciSavingsPlanBanner = ({ className }: { className: string }) => { - const { t } = useTranslation('saving-plan-banner'); - const projectURL = useProjectUrl('public-cloud'); - const { - navigation: { navigateTo }, - } = useContext(ShellContext).shell; - const navigateToSavingsPlan = async () => { - await navigateTo( - 'public-cloud', - `#/pci/projects/${projectURL}/savings-plan`, - {}, - ); - }; - - return ( - - ); -}; - -export default PciSavingsPlanBanner; From 27a5a5e0ee2d4195d134896ee3340e193aa64774 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Mon, 30 Dec 2024 16:56:41 +0100 Subject: [PATCH 09/10] feat(pci-common): lint Signed-off-by: Pierre-Philippe --- .../PciSavingsPlanBanner.spec.tsx | 43 +++++++++++++++++++ .../PciSavingsPlanBanner.tsx | 32 ++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.spec.tsx create mode 100644 packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.tsx diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.spec.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.spec.tsx new file mode 100644 index 000000000000..53ef0340fc8c --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.spec.tsx @@ -0,0 +1,43 @@ +import '@testing-library/jest-dom'; +import { render, screen, fireEvent } from '@testing-library/react'; +import { describe, it, vi } from 'vitest'; +import PciSavingPlanBanner from './PciSavingsPlanBanner'; + +const mockNavigateTo = vi.fn(); +vi.mock('@ovh-ux/manager-react-shell-client', () => ({ + useNavigation: () => ({ + navigateTo: mockNavigateTo, + }), +})); + +describe('PciSavingPlanBanner tests', () => { + it('should render the banner with the correct message and CTA', () => { + const { container } = render( + , + ); + + expect( + screen.getByText('pci_projects_savings_plan_banner'), + ).toBeInTheDocument(); + + expect( + screen.getByText('pci_projects_savings_plan_cta'), + ).toBeInTheDocument(); + + expect(container.querySelector('.test-class')).toBeInTheDocument(); + }); + + it('should call navigateToSavingsPlan on CTA click', async () => { + render(); + + const ctaButton = screen.getByText('pci_projects_savings_plan_cta'); + + fireEvent.click(ctaButton); + + expect(mockNavigateTo).toHaveBeenCalledWith( + 'public-cloud', + `#/pci/projects/mockProjectUrl/savings-plan`, + {}, + ); + }); +}); diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.tsx new file mode 100644 index 000000000000..1d589d5ecb1e --- /dev/null +++ b/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.tsx @@ -0,0 +1,32 @@ +import { ActionBanner, useProjectUrl } from '@ovh-ux/manager-react-components'; +import { ShellContext } from '@ovh-ux/manager-react-shell-client'; +import { useContext } from 'react'; +import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components'; +import { useTranslation } from 'react-i18next'; + +const PciSavingsPlanBanner = ({ className }: { className: string }) => { + const { t } = useTranslation('saving-plan-banner'); + const projectURL = useProjectUrl('public-cloud'); + const { + navigation: { navigateTo }, + } = useContext(ShellContext).shell; + const navigateToSavingsPlan = async () => { + await navigateTo( + 'public-cloud', + `#/pci/projects/${projectURL}/savings-plan`, + {}, + ); + }; + + return ( + + ); +}; + +export default PciSavingsPlanBanner; From 24fa9dd79532632d1369808848adc771b63345e9 Mon Sep 17 00:00:00 2001 From: Pierre-Philippe Date: Mon, 30 Dec 2024 17:40:26 +0100 Subject: [PATCH 10/10] feat(pci-common): lint test and fix Signed-off-by: Pierre-Philippe --- .../discovery-banner/PciDiscoveryBanner.tsx | 1 - .../PciSavingsPlanBanner.spec.tsx | 27 ++++++++++++++----- .../PciSavingsPlanBanner.tsx | 2 +- .../Messages_de_DE.json | 0 .../Messages_en_GB.json | 0 .../Messages_es_ES.json | 0 .../Messages_fr_CA.json | 0 .../Messages_fr_FR.json | 0 .../Messages_it_IT.json | 0 .../Messages_pl_PL.json | 0 .../Messages_pt_PT.json | 0 .../index.ts | 16 +++++------ 12 files changed, 30 insertions(+), 16 deletions(-) rename packages/manager/modules/manager-pci-common/src/translations/{saving-plan-banner => savings-plan-banner}/Messages_de_DE.json (100%) rename packages/manager/modules/manager-pci-common/src/translations/{saving-plan-banner => savings-plan-banner}/Messages_en_GB.json (100%) rename packages/manager/modules/manager-pci-common/src/translations/{saving-plan-banner => savings-plan-banner}/Messages_es_ES.json (100%) rename packages/manager/modules/manager-pci-common/src/translations/{saving-plan-banner => savings-plan-banner}/Messages_fr_CA.json (100%) rename packages/manager/modules/manager-pci-common/src/translations/{saving-plan-banner => savings-plan-banner}/Messages_fr_FR.json (100%) rename packages/manager/modules/manager-pci-common/src/translations/{saving-plan-banner => savings-plan-banner}/Messages_it_IT.json (100%) rename packages/manager/modules/manager-pci-common/src/translations/{saving-plan-banner => savings-plan-banner}/Messages_pl_PL.json (100%) rename packages/manager/modules/manager-pci-common/src/translations/{saving-plan-banner => savings-plan-banner}/Messages_pt_PT.json (100%) rename packages/manager/modules/manager-pci-common/src/translations/{saving-plan-banner => savings-plan-banner}/index.ts (50%) diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/discovery-banner/PciDiscoveryBanner.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/discovery-banner/PciDiscoveryBanner.tsx index 6ac4920e6033..07debede999c 100644 --- a/packages/manager/modules/manager-pci-common/src/components/banner/discovery-banner/PciDiscoveryBanner.tsx +++ b/packages/manager/modules/manager-pci-common/src/components/banner/discovery-banner/PciDiscoveryBanner.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigation } from '@ovh-ux/manager-react-shell-client'; import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components'; diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.spec.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.spec.tsx index 53ef0340fc8c..f51288594d2d 100644 --- a/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.spec.tsx +++ b/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.spec.tsx @@ -1,19 +1,28 @@ import '@testing-library/jest-dom'; import { render, screen, fireEvent } from '@testing-library/react'; +import { + ShellContext, + ShellContextType, +} from '@ovh-ux/manager-react-shell-client'; import { describe, it, vi } from 'vitest'; import PciSavingPlanBanner from './PciSavingsPlanBanner'; +import { wrapper } from '@/wrapperRenders'; const mockNavigateTo = vi.fn(); -vi.mock('@ovh-ux/manager-react-shell-client', () => ({ - useNavigation: () => ({ - navigateTo: mockNavigateTo, - }), -})); + +const mockShellContext = { + shell: { + navigation: { + navigateTo: mockNavigateTo, + }, + }, +}; describe('PciSavingPlanBanner tests', () => { it('should render the banner with the correct message and CTA', () => { const { container } = render( , + { wrapper }, ); expect( @@ -28,7 +37,13 @@ describe('PciSavingPlanBanner tests', () => { }); it('should call navigateToSavingsPlan on CTA click', async () => { - render(); + render( + + + , + ); const ctaButton = screen.getByText('pci_projects_savings_plan_cta'); diff --git a/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.tsx b/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.tsx index 1d589d5ecb1e..aa318bf2a260 100644 --- a/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.tsx +++ b/packages/manager/modules/manager-pci-common/src/components/banner/savings-plan-banner/PciSavingsPlanBanner.tsx @@ -5,7 +5,7 @@ import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components'; import { useTranslation } from 'react-i18next'; const PciSavingsPlanBanner = ({ className }: { className: string }) => { - const { t } = useTranslation('saving-plan-banner'); + const { t } = useTranslation('savings-plan-banner'); const projectURL = useProjectUrl('public-cloud'); const { navigation: { navigateTo }, diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_de_DE.json similarity index 100% rename from packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_de_DE.json rename to packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_de_DE.json diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_en_GB.json similarity index 100% rename from packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_en_GB.json rename to packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_en_GB.json diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_es_ES.json similarity index 100% rename from packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_es_ES.json rename to packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_es_ES.json diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_CA.json b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_fr_CA.json similarity index 100% rename from packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_CA.json rename to packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_fr_CA.json diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_FR.json b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_fr_FR.json similarity index 100% rename from packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_fr_FR.json rename to packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_fr_FR.json diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_it_IT.json similarity index 100% rename from packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_it_IT.json rename to packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_it_IT.json diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_pl_PL.json similarity index 100% rename from packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pl_PL.json rename to packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_pl_PL.json diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_pt_PT.json similarity index 100% rename from packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/Messages_pt_PT.json rename to packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/Messages_pt_PT.json diff --git a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/index.ts b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/index.ts similarity index 50% rename from packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/index.ts rename to packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/index.ts index dc5e760f4ba1..6a1b4f8c0d95 100644 --- a/packages/manager/modules/manager-pci-common/src/translations/saving-plan-banner/index.ts +++ b/packages/manager/modules/manager-pci-common/src/translations/savings-plan-banner/index.ts @@ -10,14 +10,14 @@ import pl_PL from './Messages_pl_PL.json'; import pt_PT from './Messages_pt_PT.json'; function addTranslations() { - i18next.addResources('de_DE', 'saving-plan-banner', de_DE); - i18next.addResources('en_GB', 'saving-plan-banner', en_GB); - i18next.addResources('es_ES', 'saving-plan-banner', es_ES); - i18next.addResources('fr_CA', 'saving-plan-banner', fr_CA); - i18next.addResources('fr_FR', 'saving-plan-banner', fr_FR); - i18next.addResources('it_IT', 'saving-plan-banner', it_IT); - i18next.addResources('pl_PL', 'saving-plan-banner', pl_PL); - i18next.addResources('pt_PT', 'saving-plan-banner', pt_PT); + i18next.addResources('de_DE', 'savings-plan-banner', de_DE); + i18next.addResources('en_GB', 'savings-plan-banner', en_GB); + i18next.addResources('es_ES', 'savings-plan-banner', es_ES); + i18next.addResources('fr_CA', 'savings-plan-banner', fr_CA); + i18next.addResources('fr_FR', 'savings-plan-banner', fr_FR); + i18next.addResources('it_IT', 'savings-plan-banner', it_IT); + i18next.addResources('pl_PL', 'savings-plan-banner', pl_PL); + i18next.addResources('pt_PT', 'savings-plan-banner', pt_PT); } if (i18next.isInitialized) {