Skip to content

Commit 1a61b15

Browse files
hana-akamaimjac0bs
andauthored
fix: [M3-9769] - Enhanced number input for LKE and LKE-E (#12046)
## Description 📝 Fix Enhanced Number Input component only displaying the first digit and update max nodes to 500 for LKE-E Add Node Pool table and Resize drawer ## How to test 🧪 ### Prerequisites (How to setup test environment) - Ensure you have LKE-E customer tags (see project tracker) ### Verification steps (How to verify changes) - [ ] Checkout this PR or preview link, go to `/kubernetes/create`, select LKE tier and region, and go to the Add Node Pools table - [ ] Update one of the number inputs to a 2-digit and 3-digit value - [ ] All digits display without getting cut off - [ ] LKE-E tier has a max of 500 nodes you can add at a time ``` pnpm test KubernetesPlanSelection ``` ``` pnpm cy:run -s "cypress/e2e/core/kubernetes/lke-create.spec.ts ``` --------- Co-authored-by: mjac0bs <mjacobs@akamai.com>
1 parent 5d84137 commit 1a61b15

24 files changed

Lines changed: 195 additions & 97 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Fixed
3+
---
4+
5+
Enhanced Number Input component only displaying the first digit and update max nodes to 500 for LKE-E Add Node Pool table and Resize drawer ([#12046](https://github.com/linode/manager/pull/12046))

packages/manager/cypress/e2e/core/kubernetes/lke-create.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ describe('LKE Cluster Creation', () => {
274274
.within(() => {
275275
cy.get(quantityInput).should('be.visible');
276276
cy.get(quantityInput).click();
277+
278+
// Ensure the max node count is 100 for LKE
279+
cy.get(quantityInput).type(`{selectall}101`);
280+
cy.get(quantityInput).should('have.value', 100);
281+
277282
cy.get(quantityInput).type(`{selectall}${nodeCount}`);
278283

279284
ui.button
@@ -1318,6 +1323,7 @@ describe('LKE Cluster Creation with LKE-E', () => {
13181323
* - Confirms the checkout bar displays the correct LKE-E info
13191324
* - Confirms an enterprise cluster can be created with the correct chip, version, and price
13201325
* - Confirms that the total node count for each pool is displayed
1326+
* - Confirms that the max nodes is 500
13211327
*/
13221328
it('creates an LKE-E cluster with the account capability', () => {
13231329
const clusterLabel = randomLabel();
@@ -1503,6 +1509,11 @@ describe('LKE Cluster Creation with LKE-E', () => {
15031509
.within(() => {
15041510
cy.get(quantityInput).should('be.visible');
15051511
cy.get(quantityInput).click();
1512+
1513+
// Ensure the max node count is 500 for LKE-E
1514+
cy.get(quantityInput).type(`{selectall}501`);
1515+
cy.get(quantityInput).should('have.value', 500);
1516+
15061517
cy.get(quantityInput).type(`{selectall}${nodeCount}`);
15071518

15081519
ui.button

packages/manager/src/components/DeletionDialog/DeletionDialog.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,8 @@ export interface DeletionDialogProps extends Omit<DialogProps, 'title'> {
2222

2323
export const DeletionDialog = React.memo((props: DeletionDialogProps) => {
2424
const theme = useTheme();
25-
const {
26-
entity,
27-
error,
28-
label,
29-
loading,
30-
onClose,
31-
onDelete,
32-
open,
33-
...rest
34-
} = props;
25+
const { entity, error, label, loading, onClose, onDelete, open, ...rest } =
26+
props;
3527

3628
const { data: typeToConfirmPreference } = usePreferences(
3729
(preferences) => preferences?.type_to_confirm ?? true

packages/manager/src/components/EnhancedNumberInput/EnhancedNumberInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const sxTextField = {
2323
height: 34,
2424
margin: '0 5px',
2525
minHeight: 30,
26-
minWidth: 40,
27-
width: 53,
26+
minWidth: 53,
27+
maxWidth: 70,
2828
};
2929

3030
interface EnhancedNumberInputProps {

packages/manager/src/factories/managed.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,24 @@ export const managedIssueFactory = Factory.Sync.makeFactory<ManagedIssue>({
7878
services: [],
7979
});
8080

81-
export const managedSSHSettingFactory = Factory.Sync.makeFactory<ManagedSSHSetting>(
82-
{
81+
export const managedSSHSettingFactory =
82+
Factory.Sync.makeFactory<ManagedSSHSetting>({
8383
access: true,
8484
ip: 'any',
8585
port: 22,
8686
user: 'root',
87-
}
88-
);
87+
});
8988

90-
export const managedLinodeSettingFactory = Factory.Sync.makeFactory<ManagedLinodeSetting>(
91-
{
89+
export const managedLinodeSettingFactory =
90+
Factory.Sync.makeFactory<ManagedLinodeSetting>({
9291
group: 'linodes',
9392
id: Factory.each((i) => i),
9493
label: Factory.each((i) => `Managed Linode ${i}`),
9594
ssh: managedSSHSettingFactory.build(),
96-
}
97-
);
95+
});
9896

99-
export const managedSSHPubKeyFactory = Factory.Sync.makeFactory<ManagedSSHPubKey>(
100-
{
97+
export const managedSSHPubKeyFactory =
98+
Factory.Sync.makeFactory<ManagedSSHPubKey>({
10199
ssh_key:
102100
'ssh-rsa MOCKEDSSHKEYMOCKEDSSHKEYMOCKEDSSHKEYMOCKEDSSHKEYMOCKEDSSHKEYMOCKEDSSHKEYMOCKEDSSHKEYMOCKEDSSHKEYMOCKEDSSHKEY managedservices@linode',
103-
}
104-
);
101+
});

packages/manager/src/features/Kubernetes/ClusterList/constants.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/manager/src/features/Kubernetes/CreateCluster/CreateCluster.tsx

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ import {
5656
import { getDCSpecificPriceByType } from 'src/utilities/pricing/dynamicPricing';
5757
import { reportAgreementSigningError } from 'src/utilities/reportAgreementSigningError';
5858

59-
import { CLUSTER_VERSIONS_DOCS_LINK } from '../constants';
59+
import {
60+
CLUSTER_VERSIONS_DOCS_LINK,
61+
MAX_NODES_PER_POOL_ENTERPRISE_TIER,
62+
MAX_NODES_PER_POOL_STANDARD_TIER,
63+
} from '../constants';
6064
import KubeCheckoutBar from '../KubeCheckoutBar';
6165
import { ApplicationPlatform } from './ApplicationPlatform';
6266
import { ClusterNetworkingPanel } from './ClusterNetworkingPanel';
@@ -115,13 +119,10 @@ export const CreateCluster = () => {
115119
const [ipV6Addr, setIPv6Addr] = React.useState<ExtendedIP[]>([
116120
stringToExtendedIP(''),
117121
]);
118-
const [selectedTier, setSelectedTier] = React.useState<KubernetesTier>(
119-
'standard'
120-
);
121-
const [
122-
isACLAcknowledgementChecked,
123-
setIsACLAcknowledgementChecked,
124-
] = React.useState(false);
122+
const [selectedTier, setSelectedTier] =
123+
React.useState<KubernetesTier>('standard');
124+
const [isACLAcknowledgementChecked, setIsACLAcknowledgementChecked] =
125+
React.useState(false);
125126

126127
const {
127128
data: kubernetesHighAvailabilityTypesData,
@@ -151,6 +152,21 @@ export const CreateCluster = () => {
151152
// Clear the ACL error if the tier is switched, since standard tier doesn't require it
152153
setErrors(undefined);
153154
}
155+
156+
// If a user adds > 100 nodes in the LKE-E flow but then switches to LKE, set the max node count to 100 for correct price display
157+
if (isLkeEnterpriseLAFeatureEnabled) {
158+
setNodePools(
159+
nodePools.map((nodePool) => ({
160+
...nodePool,
161+
count: Math.min(
162+
nodePool.count,
163+
tier === 'enterprise'
164+
? MAX_NODES_PER_POOL_ENTERPRISE_TIER
165+
: MAX_NODES_PER_POOL_STANDARD_TIER
166+
),
167+
}))
168+
);
169+
}
154170
};
155171

156172
const lkeHAType = kubernetesHighAvailabilityTypesData?.find(
@@ -174,18 +190,14 @@ export const CreateCluster = () => {
174190
// Only want to use current types here.
175191
const typesData = filterCurrentTypes(allTypes?.map(extendType));
176192

177-
const {
178-
mutateAsync: createKubernetesCluster,
179-
} = useCreateKubernetesClusterMutation();
193+
const { mutateAsync: createKubernetesCluster } =
194+
useCreateKubernetesClusterMutation();
180195

181-
const {
182-
mutateAsync: createKubernetesClusterBeta,
183-
} = useCreateKubernetesClusterBetaMutation();
196+
const { mutateAsync: createKubernetesClusterBeta } =
197+
useCreateKubernetesClusterBetaMutation();
184198

185-
const {
186-
isLkeEnterpriseLAFeatureEnabled,
187-
isLkeEnterpriseLAFlagEnabled,
188-
} = useIsLkeEnterpriseEnabled();
199+
const { isLkeEnterpriseLAFeatureEnabled, isLkeEnterpriseLAFlagEnabled } =
200+
useIsLkeEnterpriseEnabled();
189201

190202
const {
191203
isLoadingVersions,

packages/manager/src/features/Kubernetes/CreateCluster/NodePoolPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { extendType } from 'src/utilities/extendType';
88
import {
99
ADD_NODE_POOLS_DESCRIPTION,
1010
ADD_NODE_POOLS_ENTERPRISE_DESCRIPTION,
11-
} from '../ClusterList/constants';
11+
} from '../constants';
1212
import { KubernetesPlansPanel } from '../KubernetesPlansPanel/KubernetesPlansPanel';
1313
import { PremiumCPUPlanNotice } from './PremiumCPUPlanNotice';
1414

packages/manager/src/features/Kubernetes/KubeCheckoutBar/KubeCheckoutBar.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ export const KubeCheckoutBar = (props: Props) => {
147147
)}
148148
{pools.map((thisPool, idx) => (
149149
<NodePoolSummaryItem
150+
clusterTier={enterprisePrice ? 'enterprise' : 'standard'}
151+
key={idx}
152+
nodeCount={thisPool.count}
153+
onRemove={() => removePool(idx)}
150154
poolType={
151155
types?.find((thisType) => thisType.id === thisPool.type) || null
152156
}
@@ -163,9 +167,6 @@ export const KubeCheckoutBar = (props: Props) => {
163167
updateNodeCount={(updatedCount: number) =>
164168
updatePool(idx, { ...thisPool, count: updatedCount })
165169
}
166-
key={idx}
167-
nodeCount={thisPool.count}
168-
onRemove={() => removePool(idx)}
169170
/>
170171
))}
171172
<Divider dark spacingBottom={0} spacingTop={16} />

packages/manager/src/features/Kubernetes/KubeCheckoutBar/NodePoolSummaryItem.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import * as React from 'react';
55

66
import { DisplayPrice } from 'src/components/DisplayPrice';
77
import { EnhancedNumberInput } from 'src/components/EnhancedNumberInput/EnhancedNumberInput';
8+
import {
9+
MAX_NODES_PER_POOL_ENTERPRISE_TIER,
10+
MAX_NODES_PER_POOL_STANDARD_TIER,
11+
} from 'src/features/Kubernetes/constants';
812

913
import {
1014
StyledHeader,
@@ -13,9 +17,11 @@ import {
1317
StyledPriceBox,
1418
} from './KubeCheckoutSummary.styles';
1519

20+
import type { KubernetesTier } from '@linode/api-v4';
1621
import type { ExtendedType } from 'src/utilities/extendType';
1722

1823
export interface Props {
24+
clusterTier?: KubernetesTier;
1925
nodeCount: number;
2026
onRemove: () => void;
2127
poolType: ExtendedType | null;
@@ -24,7 +30,8 @@ export interface Props {
2430
}
2531

2632
export const NodePoolSummaryItem = React.memo((props: Props) => {
27-
const { nodeCount, onRemove, poolType, price, updateNodeCount } = props;
33+
const { nodeCount, onRemove, poolType, price, updateNodeCount, clusterTier } =
34+
props;
2835

2936
// This should never happen but TS wants us to account for the situation
3037
// where we fail to match a selected type against our types list.
@@ -55,6 +62,11 @@ export const NodePoolSummaryItem = React.memo((props: Props) => {
5562
</Box>
5663
<Box mb={1.5} mt={2}>
5764
<EnhancedNumberInput
65+
max={
66+
clusterTier === 'enterprise'
67+
? MAX_NODES_PER_POOL_ENTERPRISE_TIER
68+
: MAX_NODES_PER_POOL_STANDARD_TIER
69+
}
5870
min={1}
5971
setValue={updateNodeCount}
6072
value={nodeCount}

0 commit comments

Comments
 (0)