-
Notifications
You must be signed in to change notification settings - Fork 399
Upcoming: [UIE-9538]- Disable premium plan tab if corresponding g7 dedicated plans are available #13081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upcoming: [UIE-9538]- Disable premium plan tab if corresponding g7 dedicated plans are available #13081
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@linode/manager": Upcoming Features | ||
| --- | ||
|
|
||
| Disable premium plan tab if corresponding g7 dedicated plans are available ([#13081](https://github.com/linode/manager/pull/13081)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ const options: { flag: keyof Flags; label: string }[] = [ | |
| label: 'Firewall Rulesets & Prefixlists', | ||
| }, | ||
| { flag: 'gecko2', label: 'Gecko' }, | ||
| { flag: 'generationalPlans', label: 'Generational compute plans' }, | ||
| { flag: 'generationalPlansv2', label: 'Generational compute plans' }, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since DevTools doesn't support configuring data structures other than booleans and nested booleans, should we remove this from May be a good idea to keep it as is at this early stage of development to test locally for now. @abailly-akamai thoughts?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As long as the enabled property is helpful we can leave it here - maybe remove in the next PR? |
||
| { flag: 'limitsEvolution', label: 'Limits Evolution' }, | ||
| { flag: 'linodeDiskEncryption', label: 'Linode Disk Encryption (LDE)' }, | ||
| { flag: 'linodeInterfaces', label: 'Linode Interfaces' }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ import { | |
| planTabInfoContent, | ||
| replaceOrAppendPlaceholder512GbPlans, | ||
| useIsAcceleratedPlansEnabled, | ||
| useShouldDisablePremiumPlansTab, | ||
| } from './utils'; | ||
|
|
||
| import type { PlanSelectionType } from './types'; | ||
|
|
@@ -111,6 +112,10 @@ export const PlansPanel = (props: PlansPanelProps) => { | |
| Boolean(flags.soldOutChips) && Boolean(selectedRegionID) | ||
| ); | ||
|
|
||
| const shouldDisablePremiumPlansTab = useShouldDisablePremiumPlansTab({ | ||
| types, | ||
| }); | ||
|
|
||
| const _types = types.filter((type) => { | ||
| if (!isAcceleratedLinodePlansEnabled && type.class === 'accelerated') { | ||
| return false; | ||
|
|
@@ -162,7 +167,7 @@ export const PlansPanel = (props: PlansPanelProps) => { | |
|
|
||
| const isDatabaseResize = flow === 'database' && isResize; | ||
|
|
||
| const tabs = Object.keys(plans).map( | ||
| const tabs = Object.keys(plans)?.map( | ||
grevanak-akamai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (plan: Exclude<LinodeTypeClass, 'nanode' | 'standard'>) => { | ||
| const plansMap: PlanSelectionType[] = plans[plan]!; | ||
| const { | ||
|
|
@@ -255,6 +260,19 @@ export const PlansPanel = (props: PlansPanelProps) => { | |
| ); | ||
| } | ||
|
|
||
| // If there are no premium plans available, plans table will hide the premium tab. | ||
| // To override this behavior, we add the tab again and then disable it. | ||
| if ( | ||
| shouldDisablePremiumPlansTab && | ||
| !tabs.some((tab) => tab.title === planTabInfoContent.premium?.title) | ||
| ) { | ||
| tabs.push({ | ||
| disabled: true, | ||
| render: () => <div />, | ||
| title: planTabInfoContent.premium?.title, | ||
| }); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π |
||
|
|
||
| return ( | ||
| <TabbedPanel | ||
| copy={copy} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { useAccount } from '@linode/queries'; | |
| import { arrayToList, isFeatureEnabledV2 } from '@linode/utilities'; | ||
|
|
||
| import { useFlags } from 'src/hooks/useFlags'; | ||
| import { useIsGenerationalPlansEnabled } from 'src/utilities/linodes'; | ||
|
|
||
| import { | ||
| DEDICATED_512_GB_PLAN, | ||
|
|
@@ -23,6 +24,7 @@ import type { | |
| import type { | ||
| BaseType, | ||
| Capabilities, | ||
| LinodeType, | ||
| LinodeTypeClass, | ||
| Region, | ||
| RegionAvailability, | ||
|
|
@@ -495,3 +497,19 @@ export const getDisabledPlanReasonCopy = ({ | |
|
|
||
| return PLAN_IS_CURRENTLY_UNAVAILABLE_COPY; | ||
| }; | ||
|
|
||
| export const useShouldDisablePremiumPlansTab = ({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: Could we also add unit tests for this utility hook (with some allowed plans)? I think It would be good to have coverage for it. |
||
| types, | ||
| }: { | ||
| types: LinodeType[] | PlanSelectionType[] | undefined; | ||
| }): boolean => { | ||
| const { isGenerationalPlansEnabled, allowedPlans } = | ||
| useIsGenerationalPlansEnabled(); | ||
| // Check if any public premium plans are available. | ||
| // We can omit "Premium HT" and "Premium nested" plans as customers don't deploy them using cloud manager. | ||
grevanak-akamai marked this conversation as resolved.
Show resolved
Hide resolved
grevanak-akamai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const arePublicPremiumPlansAvailable = types?.some( | ||
| (plan) => plan.class === 'premium' && allowedPlans.includes(plan.id) | ||
| ); | ||
|
|
||
| return Boolean(isGenerationalPlansEnabled) && !arePublicPremiumPlansAvailable; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a TODO to revisit as this will need to be tested for its real behavior eventually