Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #265 from workfloworchestrator/1903-fix-ip-prefixl…
Browse files Browse the repository at this point in the history
…ength-range-in-dropdown-orchGUI

Improved the selectable prefixlengths in dropdown
  • Loading branch information
wouter1975 authored Jan 23, 2024
2 parents dd99f3e + 1ae2f6d commit 185dc21
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/custom-surf/components/inputForms/SplitPrefix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,19 @@ export default class SplitPrefix extends React.PureComponent<IProps> {
};

render() {
// IPv4 subnet size should be between /32 and /12
// IPv6 subnet size should be between /128 and /32
const { id, name, subnet, prefixlen, prefixMin, selectedSubnet } = this.props;
const version = subnet.indexOf(":") === -1 ? 4 : 6;
const max_for_version = version === 4 ? 32 : 64;
const minPrefixLength = version === 4 ? 12 : 32;
const minimalSelectablePrefixLength = minPrefixLength > prefixMin ? minPrefixLength : prefixMin;
const maximalSelectablePrefixLength = version === 4 ? 32 : minimalSelectablePrefixLength + 12;

const { desiredPrefixlen } = this.state;
const prefixlengths = range(max_for_version - prefixMin + 1).map((x) => prefixMin + x);
const prefixlengths = range(maximalSelectablePrefixLength - minimalSelectablePrefixLength + 1).map(
(x) => minimalSelectablePrefixLength + x
);

const length_options: Option<number>[] = prefixlengths.map((pl) => ({ value: pl, label: pl.toString() }));
const length_value = length_options.find((option) => option.value === desiredPrefixlen);

Expand Down

0 comments on commit 185dc21

Please sign in to comment.