Skip to content

Commit 57b0c13

Browse files
Improved the selectable prefixlengths in dropdown (#653)
1 parent 7cc68c0 commit 57b0c13

File tree

1 file changed

+11
-4
lines changed
  • packages/orchestrator-ui-components/src/components/WfoForms/formFields

1 file changed

+11
-4
lines changed

packages/orchestrator-ui-components/src/components/WfoForms/formFields/SplitPrefix.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,22 @@ export default class SplitPrefix extends React.PureComponent<IProps> {
9898
};
9999

100100
render() {
101+
// IPv4 subnet size should be between /32 and /12
102+
// IPv6 subnet size should be between /128 and /32
101103
const { id, name, subnet, prefixlen, prefixMin, selectedSubnet } =
102104
this.props;
103105
const version = subnet.indexOf(':') === -1 ? 4 : 6;
104-
const max_for_version = version === 4 ? 32 : prefixMin + 11;
106+
const minPrefixLength = version === 4 ? 12 : 32;
107+
const minimalSelectablePrefixLength =
108+
minPrefixLength > prefixMin ? minPrefixLength : prefixMin;
109+
const maximalSelectablePrefixLength =
110+
version === 4 ? 32 : minimalSelectablePrefixLength + 12;
105111

106112
const { desiredPrefixlen } = this.state;
107-
const prefixlengths = range(max_for_version - prefixMin + 1).map(
108-
(x) => prefixMin + x,
109-
);
113+
const prefixlengths = range(
114+
maximalSelectablePrefixLength - minimalSelectablePrefixLength + 1,
115+
).map((x) => minimalSelectablePrefixLength + x);
116+
110117
const length_options: Option<number>[] = prefixlengths.map((pl) => ({
111118
value: pl,
112119
label: pl.toString(),

0 commit comments

Comments
 (0)