Skip to content

Commit

Permalink
Merge branch 'EVEREST-1616-ui-set-affinity-rules-in-db-creation-wizar…
Browse files Browse the repository at this point in the history
…d' into EVEREST-1607-affinity-from-overview
  • Loading branch information
fabio-silva committed Jan 21, 2025
2 parents 8d60ace + c21929d commit f2d61b3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { findDbAndClickRow } from '@e2e/utils/db-clusters-list';
import { deleteDbClusterFn } from '@e2e/utils/db-cluster';

type AffinityRuleFormArgs = {
component?: 'DB Node' | 'Proxy' | 'Config Server';
component?: 'DB Node' | 'Proxy' | 'Router' | 'PG Bouncer' | 'Config Server';
type?: 'Node affinity' | 'Pod affinity' | 'Pod anti-affinity';
preference?: 'preferred' | 'required';
weight?: string;
Expand Down Expand Up @@ -154,7 +154,7 @@ test.describe('Affinity via wizard', () => {
values: 'val1, val2',
});
await addAffinityRule(page, {
component: 'Proxy',
component: 'Router',
type: 'Pod affinity',
preference: 'required',
topologyKey: 'my-topology-key',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const AffinityForm = () => {
operator={operator}
disableOperator={!key}
disableValue={!key}
affinityType={type}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { TextInput } from '@percona/ui-lib';
import { AffinityFormFields } from '../affinity-form.types';
import { AffinityType } from 'shared-types/affinity.types';

const KeyInput = () => (
const getHelperTextForAffinityType = (affinityType: AffinityType) => {
switch (affinityType) {
case AffinityType.NodeAffinity:
return 'A label key assigned to nodes that defines scheduling rules';
default:
return 'A label key assigned to pods that defines scheduling rules';
}
};

const KeyInput = ({ affinityType }: { affinityType: AffinityType }) => (
<TextInput
name={AffinityFormFields.key}
label="Key"
Expand All @@ -15,8 +25,7 @@ const KeyInput = () => (
sx: {
flex: '0 0 35%',
},
helperText:
'A label key on pods used to determine the targets for applying affinity or anti-affinity rules',
helperText: getHelperTextForAffinityType(affinityType),
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const TopologyKeyInput = () => (
sx: {
flex: '0 0 35%',
},
helperText:
'A label key on nodes that defines the grouping or topology scope (e.g., zone, hostname) where the rules are enforced',
helperText: 'A domain key that determines relative pod placement',
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@ import {
TopologyKeyInput,
ValueInput,
} from '../fields';
import { AffinityOperator } from 'shared-types/affinity.types';
import { AffinityOperator, AffinityType } from 'shared-types/affinity.types';

type Props = {
disableOperator: boolean;
disableValue: boolean;
operator: AffinityOperator;
showTopologyKey: boolean;
affinityType: AffinityType;
};

const RuleDetailsSection = ({
operator,
disableOperator,
disableValue,
showTopologyKey,
affinityType,
}: Props) => (
<>
<Typography variant="sectionHeading" sx={{ marginTop: '20px' }}>
Rule details
</Typography>
<Box sx={{ display: 'flex', gap: '20px' }}>
{showTopologyKey && <TopologyKeyInput />}
<KeyInput />
<KeyInput affinityType={affinityType} />
<OperatorInput disabled={disableOperator} />
</Box>
{[AffinityOperator.In, AffinityOperator.NotIn].includes(operator) && (
Expand Down

0 comments on commit f2d61b3

Please sign in to comment.