diff --git a/packages/manager/.changeset/pr-13539-tests-1775850586793.md b/packages/manager/.changeset/pr-13539-tests-1775850586793.md new file mode 100644 index 00000000000..aafad303056 --- /dev/null +++ b/packages/manager/.changeset/pr-13539-tests-1775850586793.md @@ -0,0 +1,5 @@ +--- +'@linode/manager': Tests +--- + +Mock `databaseResizeGenerationalPlans` feature flag to false for resize-database.spec.ts ([#13539](https://github.com/linode/manager/pull/13539)) diff --git a/packages/manager/.changeset/pr-13539-upcoming-features-1775850537076.md b/packages/manager/.changeset/pr-13539-upcoming-features-1775850537076.md new file mode 100644 index 00000000000..a7e7d9274b4 --- /dev/null +++ b/packages/manager/.changeset/pr-13539-upcoming-features-1775850537076.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Upcoming Features +--- + +Generational plans changes for Databases ([#13539](https://github.com/linode/manager/pull/13539)) diff --git a/packages/manager/cypress/e2e/core/databases/resize-database.spec.ts b/packages/manager/cypress/e2e/core/databases/resize-database.spec.ts index 62d822849ba..35acb55ff47 100644 --- a/packages/manager/cypress/e2e/core/databases/resize-database.spec.ts +++ b/packages/manager/cypress/e2e/core/databases/resize-database.spec.ts @@ -1,11 +1,3 @@ -/** - * @file DBaaS integration tests for resize operations. - */ -import { - ClusterSize, - DatabaseStatus, - RegionAvailability, -} from '@linode/api-v4'; import { accountFactory } from '@src/factories'; import { databaseConfigurationsResize, @@ -20,6 +12,7 @@ import { mockResize, mockResizeProvisioningDatabase, } from 'support/intercepts/databases'; +import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags'; import { mockGetRegionAvailability } from 'support/intercepts/regions'; import { ui } from 'support/ui'; import { randomIp, randomNumber, randomString } from 'support/util/random'; @@ -27,6 +20,14 @@ import { getRegionById } from 'support/util/regions'; import { databaseFactory } from 'src/factories/databases'; +/** + * @file DBaaS integration tests for resize operations. + */ +import type { + ClusterSize, + DatabaseStatus, + RegionAvailability, +} from '@linode/api-v4'; import type { DatabaseClusterConfiguration } from 'support/constants/databases'; /** @@ -63,16 +64,20 @@ const resizeDatabase = (initialLabel: string) => { * @param clusterSize - Database Cluster Size */ const getNodes = (clusterSize: number) => { - const nodes = - clusterSize == 1 - ? 'Primary (1 Node)' - : clusterSize == 2 - ? 'Primary (+1 Node)' - : 'Primary (+2 Nodes)'; - return nodes; + return clusterSize === 1 + ? 'Primary (1 Node)' + : clusterSize === 2 + ? 'Primary (+1 Node)' + : 'Primary (+2 Nodes)'; }; describe('Resizing existing clusters', () => { + beforeEach(() => { + mockAppendFeatureFlags({ + databaseResizeGenerationalPlans: false, + }); + }); + databaseConfigurationsResize.forEach( (configuration: DatabaseClusterConfiguration) => { describe(`Resizes a ${configuration.linodeType} ${configuration.engine} v${configuration.version}.x ${configuration.clusterSize}-node cluster`, () => { diff --git a/packages/manager/src/dev-tools/FeatureFlagTool.tsx b/packages/manager/src/dev-tools/FeatureFlagTool.tsx index 0db33ce2d62..b000d0848d9 100644 --- a/packages/manager/src/dev-tools/FeatureFlagTool.tsx +++ b/packages/manager/src/dev-tools/FeatureFlagTool.tsx @@ -59,6 +59,10 @@ const options: { flag: keyof Flags; label: string }[] = [ { flag: 'supportTicketSeverity', label: 'Support Ticket Severity' }, { flag: 'dbaasV2', label: 'Databases V2 Beta' }, { flag: 'dbaasV2MonitorMetrics', label: 'Databases V2 Monitor' }, + { + flag: 'databaseResizeGenerationalPlans', + label: 'Database Resize Generational Plans', + }, { flag: 'databasePgBouncer', label: 'Database PgBouncer' }, { flag: 'databaseResize', label: 'Database Resize' }, { flag: 'databaseAdvancedConfig', label: 'Database Advanced Config' }, diff --git a/packages/manager/src/featureFlags.ts b/packages/manager/src/featureFlags.ts index 76760ed7774..9c454173cb0 100644 --- a/packages/manager/src/featureFlags.ts +++ b/packages/manager/src/featureFlags.ts @@ -237,6 +237,7 @@ export interface Flags { databasePgBouncer: boolean; databasePremium: boolean; databaseResize: boolean; + databaseResizeGenerationalPlans: boolean; databaseRestrictPlanResize: boolean; databases: boolean; databaseVpc: boolean; diff --git a/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx b/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx index 7c670ebf370..773d8bde45c 100644 --- a/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx +++ b/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx @@ -18,7 +18,10 @@ import { DocumentTitleSegment } from 'src/components/DocumentTitle'; import { ErrorMessage } from 'src/components/ErrorMessage'; import { LandingHeader } from 'src/components/LandingHeader'; import { getRestrictedResourceText } from 'src/features/Account/utils'; -import { getIsLimitedAvailability } from 'src/features/components/PlansPanel/utils'; +import { + getIsLimitedAvailability, + useShouldDisablePremiumPlansTab, +} from 'src/features/components/PlansPanel/utils'; import { DatabaseClusterData } from 'src/features/Databases/DatabaseCreate/DatabaseClusterData'; import { StyledBtnCtn, @@ -252,11 +255,15 @@ export const DatabaseCreate = () => { } }; + const shouldDisablePremiumPlansTab = useShouldDisablePremiumPlansTab({ + types: dbtypes, + }); + if (regionsLoading || !regionsData || enginesLoading || typesLoading) { return ; } - if (regionsError || typesError || enginesError) { + if (regionsError || enginesError || typesError) { return ; } @@ -312,6 +319,9 @@ export const DatabaseCreate = () => { { regionsData={regionsData} selectedId={field.value} selectedRegionID={region} + tabDisabledMessage={ + shouldDisablePremiumPlansTab + ? 'Premium CPUs are now called G7 Dedicated plans.' + : undefined + } types={displayTypes} /> )} diff --git a/packages/manager/src/features/Databases/DatabaseDetail/DatabaseResize/DatabaseResize.test.tsx b/packages/manager/src/features/Databases/DatabaseDetail/DatabaseResize/DatabaseResize.test.tsx index 544c74e7ed9..edc2fe1f925 100644 --- a/packages/manager/src/features/Databases/DatabaseDetail/DatabaseResize/DatabaseResize.test.tsx +++ b/packages/manager/src/features/Databases/DatabaseDetail/DatabaseResize/DatabaseResize.test.tsx @@ -151,6 +151,7 @@ describe('database resize', () => { beta: false, enabled: true, }, + databasePremium: true, }; it('resize button should be disabled when no input is provided in the form', async () => { @@ -485,45 +486,6 @@ describe('database resize', () => { }); }); - describe('should disable Shared Plans Tab for 2 nodes cluster', () => { - const database = databaseFactory.build({ - cluster_size: 2, - type: 'g6-dedicated-8', - }); - it('should disable Shared Plans Tab', async () => { - const standardTypes = [ - databaseTypeFactory.build({ - class: 'nanode', - id: 'g6-nanode-1', - label: `Nanode 1 GB`, - memory: 1024, - }), - ]; - server.use( - http.get('*/databases/types', () => { - return HttpResponse.json( - makeResourcePage([...dedicatedTypes, ...standardTypes]) - ); - }), - http.get('*/account', () => { - const account = accountFactory.build(); - return HttpResponse.json(account); - }) - ); - - const { getByTestId, getByText } = renderWithTheme( - - - - ); - expect(getByTestId(loadingTestId)).toBeInTheDocument(); - await waitForElementToBeRemoved(getByTestId(loadingTestId)); - expect(getByText('Shared CPU')).toHaveAttribute('aria-disabled', 'true'); - }); - }); - describe('on rendering resize when databaseRestrictPlanResize feature flag is enabled', () => { beforeEach(() => { const standardTypes = [ diff --git a/packages/manager/src/features/Databases/DatabaseDetail/DatabaseResize/DatabaseResize.tsx b/packages/manager/src/features/Databases/DatabaseDetail/DatabaseResize/DatabaseResize.tsx index e80542c07ce..fe078785863 100644 --- a/packages/manager/src/features/Databases/DatabaseDetail/DatabaseResize/DatabaseResize.tsx +++ b/packages/manager/src/features/Databases/DatabaseDetail/DatabaseResize/DatabaseResize.tsx @@ -33,11 +33,12 @@ import { } from 'src/features/Databases/utilities'; import { typeLabelDetails } from 'src/features/Linodes/presentation'; import { useFlags } from 'src/hooks/useFlags'; +import { useIsGenerationalPlansEnabled } from 'src/utilities/linodes'; import { RESIZE_DISABLED_DEDICATED_SHARED_PLAN_TABS_TEXT, + RESIZE_DISABLED_NON_G7_DEDICATED_SHARED_PLAN_TABS_TEXT, RESIZE_DISABLED_PREMIUM_PLAN_TAB_TEXT, - RESIZE_DISABLED_SHARED_PLAN_TAB_LEGACY_TEXT, } from '../../constants'; import { useDatabaseDetailContext } from '../DatabaseDetailContext'; import { @@ -112,45 +113,62 @@ export const DatabaseResize = () => { (type: DatabaseType) => type.id === database.type ); - const isDisabledSharedTab = database.cluster_size === 2; - - const premiumRestrictedTabsCopy = - currentPlanType?.class === 'premium' - ? RESIZE_DISABLED_DEDICATED_SHARED_PLAN_TABS_TEXT - : RESIZE_DISABLED_PREMIUM_PLAN_TAB_TEXT; - - const restrictPlanTypes = () => { - if (currentPlanType?.class === 'premium') { - return ['shared', 'dedicated']; - } else { - return ['premium']; - } - }; + const { isGenerationalPlansEnabled } = useIsGenerationalPlansEnabled( + dbTypes, + currentPlanType?.class + ); const disabledTabsConfig: { disabledTabs: string[]; disabledTabsCopy: string; } = React.useMemo(() => { - // For new database clusters, restrict plan types based on the current plan - if (isDefaultDatabase(database) && flags.databaseRestrictPlanResize) { + if ( + !flags.databaseRestrictPlanResize || + (flags.databaseResizeGenerationalPlans && + currentPlanType?.class === 'premium') + ) { return { - disabledTabsCopy: premiumRestrictedTabsCopy, - disabledTabs: restrictPlanTypes(), + disabledTabs: [], + disabledTabsCopy: '', }; } - // Disable shared tab for legacy database clusters when cluster size is 2 - if (!isNewDatabaseGA && isDisabledSharedTab) { + + if (!isGenerationalPlansEnabled && currentPlanType?.class === 'premium') { + return { + disabledTabs: ['shared', 'dedicated'], + disabledTabsCopy: RESIZE_DISABLED_DEDICATED_SHARED_PLAN_TABS_TEXT, + }; + } + + if (isGenerationalPlansEnabled && currentPlanType?.class === 'premium') { return { - disabledTabsCopy: RESIZE_DISABLED_SHARED_PLAN_TAB_LEGACY_TEXT, disabledTabs: ['shared'], + disabledTabsCopy: + RESIZE_DISABLED_NON_G7_DEDICATED_SHARED_PLAN_TABS_TEXT, + }; + } + + if ( + isGenerationalPlansEnabled && + flags.databaseResizeGenerationalPlans && + currentPlanType?.class !== 'premium' + ) { + return { + disabledTabs: ['premium'], + disabledTabsCopy: 'Premium CPUs are now called G7 Dedicated plans.', }; } return { - disabledTabs: [], - disabledTabsCopy: '', + disabledTabs: ['premium'], + disabledTabsCopy: RESIZE_DISABLED_PREMIUM_PLAN_TAB_TEXT, }; - }, [database, flags, isNewDatabaseGA]); + }, [ + currentPlanType?.class, + flags.databaseResizeGenerationalPlans, + flags.databaseRestrictPlanResize, + isGenerationalPlansEnabled, + ]); const { enqueueSnackbar } = useSnackbar(); @@ -314,13 +332,34 @@ export const DatabaseResize = () => { setSelectedTab(initialTab); }, []); - const disabledPlans = isSmallerOrEqualCurrentPlan( + const disabledPlansDueToDiskSize = isSmallerOrEqualCurrentPlan( currentPlan?.id, database?.used_disk_size_gb, displayTypes, isNewDatabaseGA ); + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + const isCurrentPlanAPremiumPlan = + currentPlan?.class.includes('premium') || + currentPlan?.id.includes('g7-dedicated'); + + const disabledResizeToPremiumPlans = + !flags.databaseResizeGenerationalPlans && !isCurrentPlanAPremiumPlan + ? displayTypes.filter( + (type) => + type.class.includes('premium') || type.id.includes('g7-dedicated') + ) + : []; + + const disabledResizeFromPremiumPlans = + !flags.databaseResizeGenerationalPlans && isCurrentPlanAPremiumPlan + ? displayTypes.filter( + (type) => + !type.class.includes('premium') && !type.id.includes('g7-dedicated') + ) + : []; + const shouldSubmitBeDisabled = React.useMemo(() => { return !summaryText; }, [summaryText]); @@ -405,7 +444,10 @@ export const DatabaseResize = () => { currentPlanHeading={currentPlan?.heading} data-qa-select-plan disabled={disabled} - disabledSmallerPlans={disabledPlans} + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + disabledResizeFromPremiumPlans={disabledResizeFromPremiumPlans} + disabledResizeToPremiumPlans={disabledResizeToPremiumPlans} + disabledSmallerPlans={disabledPlansDueToDiskSize} disabledTabs={disabledTabsConfig.disabledTabs} flow="database" handleTabChange={handleTabChange} diff --git a/packages/manager/src/features/Databases/constants.ts b/packages/manager/src/features/Databases/constants.ts index bfb3e3b28dd..bd860397906 100644 --- a/packages/manager/src/features/Databases/constants.ts +++ b/packages/manager/src/features/Databases/constants.ts @@ -38,8 +38,8 @@ export const RESIZE_DISABLED_PREMIUM_PLAN_TAB_TEXT = export const RESIZE_DISABLED_DEDICATED_SHARED_PLAN_TABS_TEXT = 'Resizing to a Shared CPU or a Dedicated CPU plan is not available for database clusters on a Premium CPU plan.'; -export const RESIZE_DISABLED_SHARED_PLAN_TAB_LEGACY_TEXT = - 'Resizing a 2-node cluster is only allowed with Dedicated plans.'; +export const RESIZE_DISABLED_NON_G7_DEDICATED_SHARED_PLAN_TABS_TEXT = + 'Resizing to a Shared CPU or a non-G7 Dedicated CPU plan is not available for database clusters on a Premium CPU plan.'; export const BACKUPS_MAX_TIME_EXCEEDED_VALIDATON_TEXT = 'Select a time from the past.'; diff --git a/packages/manager/src/features/components/PlansPanel/PlanContainer.tsx b/packages/manager/src/features/components/PlansPanel/PlanContainer.tsx index 4b454edc2a5..ff773621d24 100644 --- a/packages/manager/src/features/components/PlansPanel/PlanContainer.tsx +++ b/packages/manager/src/features/components/PlansPanel/PlanContainer.tsx @@ -116,10 +116,8 @@ export const PlanContainer = (props: PlanContainerProps) => { } = props; const location = useLocation(); const flags = useFlags(); - const { isGenerationalPlansEnabled } = useIsGenerationalPlansEnabled( - plans, - planType - ); + const { isGenerationalPlansEnabled, hasG7DedicatedPlans } = + useIsGenerationalPlansEnabled(plans, planType); // Show the Transfer column if, for any plan, the api returned data and we're not in the Database Create flow const showTransfer = @@ -135,8 +133,11 @@ export const PlanContainer = (props: PlanContainerProps) => { const isDatabaseResizeFlow = location.pathname.match(/\/databases\/.*\/(\d+\/resize)/)?.[0] === location.pathname; - const shouldDisplayNoRegionSelectedMessage = - !selectedRegionId && !isDatabaseCreateFlow && !isDatabaseResizeFlow; + + const shouldDisplayNoRegionSelectedMessage = Boolean( + (!selectedRegionId && !isDatabaseCreateFlow) || + (isDatabaseCreateFlow && hasG7DedicatedPlans && !selectedRegionId) + ); const isDatabaseGA = !flags.dbaasV2?.beta && diff --git a/packages/manager/src/features/components/PlansPanel/PlanSelection.tsx b/packages/manager/src/features/components/PlansPanel/PlanSelection.tsx index 77364fbe3f6..5bce3837425 100644 --- a/packages/manager/src/features/components/PlansPanel/PlanSelection.tsx +++ b/packages/manager/src/features/components/PlansPanel/PlanSelection.tsx @@ -60,6 +60,9 @@ export const PlanSelection = (props: PlanSelectionProps) => { planHasLimitedAvailability, planIsDisabled512Gb, planResizeNotSupported, + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + planDBaaSResizeFromPremiumNotSupported, + planDBaaSResizeToPremiumNotSupported, planIsSmallerThanUsage, planIsTooSmall, } = plan; @@ -90,6 +93,9 @@ export const PlanSelection = (props: PlanSelectionProps) => { planIsDisabled512Gb || planHasLimitedAvailability || planResizeNotSupported || + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + (isDatabaseFlow && planDBaaSResizeFromPremiumNotSupported) || + (isDatabaseFlow && planDBaaSResizeToPremiumNotSupported) || wholePanelIsDisabled; const disabledPlanReasonCopy = getDisabledPlanReasonCopy({ @@ -97,6 +103,9 @@ export const PlanSelection = (props: PlanSelectionProps) => { planHasLimitedAvailability, planIsDisabled512Gb, planResizeNotSupported, + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + planDBaaSResizeFromPremiumNotSupported, + planDBaaSResizeToPremiumNotSupported, planIsSmallerThanUsage, planIsTooSmall, wholePanelIsDisabled, @@ -112,6 +121,9 @@ export const PlanSelection = (props: PlanSelectionProps) => { (planBelongsToDisabledClass || planIsDisabled512Gb || planHasLimitedAvailability || + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + planDBaaSResizeFromPremiumNotSupported || + planDBaaSResizeToPremiumNotSupported || planIsTooSmall || planIsSmallerThanUsage || planResizeNotSupported); diff --git a/packages/manager/src/features/components/PlansPanel/PlansPanel.tsx b/packages/manager/src/features/components/PlansPanel/PlansPanel.tsx index 83ad6b78d30..781878e24d4 100644 --- a/packages/manager/src/features/components/PlansPanel/PlansPanel.tsx +++ b/packages/manager/src/features/components/PlansPanel/PlansPanel.tsx @@ -42,6 +42,9 @@ export interface PlansPanelProps { currentPlanHeading?: string; disabled?: boolean; disabledClasses?: LinodeTypeClass[]; + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + disabledResizeFromPremiumPlans?: PlanSelectionType[]; + disabledResizeToPremiumPlans?: PlanSelectionType[]; disabledSmallerPlans?: PlanSelectionType[]; disabledTabs?: string[]; docsLink?: JSX.Element; @@ -80,6 +83,9 @@ export const PlansPanel = (props: PlansPanelProps) => { disabled, disabledClasses, disabledSmallerPlans, + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + disabledResizeToPremiumPlans, + disabledResizeFromPremiumPlans, docsLink, error, flow = 'linode', @@ -180,7 +186,11 @@ export const PlansPanel = (props: PlansPanelProps) => { disableLargestGbPlansFlag: flags.disableLargestGbPlans, disabledClasses, disabledSmallerPlans, + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + disabledResizeFromPremiumPlans, + disabledResizeToPremiumPlans, isLegacyDatabase, + isDatabaseResize, isResize: isDatabaseResize ? false : isResize, plans: plansMap, regionAvailabilities, diff --git a/packages/manager/src/features/components/PlansPanel/types.ts b/packages/manager/src/features/components/PlansPanel/types.ts index 4b41b9a9632..57b231438a1 100644 --- a/packages/manager/src/features/components/PlansPanel/types.ts +++ b/packages/manager/src/features/components/PlansPanel/types.ts @@ -30,6 +30,9 @@ export type PlanWithAvailability = export interface PlanSelectionAvailabilityTypes { planBelongsToDisabledClass: boolean; + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + planDBaaSResizeFromPremiumNotSupported?: boolean; + planDBaaSResizeToPremiumNotSupported?: boolean; planHasLimitedAvailability: boolean; planIsDisabled512Gb: boolean; planIsSmallerThanUsage?: boolean; diff --git a/packages/manager/src/features/components/PlansPanel/utils.ts b/packages/manager/src/features/components/PlansPanel/utils.ts index 56f6108786e..3da00809f73 100644 --- a/packages/manager/src/features/components/PlansPanel/utils.ts +++ b/packages/manager/src/features/components/PlansPanel/utils.ts @@ -1,6 +1,10 @@ import { useAccount } from '@linode/queries'; import { arrayToList, isFeatureEnabledV2 } from '@linode/utilities'; +import { + RESIZE_DISABLED_NON_G7_DEDICATED_SHARED_PLAN_TABS_TEXT, + RESIZE_DISABLED_PREMIUM_PLAN_TAB_TEXT, +} from 'src/features/Databases/constants'; import { useFlags } from 'src/hooks/useFlags'; import { useIsGenerationalPlansEnabled } from 'src/utilities/linodes'; @@ -24,6 +28,7 @@ import type { import type { BaseType, Capabilities, + DatabaseType, LinodeType, LinodeTypeClass, Region, @@ -321,9 +326,13 @@ export const replaceOrAppendPlaceholder512GbPlans = ( interface ExtractPlansInformationProps { disabledClasses?: LinodeTypeClass[]; + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + disabledResizeFromPremiumPlans?: PlanSelectionType[]; + disabledResizeToPremiumPlans?: PlanSelectionType[]; disabledSmallerPlans?: PlanSelectionType[]; disableLargestGbPlansFlag: Flags['disableLargestGbPlans'] | undefined; isAPLEnabled?: boolean; + isDatabaseResize?: boolean; isLegacyDatabase?: boolean; isResize?: boolean; plans: PlanSelectionType[]; @@ -333,7 +342,7 @@ interface ExtractPlansInformationProps { /** * Extracts plan information and determines if any plans are disabled. - * Used for Linode and Kubernetes selection Plan tables and notices. + * Used for Linode, Kubernetes, and Databases selection Plan tables and notices. * * @param disableLargestGbPlansFlag The flag to disable the largest GB plans. * @param disabledClasses The disabled classes (aka linode types). @@ -349,7 +358,11 @@ export const extractPlansInformation = ({ disabledSmallerPlans, isAPLEnabled, isLegacyDatabase, + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + disabledResizeFromPremiumPlans, + disabledResizeToPremiumPlans, isResize, + isDatabaseResize, plans, regionAvailabilities, selectedRegionId, @@ -373,6 +386,22 @@ export const extractPlansInformation = ({ // - Resizing existing linodes (from MTC regions) to this MTC plan is not supported. const planResizeNotSupported = isCustomMTCPlan && isResize; + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + const planDBaaSResizeFromPremiumNotSupported = + isDatabaseResize && + Boolean( + disabledResizeFromPremiumPlans?.find( + (disabledPlan) => disabledPlan.id === plan.id + ) + ); + const planDBaaSResizeToPremiumNotSupported = + isDatabaseResize && + Boolean( + disabledResizeToPremiumPlans?.find( + (disabledPlan) => disabledPlan.id === plan.id + ) + ); + const planHasLimitedAvailability = getIsLimitedAvailability({ plan, regionAvailabilities, @@ -403,6 +432,9 @@ export const extractPlansInformation = ({ planIsSmallerThanUsage, planIsTooSmall, planIsTooSmallForAPL, + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + planDBaaSResizeFromPremiumNotSupported, + planDBaaSResizeToPremiumNotSupported, }; } ); @@ -444,6 +476,9 @@ export const getIsPlanDisabled = (plan: PlanWithAvailability) => { planIsSmallerThanUsage, planIsTooSmall, planIsTooSmallForAPL, + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + planDBaaSResizeFromPremiumNotSupported, + planDBaaSResizeToPremiumNotSupported, } = plan; return ( @@ -453,7 +488,10 @@ export const getIsPlanDisabled = (plan: PlanWithAvailability) => { planResizeNotSupported || planIsSmallerThanUsage || planIsTooSmall || - planIsTooSmallForAPL + planIsTooSmallForAPL || + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + planDBaaSResizeFromPremiumNotSupported || + planDBaaSResizeToPremiumNotSupported ); }; @@ -466,12 +504,18 @@ export const getDisabledPlanReasonCopy = ({ planHasLimitedAvailability, planIsDisabled512Gb, planResizeNotSupported, + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + planDBaaSResizeFromPremiumNotSupported, + planDBaaSResizeToPremiumNotSupported, planIsSmallerThanUsage, planIsTooSmall, planIsTooSmallForAPL, wholePanelIsDisabled, }: { planBelongsToDisabledClass: DisabledTooltipReasons['planBelongsToDisabledClass']; + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + planDBaaSResizeFromPremiumNotSupported?: DisabledTooltipReasons['planDBaaSResizeFromPremiumNotSupported']; + planDBaaSResizeToPremiumNotSupported?: DisabledTooltipReasons['planDBaaSResizeToPremiumNotSupported']; planHasLimitedAvailability: DisabledTooltipReasons['planHasLimitedAvailability']; planIsDisabled512Gb: DisabledTooltipReasons['planIsDisabled512Gb']; planIsSmallerThanUsage?: DisabledTooltipReasons['planIsSmallerThanUsage']; @@ -498,6 +542,15 @@ export const getDisabledPlanReasonCopy = ({ return PLAN_IS_TOO_SMALL_FOR_APL_COPY; } + // @TODO remove dbaas resize class type restriction sometime post-release when we support resizing across different plans + if (planDBaaSResizeToPremiumNotSupported) { + return RESIZE_DISABLED_PREMIUM_PLAN_TAB_TEXT; + } + + if (planDBaaSResizeFromPremiumNotSupported) { + return RESIZE_DISABLED_NON_G7_DEDICATED_SHARED_PLAN_TABS_TEXT; + } + if ( planHasLimitedAvailability || planIsDisabled512Gb || @@ -512,7 +565,7 @@ export const getDisabledPlanReasonCopy = ({ export const useShouldDisablePremiumPlansTab = ({ types, }: { - types: LinodeType[] | PlanSelectionType[] | undefined; + types: DatabaseType[] | LinodeType[] | PlanSelectionType[] | undefined; }): boolean => { const { isGenerationalPlansEnabled, allowedPlans } = useIsGenerationalPlansEnabled(types, 'premium'); diff --git a/packages/manager/src/utilities/linodes.ts b/packages/manager/src/utilities/linodes.ts index 1d0f5f354b0..ffbaea39bd4 100644 --- a/packages/manager/src/utilities/linodes.ts +++ b/packages/manager/src/utilities/linodes.ts @@ -5,6 +5,7 @@ import { useFlags } from 'src/hooks/useFlags'; import type { AccountMaintenance, + DatabaseTypeClass, Linode, LinodeTypeClass, MaintenancePolicySlug, @@ -106,7 +107,7 @@ export const useIsLinodeCloneFirewallEnabled = () => { */ export const useIsGenerationalPlansEnabled = ( plans: Array<{ id: string }> | undefined, - planType: LinodeTypeClass | undefined + planType: DatabaseTypeClass | LinodeTypeClass | undefined ) => { const flags = useFlags(); @@ -150,5 +151,6 @@ export const useIsGenerationalPlansEnabled = ( isGenerationalPlansEnabled: isFlagEnabled && !shouldDisableDueToUnavailability, allowedPlans: flags.generationalPlansv2?.allowedPlans || [], + hasG7DedicatedPlans, }; };