From 0bce7b020c945de850e7ef53c1554948f46403e9 Mon Sep 17 00:00:00 2001 From: Eric Ciccotti Date: Fri, 20 Sep 2024 15:00:24 +0200 Subject: [PATCH] feat(pci-rancher): add upgrade tile ref: TAPC-644 Signed-off-by: Eric Ciccotti --- .../dashboard/Messages_fr_FR.json | 5 +++- .../RancherDetail/RancherDetail.component.tsx | 25 +++++++++++++++++++ .../RancherDetail/RancherDetail.test.tsx | 22 +++++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/packages/manager/apps/pci-rancher/public/translations/dashboard/Messages_fr_FR.json b/packages/manager/apps/pci-rancher/public/translations/dashboard/Messages_fr_FR.json index 62c40c4cb7cd..13674b77d541 100644 --- a/packages/manager/apps/pci-rancher/public/translations/dashboard/Messages_fr_FR.json +++ b/packages/manager/apps/pci-rancher/public/translations/dashboard/Messages_fr_FR.json @@ -47,5 +47,8 @@ "updateOfferModaleTitle": "Changer d'offre", "updateOfferModalDescription": "Vous êtes sur le point de modifier votre offre actuelle pour l'offre {{availableServicePlan}}. Vous serez facturé {{planPricing}} HT / heure par vCPUs orchestrés. Cette opération prendra effet immédiatement et n'a pas d'impact sur vos « downstream clusters » ni les données de votre Rancher managé. Veuillez confirmer si vous souhaitez continuer.", "updateOfferPending": "Votre changement d’offre a bien été pris en compte. Merci de patienter, cela peut prendre quelques minutes", - "updateOfferError": "Une erreur s'est produite : {{errorMessage}}" + "updateOfferError": "Une erreur s'est produite : {{errorMessage}}", + "upgradePlanTitle": "Passez à l’offre Standard", + "upgradePlanDescription": "Créez ou enregistrez des « downstream clusters » avec n’importe quel cloud public supporté par Rancher ou sur un cloud privé automatisable (ex. VMware vSphere), y compris les scénarios supportés par l’offre OVHcloud Edition.", + "upgradePlanButton": "Améliorer mon offre" } 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 f301065fd3d6..46dbb5fad2ed 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 @@ -28,6 +28,7 @@ import { useTranslation } from 'react-i18next'; import { MutationStatus } from '@tanstack/react-query'; import { + RancherPlanName, RancherService, RancherVersion, ResourceStatus, @@ -125,6 +126,8 @@ const RancherDetail = ({ isReadyStatus && !updateSoftwareResponseType; + const isEligibleForUpgrade = plan === RancherPlanName.OVHCLOUD_EDITION; + return (
@@ -256,6 +259,28 @@ const RancherDetail = ({
+ {isEligibleForUpgrade && ( +
+ +
+ {t('upgradePlanTitle')} + + {t('upgradePlanDescription')} + + +
+
+
+ )} ); diff --git a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.test.tsx b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.test.tsx index 6b487fed7935..fff93f41ec09 100644 --- a/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.test.tsx +++ b/packages/manager/apps/pci-rancher/src/components/layout-helpers/Dashboard/RancherDetail/RancherDetail.test.tsx @@ -3,7 +3,7 @@ import dashboardTranslation from '@translation/dashboard/Messages_fr_FR.json'; import updateTranslation from '@translation/updateSoftware/Messages_fr_FR.json'; import { versionsMocked } from '@/_mock_/version'; import { rancherMocked } from '@/_mock_/rancher'; -import { ResourceStatus } from '@/types/api.type'; +import { RancherPlanName, ResourceStatus } from '@/types/api.type'; import { fireEvent, render, waitFor } from '@/utils/test/test.provider'; import RancherDetail, { RancherDetailProps } from './RancherDetail.component'; @@ -182,5 +182,25 @@ describe('RancherDetail', () => { expect(updateSoftwareLabel).toBeNull(); expect(updateSoftwareButton).toBeNull(); }); + it('should render upgrade plan information when isEligibleForUpgrade is true', async () => { + const screen = await setupSpecTest(); + + const upgradePlanTitle = screen.getByText( + dashboardTranslation.upgradePlanTitle, + ); + const upgradePlanDescription = screen.getByText( + dashboardTranslation.upgradePlanDescription, + ); + const upgradePlanButton = screen.getByText( + dashboardTranslation.upgradePlanButton, + ); + + expect(upgradePlanTitle).toBeInTheDocument(); + expect(upgradePlanDescription).toBeInTheDocument(); + expect(upgradePlanButton).toBeInTheDocument(); + + const linkIcon = screen.getByText(dashboardTranslation.upgradePlanButton); + expect(linkIcon).not.toBeDisabled(); + }); }); });