Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upcoming: [M3-9535] - Support VPC interfaces on updated Linode Create Networking flow #11847

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
attempt to improve validation layre
bnussman committed Mar 13, 2025
commit 295f00c67fd23768bef92bc325651310678e1d2b
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { yupResolver } from '@hookform/resolvers/yup';
import { isNullOrUndefined } from '@linode/utilities';
import { CreateLinodeSchema } from '@linode/validation';

import { accountQueries, regionQueries } from '@linode/queries';
import { getRegionCountryGroup, isEURegion } from 'src/utilities/formatRegion';
@@ -9,8 +8,9 @@ import {
CreateLinodeFromBackupSchema,
CreateLinodeFromMarketplaceAppSchema,
CreateLinodeFromStackScriptSchema,
CreateLinodeSchema,
} from './schemas';
import { getLinodeCreatePayload } from './utilities';
import { getInterfacesPayload } from './utilities';

import type { LinodeCreateType } from './types';
import type {
@@ -27,16 +27,15 @@ export const getLinodeCreateResolver = (
): Resolver<LinodeCreateFormValues, LinodeCreateFormContext> => {
const schema = linodeCreateResolvers[tab ?? 'OS'];
return async (values, context, options) => {
const transformedValues = getLinodeCreatePayload(
structuredClone(values),
context?.isLinodeInterfacesEnabled ?? false
values.interfaces = getInterfacesPayload(
values.interfaces,
values.private_ip
);

const { errors } = await yupResolver<LinodeCreateFormValues>(
const { errors } = await yupResolver(
schema as ObjectSchema<LinodeCreateFormValues>,
{},
{ mode: 'async', raw: true }
)(transformedValues as LinodeCreateFormValues, context, options);
)(values, context, options);

if (tab === 'Clone Linode' && !values.linode) {
(errors as FieldErrors<LinodeCreateFormValues>)['linode'] = {
15 changes: 13 additions & 2 deletions packages/manager/src/features/Linodes/LinodeCreate/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { CreateLinodeSchema } from '@linode/validation';
import { number, object } from 'yup';
import {
CreateLinodeSchema as BaseCreateLinodeSchema,
ConfigProfileInterfaceSchema,
CreateLinodeInterfaceSchema,
} from '@linode/validation';
import { array, number, object } from 'yup';

export const CreateLinodeSchema = BaseCreateLinodeSchema.concat(
object({
interfaces: array(ConfigProfileInterfaceSchema),
linodeInterfaces: array(CreateLinodeInterfaceSchema),
})
);

/**
* Extends the Linode Create schema to make backup_id required for the backups tab
Original file line number Diff line number Diff line change
@@ -302,7 +302,7 @@ export interface LinodeCreateFormValues extends CreateLinodeRequest {
/**
* Override the interfaces type of the Linode Create flow so it only has Legacy Interfaces
*/
interfaces: InterfacePayload[];
interfaces?: InterfacePayload[];
/**
* The currently selected Linode (used for the Backups and Clone tabs)
*/