-
Notifications
You must be signed in to change notification settings - Fork 367
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
feat: [M3-7373] - Sold Out Chips #10013
Conversation
35848b0
to
8063a57
Compare
@@ -16,7 +16,7 @@ export interface CardBaseProps { | |||
headingDecoration?: JSX.Element; | |||
renderIcon?: () => JSX.Element; | |||
renderVariant?: () => JSX.Element | null; | |||
subheadings: (string | undefined)[]; | |||
subheadings: (JSX.Element | string | undefined)[]; |
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.
This allows adding the chip to the selection card on mobile
|
||
return !!availability; | ||
}; | ||
|
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.
This is the meat of the PR. Made sure to have early returns so we don't loop over regionAvailabilities
for no reasons
Coverage Report: ✅ |
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.
code review ✅
will be reviewing the functionality and following the steps listed above next 👍
}, [ | ||
disabled, | ||
getTypeCount, | ||
onAdd, | ||
onSelect, | ||
plans, | ||
selectedId, | ||
selectedRegionID, | ||
selectedRegionId, |
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.
saw an eslint error for missing regionAvailabilities
from dependency list
selectedRegionId, | |
regionAvailabilities, | |
selectedRegionId, |
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.
fixed!
expect(result).toBe(false); | ||
}); | ||
|
||
it('should return false if plan or selectedRegionId is falsy', () => { |
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.
it('should return false if plan or selectedRegionId is falsy', () => { | |
it('should return false if selectedRegionId is falsy', () => { |
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.
fixed!
|
||
expect(result).toBe(false); | ||
}); | ||
|
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.
can we add a test for non matching planId:
it('should return false if no matching regionAvailability is found (based on planId)', () => {
const result = getPlanSoldOutStatus({
plan: mockPlan,
regionAvailabilities: [
{ available: true, plan: otherMockPlan.id, region: 'us-east-1' },
],
selectedRegionId: mockSelectedRegionId,
});
expect(result).toBe(false);
});
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.
Good idea - added!
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.
✅ Confirmed sold out chips in either the Dedicated CPU or Shared CPU tabs
✅ Confirmed mobile and desktop styling
✅ Confirmed light and dark mode (ignore known visual defect for disabled radios which will be released at the same time)
✅ Confirmed chip doesn't show if panel is disabled
✅ Test coverage looks good
Connie had some good feedback. Agreed about the weird experience of being able to add a kube cluster that is Sold Out; we should disable those buttons.
Otherwise, a small piece of feedback on the disabled table row styling, which differs between Linode and Kube: This is more noticeable in light mode. Kube styling seems preferable to me, where the disabled row is lighter than the other rows. Can we make that consistent with the Linode plans table?
a02f47f
to
8a2fa6e
Compare
@mjac0bs addressed all the feedback - pls take another look when you get a chance, ty! |
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.
Functionality and logic is looking good! Left a few optional comments/questions
packages/manager/src/constants.ts
Outdated
|
||
// Sold Out plans | ||
export const PLAN_IS_SOLD_OUT_COPY = | ||
'This plan has no availability for the selected region. Please select a smaller plan or the same plan in another region.'; |
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.
'This plan has no availability for the selected region. Please select a smaller plan or the same plan in another region.'; | |
'This plan has no availability for the selected region. Please select a different plan or the same plan in another region.'; |
Was "smaller" picked because all plan above a certain size will always be sold out? (is it possible for a Dedicated 32GB to be sold out but a Dedicated 64GB to be in stock)
It feels weird to me to assume the user should pick a smaller plan.
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.
This was the recommended copy (and yes if it is based on the host's availability so theoretically a bigger plan would never be available), but i do prefer using different
as well so I made that update 👍
<TooltipIcon | ||
data-testid="sold-out-chip" | ||
icon={<Chip label="Sold Out" />} | ||
status="other" | ||
text={PLAN_IS_SOLD_OUT_COPY} | ||
/> |
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.
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.
Fair enough - I added a regular tooltip with Chip inside for both instance - also moved the tooltip to the SelectionCard on mobile
/** | ||
* Utility to map Premium & GPU plans to a selected region's availability. | ||
*/ | ||
export const getPlanSoldOutStatus = ({ |
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.
Optional naming / comment changes. I like using "is" for boolean things
/** | |
* Utility to map Premium & GPU plans to a selected region's availability. | |
*/ | |
export const getPlanSoldOutStatus = ({ | |
/** | |
* Utility to determine if a plan is sold out based on a region's availability. | |
*/ | |
export const getIsPlanSoldOut = ({ |
/** | |
* Utility to map Premium & GPU plans to a selected region's availability. | |
*/ | |
export const getPlanSoldOutStatus = ({ | |
/** | |
* Utility to map Premium & GPU plans to a selected region's availability. | |
*/ | |
export const getPlanSoldOutStatus = ({ |
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.
Agreed, done as well!
@@ -109,6 +111,41 @@ export const getRegionsWithCapability = ( | |||
return arrayToList(withCapability ?? []); | |||
}; | |||
|
|||
interface PlanSoldOutStatus { |
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.
Optional
interface PlanSoldOutStatus { | |
interface PlanSoldOutStatusOptions { |
Thanks for the congruent disabled row treatment! One more thing to fix with Kube: in selection card mode only, the buttons aren't disabled when the plan is sold out. Screen.Recording.2024-01-02.at.2.44.48.PM.mov |
6e5d79a
to
cd9be32
Compare
@mjac0bs feedback addressed as well! |
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.
Thanks, Alban! Verified light and dark mode both still look good and that rows (and their buttons) are all disabled at various screen sizes once all feedback was addressed.
One tiny nitpick: with the tooltip/chip changes, it looks like we lost a little margin between the plan label and the chip - not sure if that was intentional. They look a little close together and could benefit from a bit of spacing, in my opinion.
|
||
const shouldDisplayNoRegionSelectedMessage = !selectedRegionID; | ||
const { data: regionAvailabilities } = useRegionsAvailabilitiesQuery( |
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.
Rather than using the useRegionsAvailabilitiesQuery
, can we just fetch the availability for selectedRegionId
?
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.
Yeah good idea it's available and will make for smaller requests on RegionSelect change - done here:
7adfe39
Description 📝
This PR implements sold out chips to our
PlanSelection
components (both Linode and Kubernetes). It helps our users with picking aGPU
orPremium CPU
plan by showing them plans that are actually available to them instead of trying to select unavailable plans that would lead to an API error upon submission.It utilizes the new regions/availability endpoint which only returns availability for
GPU
orPremium CPU
plans (it may be expanded later on). In the background, the endpoint gets refreshed at 15m via a cron job checking available resources in our DCs.plan
value to our regular plan Ids. This is why this PR is to be tested with mock data.off
and no data is returned no plans will be shown as sold out.Changes 🔄
GPU
orPremium CPU
plansuseRegionsAvailabilitiesQuery
to be abled to be disabledsubheadings
mobile selection cardssoldOutSingapore
&soldOutTokyo
flagsselectedRegionID
withselectedRegionId
Preview 📷
Linode Creation Flow
Kubernetes Creation Flow
How to test 🧪
Prerequisites
Verification steps
for both the Linode and Kubernetes creation flows:
true
)As an Author I have considered 🤔
Check all that apply