From 7ca5e0cc635fa82b2305306a0ac0217d0ab7861c Mon Sep 17 00:00:00 2001 From: Sergio Betanzos Date: Wed, 13 Jul 2022 19:15:51 +0200 Subject: [PATCH] F #5832: Add IPv6 AR no-SLAAC (#2233) --- .../components/Cards/AddressRangeCard.js | 1 + .../Forms/VNetwork/AddRangeForm/schema.js | 58 +++++++++++++++++-- .../src/client/constants/translates.js | 4 ++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/fireedge/src/client/components/Cards/AddressRangeCard.js b/src/fireedge/src/client/components/Cards/AddressRangeCard.js index 0f0fd93ecc0..7ed8f51672d 100644 --- a/src/fireedge/src/client/components/Cards/AddressRangeCard.js +++ b/src/fireedge/src/client/components/Cards/AddressRangeCard.js @@ -98,6 +98,7 @@ const AddressRangeCard = memo( return ( - [AR_TYPES.IP6, AR_TYPES.ETHER].includes(arType) && INPUT_TYPES.HIDDEN, + [AR_TYPES.IP6, AR_TYPES.IP6_STATIC, AR_TYPES.ETHER].includes(arType) && + INPUT_TYPES.HIDDEN, validation: string() .trim() .default(() => undefined) .when(TYPE_FIELD.name, { - is: (arType) => [AR_TYPES.IP6, AR_TYPES.ETHER].includes(arType), + is: (arType) => + [AR_TYPES.IP6, AR_TYPES.IP6_STATIC, AR_TYPES.ETHER].includes(arType), then: (schema) => schema.strip().notRequired(), otherwise: (schema) => schema.required().matches(REG_V4, { message: T.InvalidIPv4 }), }), } +/** @type {Field} IPv6 field */ +const IP6_FIELD = { + name: 'IP6', + label: T.FirstIPv6Address, + type: INPUT_TYPES.TEXT, + dependOf: TYPE_FIELD.name, + htmlType: (arType) => + ![AR_TYPES.IP6_STATIC, AR_TYPES.IP4_6].includes(arType) && + INPUT_TYPES.HIDDEN, + validation: string() + .trim() + .default(() => undefined) + .when(TYPE_FIELD.name, { + is: (arType) => ![AR_TYPES.IP6_STATIC, AR_TYPES.IP4_6].includes(arType), + then: (schema) => schema.strip(), + otherwise: (schema) => + schema.required().matches(REG_V6, { message: T.InvalidIPv6 }), + }), +} + +/** @type {Field} Prefix length field */ +const PREFIX_LENGTH_FIELD = { + name: 'PREFIX_LENGTH', + label: T.PrefixLength, + tooltip: T.PrefixLengthConcept, + type: INPUT_TYPES.TEXT, + dependOf: TYPE_FIELD.name, + htmlType: (arType) => AR_TYPES.IP6_STATIC !== arType && INPUT_TYPES.HIDDEN, + validation: string() + .trim() + .default(() => undefined) + .when(TYPE_FIELD.name, { + is: (arType) => AR_TYPES.IP6_STATIC !== arType, + then: (schema) => schema.strip(), + otherwise: (schema) => schema.required(), + }), +} + /** @type {Field} MAC field */ const MAC_FIELD = { name: 'MAC', @@ -137,8 +185,10 @@ const FIELDS = [ TYPE_FIELD, IP_FIELD, MAC_FIELD, + IP6_FIELD, SIZE_FIELD, GLOBAL_PREFIX_FIELD, + PREFIX_LENGTH_FIELD, ULA_PREFIX_FIELD, ] diff --git a/src/fireedge/src/client/constants/translates.js b/src/fireedge/src/client/constants/translates.js index 97582b3f99f..799d6bed5f4 100644 --- a/src/fireedge/src/client/constants/translates.js +++ b/src/fireedge/src/client/constants/translates.js @@ -892,13 +892,17 @@ module.exports = { Addresses: 'Addresses', AddressRange: 'Address Range', FirstIPv4Address: 'First IPv4 address', + FirstIPv6Address: 'First IPv6 address', FirstMacAddress: 'First MAC address', + PrefixLength: 'Prefix length', + PrefixLengthConcept: 'Length of the prefix to configure VM interfaces', SLAAC: 'SLAAC', IPv6GlobalPrefix: 'IPv6 Global prefix', IPv6ULAPrefix: 'IPv6 ULA prefix', IPAMDriver: 'IPAM driver', InvalidAddress: 'Invalid address', InvalidIPv4: 'Invalid IPv4', + InvalidIPv6: 'Invalid IPv6', InvalidMAC: 'Invalid MAC', DisabledAddressRangeInForm: 'Address Ranges need to be managed in the individual Virtual Network panel',