mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 06:49:40 +02:00
fix(app): remove canUndo function from environment variables [EE-6232] (#10961)
Co-authored-by: testa113 <testa113>
This commit is contained in:
parent
a8e53a4510
commit
787c7ec4cc
4 changed files with 50 additions and 26 deletions
|
@ -0,0 +1,30 @@
|
|||
import { FormSection } from '@@/form-components/FormSection';
|
||||
import {
|
||||
EnvVarValues,
|
||||
EnvironmentVariablesFieldset,
|
||||
} from '@@/form-components/EnvironmentVariablesFieldset';
|
||||
import { ArrayError } from '@@/form-components/InputList/InputList';
|
||||
|
||||
type Props = {
|
||||
values: EnvVarValues;
|
||||
onChange(value: EnvVarValues): void;
|
||||
errors?: ArrayError<EnvVarValues>;
|
||||
};
|
||||
|
||||
export function EnvironmentVariablesFormSection({
|
||||
values,
|
||||
onChange,
|
||||
errors,
|
||||
}: Props) {
|
||||
return (
|
||||
<FormSection title="Environment variables" titleSize="sm">
|
||||
<div className="mb-4">
|
||||
<EnvironmentVariablesFieldset
|
||||
values={values}
|
||||
onChange={onChange}
|
||||
errors={errors}
|
||||
/>
|
||||
</div>
|
||||
</FormSection>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import { SchemaOf, array, bool, object, string } from 'yup';
|
||||
|
||||
import { EnvVar } from '@@/form-components/EnvironmentVariablesFieldset/types';
|
||||
import { buildUniquenessTest } from '@@/form-components/validate-unique';
|
||||
|
||||
export function kubeEnvVarValidationSchema(): SchemaOf<EnvVar[]> {
|
||||
return array(
|
||||
object({
|
||||
name: string()
|
||||
.required('Environment variable name is required')
|
||||
.matches(
|
||||
/^[a-zA-Z][a-zA-Z0-9_.-]*$/,
|
||||
`This field must consist of alphabetic characters, digits, '_', '-', or '.', and must not start with a digit (e.g. 'my.env-name', or 'MY_ENV.NAME', or 'MyEnvName1'`
|
||||
),
|
||||
value: string().default(''),
|
||||
needsDeletion: bool().default(false),
|
||||
isNew: bool().default(false),
|
||||
})
|
||||
).test(
|
||||
'unique',
|
||||
'This environment variable is already defined',
|
||||
buildUniquenessTest(
|
||||
() => 'This environment variable is already defined',
|
||||
'name'
|
||||
)
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue