mirror of https://github.com/portainer/portainer
fix(app): fix wording and 2 key validation [EE-6233] (#10944)
Co-authored-by: testa113 <testa113>pull/10943/head
parent
55f66f161e
commit
cb7efd8601
|
@ -62,7 +62,7 @@ export function ConfigMapsFormSection({
|
||||||
configurations={configMaps}
|
configurations={configMaps}
|
||||||
onRemoveItem={() => onRemoveItem(index)}
|
onRemoveItem={() => onRemoveItem(index)}
|
||||||
index={index}
|
index={index}
|
||||||
dataCyType="config"
|
configurationType="ConfigMap"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
itemBuilder={() => ({
|
itemBuilder={() => ({
|
||||||
|
|
|
@ -11,7 +11,11 @@ import { isErrorType } from '@@/form-components/formikUtils';
|
||||||
import { Button } from '@@/buttons';
|
import { Button } from '@@/buttons';
|
||||||
import { TextTip } from '@@/Tip/TextTip';
|
import { TextTip } from '@@/Tip/TextTip';
|
||||||
|
|
||||||
import { ConfigurationFormValues, ConfigurationOverrideKey } from './types';
|
import {
|
||||||
|
ConfigurationFormValues,
|
||||||
|
ConfigurationOverrideKey,
|
||||||
|
ConfigurationType,
|
||||||
|
} from './types';
|
||||||
import { ConfigurationData } from './ConfigurationKey';
|
import { ConfigurationData } from './ConfigurationKey';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -21,7 +25,7 @@ type Props = {
|
||||||
configurations: Array<ConfigMap | Secret>;
|
configurations: Array<ConfigMap | Secret>;
|
||||||
index: number;
|
index: number;
|
||||||
error?: ItemError<ConfigurationFormValues>;
|
error?: ItemError<ConfigurationFormValues>;
|
||||||
dataCyType: 'config' | 'secret';
|
configurationType: ConfigurationType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ConfigurationItem({
|
export function ConfigurationItem({
|
||||||
|
@ -31,7 +35,7 @@ export function ConfigurationItem({
|
||||||
configurations,
|
configurations,
|
||||||
index,
|
index,
|
||||||
onRemoveItem,
|
onRemoveItem,
|
||||||
dataCyType,
|
configurationType,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
// rule out the error being of type string
|
// rule out the error being of type string
|
||||||
const formikError = isErrorType(error) ? error : undefined;
|
const formikError = isErrorType(error) ? error : undefined;
|
||||||
|
@ -55,7 +59,7 @@ export function ConfigurationItem({
|
||||||
)}
|
)}
|
||||||
onChange={onSelectConfigMap}
|
onChange={onSelectConfigMap}
|
||||||
size="sm"
|
size="sm"
|
||||||
data-cy={`k8sAppCreate-add${dataCyType}Select_${index}`}
|
data-cy={`k8sAppCreate-add${configurationType}Select_${index}`}
|
||||||
/>
|
/>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
{formikError?.selectedConfiguration && (
|
{formikError?.selectedConfiguration && (
|
||||||
|
@ -95,8 +99,8 @@ export function ConfigurationItem({
|
||||||
{!item.overriden && (
|
{!item.overriden && (
|
||||||
<TextTip color="blue">
|
<TextTip color="blue">
|
||||||
The following keys will be loaded from the{' '}
|
The following keys will be loaded from the{' '}
|
||||||
<code>{item.selectedConfiguration.metadata?.name}</code>
|
<code>{item.selectedConfiguration.metadata?.name}</code>{' '}
|
||||||
ConfigMap as environment variables:
|
{configurationType} as environment variables:
|
||||||
{Object.keys(configurationData).map((key, index) => (
|
{Object.keys(configurationData).map((key, index) => (
|
||||||
<span key={key}>
|
<span key={key}>
|
||||||
<code>{key}</code>
|
<code>{key}</code>
|
||||||
|
@ -116,7 +120,7 @@ export function ConfigurationItem({
|
||||||
onChange({ ...item, overridenKeys: newOverridenKeys });
|
onChange({ ...item, overridenKeys: newOverridenKeys });
|
||||||
}}
|
}}
|
||||||
overrideKeysErrors={formikError?.overridenKeys}
|
overrideKeysErrors={formikError?.overridenKeys}
|
||||||
dataCyType={dataCyType}
|
configurationType={configurationType}
|
||||||
configurationIndex={index}
|
configurationIndex={index}
|
||||||
keyIndex={keyIndex}
|
keyIndex={keyIndex}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { Button } from '@@/buttons';
|
||||||
import { FormError } from '@@/form-components/FormError';
|
import { FormError } from '@@/form-components/FormError';
|
||||||
import { isArrayErrorType } from '@@/form-components/formikUtils';
|
import { isArrayErrorType } from '@@/form-components/formikUtils';
|
||||||
|
|
||||||
import { ConfigurationOverrideKey } from './types';
|
import { ConfigurationOverrideKey, ConfigurationType } from './types';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
value: ConfigurationOverrideKey;
|
value: ConfigurationOverrideKey;
|
||||||
|
@ -18,7 +18,7 @@ type Props = {
|
||||||
| string
|
| string
|
||||||
| string[]
|
| string[]
|
||||||
| FormikErrors<ConfigurationOverrideKey>[];
|
| FormikErrors<ConfigurationOverrideKey>[];
|
||||||
dataCyType: 'config' | 'secret';
|
configurationType: ConfigurationType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ConfigurationData({
|
export function ConfigurationData({
|
||||||
|
@ -27,8 +27,10 @@ export function ConfigurationData({
|
||||||
overrideKeysErrors,
|
overrideKeysErrors,
|
||||||
configurationIndex,
|
configurationIndex,
|
||||||
keyIndex,
|
keyIndex,
|
||||||
dataCyType,
|
configurationType,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
|
const dataCyType = configurationType.toLowerCase();
|
||||||
|
|
||||||
// rule out the error (from formik) being of type string
|
// rule out the error (from formik) being of type string
|
||||||
const overriddenKeyError = isArrayErrorType(overrideKeysErrors)
|
const overriddenKeyError = isArrayErrorType(overrideKeysErrors)
|
||||||
? overrideKeysErrors[keyIndex]
|
? overrideKeysErrors[keyIndex]
|
||||||
|
|
|
@ -62,7 +62,7 @@ export function SecretsFormSection({
|
||||||
configurations={secrets}
|
configurations={secrets}
|
||||||
onRemoveItem={() => onRemoveItem(index)}
|
onRemoveItem={() => onRemoveItem(index)}
|
||||||
index={index}
|
index={index}
|
||||||
dataCyType="secret"
|
configurationType="Secret"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
itemBuilder={() => ({
|
itemBuilder={() => ({
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { SchemaOf, array, boolean, mixed, object, string } from 'yup';
|
import { SchemaOf, array, boolean, mixed, object, string } from 'yup';
|
||||||
|
|
||||||
import { buildUniquenessTest } from '@@/form-components/validate-unique';
|
|
||||||
|
|
||||||
import { ConfigurationFormValues } from './types';
|
import { ConfigurationFormValues } from './types';
|
||||||
|
|
||||||
export function configurationsValidationSchema(
|
export function configurationsValidationSchema(
|
||||||
|
@ -36,13 +34,7 @@ export function configurationsValidationSchema(
|
||||||
}),
|
}),
|
||||||
type: mixed().oneOf(['NONE', 'ENVIRONMENT', 'FILESYSTEM']),
|
type: mixed().oneOf(['NONE', 'ENVIRONMENT', 'FILESYSTEM']),
|
||||||
})
|
})
|
||||||
)
|
).required(),
|
||||||
.test(
|
|
||||||
'No duplicates',
|
|
||||||
'This path is already used.',
|
|
||||||
buildUniquenessTest(() => 'This path is already used.', 'path')
|
|
||||||
)
|
|
||||||
.required(),
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,6 @@ export type ConfigurationOverrideKey = {
|
||||||
path?: string;
|
path?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ConfigurationType = 'ConfigMap' | 'Secret';
|
||||||
|
|
||||||
type ConfigurationOverrideKeyType = 'NONE' | 'ENVIRONMENT' | 'FILESYSTEM';
|
type ConfigurationOverrideKeyType = 'NONE' | 'ENVIRONMENT' | 'FILESYSTEM';
|
||||||
|
|
Loading…
Reference in New Issue