From 688b36d124d594fde104c4cfb415d126f5c98abc Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Fri, 19 Apr 2024 16:54:19 -0400 Subject: [PATCH] save work still need to work on tests --- .../KubernetesPlanContainer.test.tsx | 3 + .../KubernetesPlanContainer.tsx | 21 +++-- .../KubernetesPlanSelection.test.tsx | 22 ++---- .../KubernetesPlanSelection.tsx | 29 +++---- .../KubernetesPlansPanel.tsx | 50 +++++------- .../PlansPanel/PlanContainer.test.tsx | 2 + .../PlansPanel/PlanInformation.test.tsx | 1 + .../components/PlansPanel/PlanInformation.tsx | 8 +- .../PlansPanel/PlanSelection.test.tsx | 19 +---- .../components/PlansPanel/PlanSelection.tsx | 4 +- .../components/PlansPanel/PlansPanel.tsx | 50 ++++-------- .../components/PlansPanel/constants.ts | 2 - .../features/components/PlansPanel/utils.ts | 78 ++++++++++++++----- 13 files changed, 137 insertions(+), 152 deletions(-) diff --git a/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanContainer.test.tsx b/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanContainer.test.tsx index 0000dc08685..f410ee53f95 100644 --- a/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanContainer.test.tsx +++ b/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanContainer.test.tsx @@ -23,7 +23,10 @@ const plans: TypeWithAvailability[] = [ ]; const props: KubernetesPlanContainerProps = { + allDisabledPlans: [], getTypeCount: vi.fn(), + hasMajorityOfPlansDisabled: false, + isWholePanelDisabled: false, onSelect: vi.fn(), plans, selectedRegionId: undefined, diff --git a/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanContainer.tsx b/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanContainer.tsx index d8c302f7f5b..f008cc1261d 100644 --- a/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanContainer.tsx +++ b/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanContainer.tsx @@ -26,8 +26,10 @@ const tableCells = [ ]; export interface KubernetesPlanContainerProps { - disabled?: boolean; + allDisabledPlans: string[]; getTypeCount: (planId: string) => number; + hasMajorityOfPlansDisabled: boolean; + isWholePanelDisabled: boolean; onAdd?: (key: string, value: number) => void; onSelect: (key: string) => void; plans: TypeWithAvailability[]; @@ -40,8 +42,10 @@ export const KubernetesPlanContainer = ( props: KubernetesPlanContainerProps ) => { const { - disabled, + allDisabledPlans, getTypeCount, + hasMajorityOfPlansDisabled, + isWholePanelDisabled, onAdd, onSelect, plans, @@ -54,14 +58,15 @@ export const KubernetesPlanContainer = ( const renderPlanSelection = React.useCallback(() => { return plans.map((plan, id) => { + const isPlanDisabled = allDisabledPlans.includes(plan.id); + return ( { const { getByRole, getByTestId, getByText } = renderWithTheme( wrapWithTableBody( - , + , { flags: { disableLargestGbPlans: true } } ) ); @@ -185,11 +183,7 @@ describe('KubernetesPlanSelection (cards, mobile view)', () => { it('shows limited availability messaging', async () => { const { getByRole, getByTestId, getByText } = renderWithTheme( - + ); const selectionCard = getByTestId('selection-card'); @@ -212,11 +206,7 @@ describe('KubernetesPlanSelection (cards, mobile view)', () => { }; const { getByTestId } = renderWithTheme( - , + , { flags: { disableLargestGbPlans: true } } ); diff --git a/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanSelection.tsx b/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanSelection.tsx index 84ff5ff7bf9..0c1d37db531 100644 --- a/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanSelection.tsx +++ b/packages/manager/src/features/Kubernetes/KubernetesPlansPanel/KubernetesPlanSelection.tsx @@ -16,7 +16,6 @@ import { TableCell } from 'src/components/TableCell'; import { TableRow } from 'src/components/TableRow'; import { Tooltip } from 'src/components/Tooltip'; import { LIMITED_AVAILABILITY_TEXT } from 'src/features/components/PlansPanel/constants'; -import { useFlags } from 'src/hooks/useFlags'; import { PRICE_ERROR_TOOLTIP_TEXT, UNKNOWN_PRICE, @@ -28,10 +27,11 @@ import { convertMegabytesTo } from 'src/utilities/unitConversions'; import type { TypeWithAvailability } from 'src/features/components/PlansPanel/types'; export interface KubernetesPlanSelectionProps { - disabled?: boolean; getTypeCount: (planId: string) => number; + hasMajorityOfPlansDisabled: boolean; idx: number; - isLimitedAvailabilityPlan: boolean; + isPlanDisabled: boolean; + isWholePanelDisabled: boolean; onAdd?: (key: string, value: number) => void; onSelect: (key: string) => void; selectedId?: string; @@ -44,10 +44,11 @@ export const KubernetesPlanSelection = ( props: KubernetesPlanSelectionProps ) => { const { - disabled, getTypeCount, + hasMajorityOfPlansDisabled, idx, - isLimitedAvailabilityPlan, + isPlanDisabled, + isWholePanelDisabled, onAdd, onSelect, selectedId, @@ -56,14 +57,7 @@ export const KubernetesPlanSelection = ( updatePlanCount, } = props; - const flags = useFlags(); - - // Determine if the plan should be disabled solely due to being a 512GB plan - const disabled512GbPlan = - type.label.includes('512GB') && - Boolean(flags.disableLargestGbPlans) && - !disabled; - const isDisabled = disabled || isLimitedAvailabilityPlan || disabled512GbPlan; + const isDisabled = isPlanDisabled || isWholePanelDisabled; const count = getTypeCount(type.id); const price: PriceObject | undefined = getLinodeRegionPrice( type, @@ -88,13 +82,8 @@ export const KubernetesPlanSelection = ( /> {onAdd && (