Skip to content

Commit c95e9f1

Browse files
committed
feat: Split the deployment and usage to two lines
1 parent 07832fb commit c95e9f1

File tree

3 files changed

+51
-17
lines changed

3 files changed

+51
-17
lines changed

src/components/ui/select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ function SelectItem({ className, children, ...props }: React.ComponentProps<type
8989
)}
9090
{...props}
9191
>
92+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
9293
<span className="absolute right-2 flex size-3.5 items-center justify-center">
9394
<SelectPrimitive.ItemIndicator>
9495
<CheckIcon className="size-4" />
9596
</SelectPrimitive.ItemIndicator>
9697
</span>
97-
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
9898
</SelectPrimitive.Item>
9999
);
100100
}

src/features/clusters/upsert/ClusterDetails.tsx

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ interface ClusterDetailsProps {
3232
}
3333

3434
const DEPLOYMENT_FULL_DESCRIPTION: { [key: string]: string } = {
35-
"Colocated": "Colocated (shared infrastructure for optimized value)",
36-
"Dedicated": "Dedicated (dedicated infrastructure for consistent performance)",
37-
"Self-Hosted": "Self-Hosted (your own infrastructure)",
38-
}
35+
'Colocated': 'Shared infrastructure for optimized value',
36+
'Dedicated': 'Dedicated infrastructure for consistent performance',
37+
'Self-Hosted': 'Your own infrastructure',
38+
};
3939

4040
export function ClusterDetails({
4141
calculatedNames,
@@ -51,14 +51,37 @@ export function ClusterDetails({
5151
totalPrice,
5252
}: ClusterDetailsProps) {
5353
const { isDirty, isValid } = useFormState();
54-
const availablePerformanceDescriptions = useMemo(() =>
55-
Object.keys(deploymentToPerformanceToPlan[selectedDeployment] || {}), [deploymentToPerformanceToPlan, selectedDeployment]);
54+
const availablePerformanceDescriptions = useMemo(() => {
55+
return Object.keys(deploymentToPerformanceToPlan[selectedDeployment] || {}).map(performanceTier => {
56+
const splitByParens = performanceTier.slice(0, -1).split('(');
57+
if (splitByParens.length > 1) {
58+
return {
59+
performanceTier,
60+
name: splitByParens[0],
61+
description: splitByParens[1],
62+
};
63+
}
64+
const splitByFor = performanceTier.split(' for ');
65+
if (splitByFor.length > 1) {
66+
return {
67+
performanceTier,
68+
name: splitByFor[0],
69+
description: 'For ' + splitByFor[1],
70+
};
71+
}
72+
return {
73+
performanceTier,
74+
name: performanceTier,
75+
description: '',
76+
};
77+
});
78+
}, [deploymentToPerformanceToPlan, selectedDeployment]);
5679
const availableDeploymentTypes = useMemo(() =>
5780
Object.keys(deploymentToPerformanceToPlan).sort(), [deploymentToPerformanceToPlan]);
5881

5982
useEffect(function autoSelectFirstAvailablePerformanceDescription() {
60-
if (availablePerformanceDescriptions?.length && !availablePerformanceDescriptions.includes(selectedPerformance)) {
61-
form.setValue('performanceDescription', availablePerformanceDescriptions[0]);
83+
if (availablePerformanceDescriptions?.length && !availablePerformanceDescriptions.find(sp => sp.performanceTier === selectedPerformance)) {
84+
form.setValue('performanceDescription', availablePerformanceDescriptions[0].performanceTier);
6285
void form.trigger();
6386
}
6487
}, [selectedDeployment, selectedPerformance, availablePerformanceDescriptions, form]);
@@ -102,7 +125,7 @@ export function ClusterDetails({
102125
field.onChange(deploymentDescription);
103126
void form.trigger();
104127
}}>
105-
<SelectTrigger className="w-full">
128+
<SelectTrigger className="w-full h-auto">
106129
<SelectValue placeholder="Choose Tier" />
107130
</SelectTrigger>
108131
<SelectContent>
@@ -111,7 +134,11 @@ export function ClusterDetails({
111134
<SelectItem
112135
key={deploymentDescription}
113136
value={deploymentDescription}
114-
>{DEPLOYMENT_FULL_DESCRIPTION[deploymentDescription] ?? deploymentDescription}</SelectItem>
137+
>
138+
<dt className="text-left font-bold text-sm/6">{deploymentDescription}</dt>
139+
{DEPLOYMENT_FULL_DESCRIPTION[deploymentDescription] && (
140+
<dd className="font-light">{DEPLOYMENT_FULL_DESCRIPTION[deploymentDescription]}</dd>)}
141+
</SelectItem>
115142
))}
116143
</SelectGroup>
117144
</SelectContent>
@@ -138,16 +165,20 @@ export function ClusterDetails({
138165
void form.trigger();
139166
}}
140167
disabled={!availablePerformanceDescriptions?.length}>
141-
<SelectTrigger className="w-full">
168+
<SelectTrigger className="w-full h-auto">
142169
<SelectValue placeholder="Choose Tier" />
143170
</SelectTrigger>
144171
<SelectContent>
145172
<SelectGroup>
146173
{availablePerformanceDescriptions.map((performanceDescription) => (
147174
<SelectItem
148-
key={performanceDescription}
149-
value={performanceDescription}
150-
>{performanceDescription}</SelectItem>
175+
key={performanceDescription.name}
176+
value={performanceDescription.performanceTier}
177+
>
178+
<dt className="text-left font-bold text-sm/6">{performanceDescription.name}</dt>
179+
{performanceDescription.description && (
180+
<dd className="font-light">{performanceDescription.description}</dd>)}
181+
</SelectItem>
151182
))}
152183
</SelectGroup>
153184
</SelectContent>

src/features/clusters/upsert/components/RegionFormInputs.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ export function RegionFormInputs({
123123
</Button>
124124
</div>
125125
)}
126-
<ResourcesPerInstance planLimits={selectedPlan?.planLimits} resourcesPerInstance={selectedPlan?.resourcesPerInstance} selectedRegion={regionNameToLatencyToRegion[selectedRegionName]?.[selectedLatencyDescription
127-
]}/>
126+
<ResourcesPerInstance
127+
planLimits={selectedPlan?.planLimits}
128+
resourcesPerInstance={selectedPlan?.resourcesPerInstance}
129+
selectedRegion={regionNameToLatencyToRegion[selectedRegionName]?.[selectedLatencyDescription]}
130+
/>
128131
</div>
129132
);
130133
}

0 commit comments

Comments
 (0)