From cb7efd8601f961ded065f127557321fd07a0b025 Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:01:48 +1300 Subject: [PATCH] fix(app): fix wording and 2 key validation [EE-6233] (#10944) Co-authored-by: testa113 --- .../ConfigMapsFormSection.tsx | 2 +- .../ConfigurationItem.tsx | 18 +++++++++++------- .../ConfigurationKey.tsx | 8 +++++--- .../SecretsFormSection.tsx | 2 +- .../configurationValidationSchema.ts | 10 +--------- .../ConfigurationsFormSection/types.ts | 2 ++ 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigMapsFormSection.tsx b/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigMapsFormSection.tsx index 33e68171e..fad3cdb12 100644 --- a/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigMapsFormSection.tsx +++ b/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigMapsFormSection.tsx @@ -62,7 +62,7 @@ export function ConfigMapsFormSection({ configurations={configMaps} onRemoveItem={() => onRemoveItem(index)} index={index} - dataCyType="config" + configurationType="ConfigMap" /> )} itemBuilder={() => ({ diff --git a/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigurationItem.tsx b/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigurationItem.tsx index 9d8303838..7c181c549 100644 --- a/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigurationItem.tsx +++ b/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigurationItem.tsx @@ -11,7 +11,11 @@ import { isErrorType } from '@@/form-components/formikUtils'; import { Button } from '@@/buttons'; import { TextTip } from '@@/Tip/TextTip'; -import { ConfigurationFormValues, ConfigurationOverrideKey } from './types'; +import { + ConfigurationFormValues, + ConfigurationOverrideKey, + ConfigurationType, +} from './types'; import { ConfigurationData } from './ConfigurationKey'; type Props = { @@ -21,7 +25,7 @@ type Props = { configurations: Array; index: number; error?: ItemError; - dataCyType: 'config' | 'secret'; + configurationType: ConfigurationType; }; export function ConfigurationItem({ @@ -31,7 +35,7 @@ export function ConfigurationItem({ configurations, index, onRemoveItem, - dataCyType, + configurationType, }: Props) { // rule out the error being of type string const formikError = isErrorType(error) ? error : undefined; @@ -55,7 +59,7 @@ export function ConfigurationItem({ )} onChange={onSelectConfigMap} size="sm" - data-cy={`k8sAppCreate-add${dataCyType}Select_${index}`} + data-cy={`k8sAppCreate-add${configurationType}Select_${index}`} /> {formikError?.selectedConfiguration && ( @@ -95,8 +99,8 @@ export function ConfigurationItem({ {!item.overriden && ( The following keys will be loaded from the{' '} - {item.selectedConfiguration.metadata?.name} - ConfigMap as environment variables: + {item.selectedConfiguration.metadata?.name}{' '} + {configurationType} as environment variables: {Object.keys(configurationData).map((key, index) => ( {key} @@ -116,7 +120,7 @@ export function ConfigurationItem({ onChange({ ...item, overridenKeys: newOverridenKeys }); }} overrideKeysErrors={formikError?.overridenKeys} - dataCyType={dataCyType} + configurationType={configurationType} configurationIndex={index} keyIndex={keyIndex} /> diff --git a/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigurationKey.tsx b/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigurationKey.tsx index 46045cb3b..377ff8f84 100644 --- a/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigurationKey.tsx +++ b/app/react/kubernetes/applications/components/ConfigurationsFormSection/ConfigurationKey.tsx @@ -7,7 +7,7 @@ import { Button } from '@@/buttons'; import { FormError } from '@@/form-components/FormError'; import { isArrayErrorType } from '@@/form-components/formikUtils'; -import { ConfigurationOverrideKey } from './types'; +import { ConfigurationOverrideKey, ConfigurationType } from './types'; type Props = { value: ConfigurationOverrideKey; @@ -18,7 +18,7 @@ type Props = { | string | string[] | FormikErrors[]; - dataCyType: 'config' | 'secret'; + configurationType: ConfigurationType; }; export function ConfigurationData({ @@ -27,8 +27,10 @@ export function ConfigurationData({ overrideKeysErrors, configurationIndex, keyIndex, - dataCyType, + configurationType, }: Props) { + const dataCyType = configurationType.toLowerCase(); + // rule out the error (from formik) being of type string const overriddenKeyError = isArrayErrorType(overrideKeysErrors) ? overrideKeysErrors[keyIndex] diff --git a/app/react/kubernetes/applications/components/ConfigurationsFormSection/SecretsFormSection.tsx b/app/react/kubernetes/applications/components/ConfigurationsFormSection/SecretsFormSection.tsx index 638606d88..5f47ea199 100644 --- a/app/react/kubernetes/applications/components/ConfigurationsFormSection/SecretsFormSection.tsx +++ b/app/react/kubernetes/applications/components/ConfigurationsFormSection/SecretsFormSection.tsx @@ -62,7 +62,7 @@ export function SecretsFormSection({ configurations={secrets} onRemoveItem={() => onRemoveItem(index)} index={index} - dataCyType="secret" + configurationType="Secret" /> )} itemBuilder={() => ({ diff --git a/app/react/kubernetes/applications/components/ConfigurationsFormSection/configurationValidationSchema.ts b/app/react/kubernetes/applications/components/ConfigurationsFormSection/configurationValidationSchema.ts index cf37c6666..b64a7f458 100644 --- a/app/react/kubernetes/applications/components/ConfigurationsFormSection/configurationValidationSchema.ts +++ b/app/react/kubernetes/applications/components/ConfigurationsFormSection/configurationValidationSchema.ts @@ -1,7 +1,5 @@ import { SchemaOf, array, boolean, mixed, object, string } from 'yup'; -import { buildUniquenessTest } from '@@/form-components/validate-unique'; - import { ConfigurationFormValues } from './types'; export function configurationsValidationSchema( @@ -36,13 +34,7 @@ export function configurationsValidationSchema( }), type: mixed().oneOf(['NONE', 'ENVIRONMENT', 'FILESYSTEM']), }) - ) - .test( - 'No duplicates', - 'This path is already used.', - buildUniquenessTest(() => 'This path is already used.', 'path') - ) - .required(), + ).required(), }) ); } diff --git a/app/react/kubernetes/applications/components/ConfigurationsFormSection/types.ts b/app/react/kubernetes/applications/components/ConfigurationsFormSection/types.ts index 27562fbd4..f21c7b554 100644 --- a/app/react/kubernetes/applications/components/ConfigurationsFormSection/types.ts +++ b/app/react/kubernetes/applications/components/ConfigurationsFormSection/types.ts @@ -12,4 +12,6 @@ export type ConfigurationOverrideKey = { path?: string; }; +export type ConfigurationType = 'ConfigMap' | 'Secret'; + type ConfigurationOverrideKeyType = 'NONE' | 'ENVIRONMENT' | 'FILESYSTEM';