mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 06:19:41 +02:00
refactor(containers): migrate create view to react [EE-2307] (#9175)
This commit is contained in:
parent
bc0050a7b4
commit
d970f0e2bc
71 changed files with 2612 additions and 1399 deletions
|
@ -0,0 +1,45 @@
|
|||
import { boolean, object, SchemaOf, string } from 'yup';
|
||||
|
||||
import { validationSchema as accessControlSchema } from '@/react/portainer/access-control/AccessControlForm/AccessControlForm.validation';
|
||||
|
||||
import { imageConfigValidation } from '@@/ImageConfigFieldset';
|
||||
|
||||
import { Values } from './BaseForm';
|
||||
import { validationSchema as portsSchema } from './PortsMappingField.validation';
|
||||
|
||||
export function validation(
|
||||
{
|
||||
isAdmin,
|
||||
isDuplicating,
|
||||
isDuplicatingPortainer,
|
||||
isDockerhubRateLimited,
|
||||
}: {
|
||||
isAdmin: boolean;
|
||||
isDuplicating: boolean | undefined;
|
||||
isDuplicatingPortainer: boolean | undefined;
|
||||
isDockerhubRateLimited: boolean;
|
||||
} = {
|
||||
isAdmin: false,
|
||||
isDuplicating: false,
|
||||
isDuplicatingPortainer: false,
|
||||
isDockerhubRateLimited: false,
|
||||
}
|
||||
): SchemaOf<Values> {
|
||||
return object({
|
||||
name: string()
|
||||
.default('')
|
||||
.test('not-duplicate-portainer', () => !isDuplicatingPortainer),
|
||||
alwaysPull: boolean().default(true),
|
||||
accessControl: accessControlSchema(isAdmin),
|
||||
autoRemove: boolean().default(false),
|
||||
enableWebhook: boolean().default(false),
|
||||
nodeName: string().default(''),
|
||||
ports: portsSchema(),
|
||||
publishAllPorts: boolean().default(false),
|
||||
image: imageConfigValidation(isDockerhubRateLimited).test(
|
||||
'duplicate-must-have-registry',
|
||||
'Duplicate is only possible when registry is selected',
|
||||
(value) => !isDuplicating || typeof value.registryId !== 'undefined'
|
||||
),
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue