mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(namespace): migrate namespace edit to react [r8s-125] (#38)
This commit is contained in:
parent
40c7742e46
commit
ce7e0d8d60
108 changed files with 3183 additions and 2194 deletions
|
@ -11,7 +11,7 @@ interface Props {
|
|||
annotations: Annotation[];
|
||||
handleAnnotationChange: (
|
||||
index: number,
|
||||
key: 'Key' | 'Value',
|
||||
key: 'key' | 'value',
|
||||
val: string
|
||||
) => void;
|
||||
removeAnnotation: (index: number) => void;
|
||||
|
@ -33,7 +33,7 @@ export function AnnotationsForm({
|
|||
return (
|
||||
<>
|
||||
{annotations.map((annotation, i) => (
|
||||
<div className="row" key={annotation.ID}>
|
||||
<div className="row" key={annotation.id}>
|
||||
<div className="form-group col-sm-4 !m-0 !pl-0">
|
||||
<div className="input-group input-group-sm">
|
||||
<span className="input-group-addon required">Key</span>
|
||||
|
@ -42,16 +42,16 @@ export function AnnotationsForm({
|
|||
type="text"
|
||||
className="form-control form-control-sm"
|
||||
placeholder={placeholder[0]}
|
||||
defaultValue={annotation.Key}
|
||||
defaultValue={annotation.key}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
handleAnnotationChange(i, 'Key', e.target.value)
|
||||
handleAnnotationChange(i, 'key', e.target.value)
|
||||
}
|
||||
data-cy={`annotation-key-${i}`}
|
||||
/>
|
||||
</div>
|
||||
{annotationErrors?.[i]?.Key && (
|
||||
{annotationErrors?.[i]?.key && (
|
||||
<FormError className="!mb-0 mt-1">
|
||||
{annotationErrors[i]?.Key}
|
||||
{annotationErrors[i]?.key}
|
||||
</FormError>
|
||||
)}
|
||||
</div>
|
||||
|
@ -63,16 +63,16 @@ export function AnnotationsForm({
|
|||
type="text"
|
||||
className="form-control form-control-sm"
|
||||
placeholder={placeholder[1]}
|
||||
defaultValue={annotation.Value}
|
||||
defaultValue={annotation.value}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
handleAnnotationChange(i, 'Value', e.target.value)
|
||||
handleAnnotationChange(i, 'value', e.target.value)
|
||||
}
|
||||
data-cy={`annotation-value-${i}`}
|
||||
/>
|
||||
</div>
|
||||
{annotationErrors?.[i]?.Value && (
|
||||
{annotationErrors?.[i]?.value && (
|
||||
<FormError className="!mb-0 mt-1">
|
||||
{annotationErrors[i]?.Value}
|
||||
{annotationErrors[i]?.value}
|
||||
</FormError>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { FormikErrors } from 'formik';
|
||||
|
||||
export interface Annotation {
|
||||
Key: string;
|
||||
Value: string;
|
||||
ID: string;
|
||||
key: string;
|
||||
value: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export type AnnotationsPayload = Record<string, string>;
|
||||
|
|
|
@ -11,12 +11,12 @@ export const annotationsSchema: SchemaOf<Annotation[]> = array(
|
|||
).test(
|
||||
'unique',
|
||||
'Duplicate keys are not allowed.',
|
||||
buildUniquenessTest(() => 'Duplicate keys are not allowed.', 'Key')
|
||||
buildUniquenessTest(() => 'Duplicate keys are not allowed.', 'key')
|
||||
);
|
||||
|
||||
function getAnnotationValidation(): SchemaOf<Annotation> {
|
||||
return object({
|
||||
Key: string()
|
||||
key: string()
|
||||
.required('Key is required.')
|
||||
.test('is-valid', (value, { createError }) => {
|
||||
if (!value) {
|
||||
|
@ -62,7 +62,7 @@ function getAnnotationValidation(): SchemaOf<Annotation> {
|
|||
}
|
||||
return true;
|
||||
}),
|
||||
Value: string().required('Value is required.'),
|
||||
ID: string().required('ID is required.'),
|
||||
value: string().required('Value is required.'),
|
||||
id: string().required('ID is required.'),
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue