From 152be78af699b2034c2f7a6fa89dd810115c752c Mon Sep 17 00:00:00 2001 From: Sam Mans Date: Thu, 12 Dec 2024 16:17:16 -0500 Subject: [PATCH] fix: [UIE-8338] dbaas IP validation should display updated error message that includes IPV6 --- .../features/Databases/DatabaseCreate/DatabaseCreate.tsx | 8 +++++++- .../Databases/DatabaseDetail/AddAccessControlDrawer.tsx | 6 +++++- packages/manager/src/features/Databases/constants.ts | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx b/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx index 899d5774fd0..643d94f1e16 100644 --- a/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx +++ b/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx @@ -51,6 +51,10 @@ import type { APIError } from '@linode/api-v4/lib/types'; import type { PlanSelectionWithDatabaseType } from 'src/features/components/PlansPanel/types'; import type { DatabaseCreateValues } from 'src/features/Databases/DatabaseCreate/DatabaseClusterData'; import type { ExtendedIP } from 'src/utilities/ipUtils'; +import { + ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT, + ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT_LEGACY, +} from '../constants'; const DatabaseCreate = () => { const history = useHistory(); @@ -97,7 +101,9 @@ const DatabaseCreate = () => { const handleIPValidation = () => { const validatedIps = validateIPs(values.allow_list, { allowEmptyAddress: true, - errorMessage: 'Must be a valid IPv4 address', + errorMessage: isDatabasesV2GA + ? ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT + : ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT_LEGACY, }); if (validatedIps.some((ip) => ip.error)) { diff --git a/packages/manager/src/features/Databases/DatabaseDetail/AddAccessControlDrawer.tsx b/packages/manager/src/features/Databases/DatabaseDetail/AddAccessControlDrawer.tsx index 4eab8a9c272..3fd55746724 100644 --- a/packages/manager/src/features/Databases/DatabaseDetail/AddAccessControlDrawer.tsx +++ b/packages/manager/src/features/Databases/DatabaseDetail/AddAccessControlDrawer.tsx @@ -10,6 +10,8 @@ import { MultipleIPInput } from 'src/components/MultipleIPInput/MultipleIPInput' import { ACCESS_CONTROLS_DRAWER_TEXT, ACCESS_CONTROLS_DRAWER_TEXT_LEGACY, + ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT, + ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT_LEGACY, LEARN_MORE_LINK, LEARN_MORE_LINK_LEGACY, } from 'src/features/Databases/constants'; @@ -123,7 +125,9 @@ const AddAccessControlDrawer = (props: CombinedProps) => { const onValidate = ({ _allowList }: Values) => { const validatedIPs = validateIPs(_allowList, { allowEmptyAddress: false, - errorMessage: 'Must be a valid IPv4 address.', + errorMessage: isDefaultDB + ? ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT + : ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT_LEGACY, }); setValues({ _allowList: validatedIPs }); diff --git a/packages/manager/src/features/Databases/constants.ts b/packages/manager/src/features/Databases/constants.ts index 0a8fc5e9480..b00543d8fd1 100644 --- a/packages/manager/src/features/Databases/constants.ts +++ b/packages/manager/src/features/Databases/constants.ts @@ -11,6 +11,12 @@ export const ACCESS_CONTROLS_IN_SETTINGS_TEXT = export const ACCESS_CONTROLS_IN_SETTINGS_TEXT_LEGACY = 'Add or remove IPv4 addresses or ranges that should be authorized to access your cluster.'; +export const ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT = + 'Must be a valid IPv6 or IPv4 address.'; + +export const ACCESS_CONTROLS_IP_VALIDATION_ERROR_TEXT_LEGACY = + 'Must be a valid IPv4 address.'; + export const SUSPEND_CLUSTER_TEXT = `Suspend the cluster if you don't use it temporarily to prevent being billed for it.`; export const RESET_ROOT_PASSWORD_TEXT =