Skip to content

Commit

Permalink
fix: [UIE-8338] dbaas IP validation should display updated error mess…
Browse files Browse the repository at this point in the history
…age that includes IPV6
  • Loading branch information
smans-akamai committed Dec 12, 2024
1 parent 15992df commit 152be78
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 });
Expand Down
6 changes: 6 additions & 0 deletions packages/manager/src/features/Databases/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 152be78

Please sign in to comment.