From 21b705d6f8866462a723eb223066a62f9f12f47a Mon Sep 17 00:00:00 2001 From: Ben Elferink Date: Mon, 23 Dec 2024 12:24:03 +0200 Subject: [PATCH 1/2] [GEN-2080]: fix useConnectDestinationForm to support additional component properties for checkboxes (#2043) This pull request focuses on replacing the `initialValue` prop with the `value` prop for the `Checkbox` component across various parts of the codebase. This change aims to standardize the usage of the `Checkbox` component and ensure consistency in its implementation. Key changes include: *Checkbox Component Update:* * [`frontend/webapp/reuseable-components/checkbox/index.tsx`](diffhunk://#diff-e3e26dd8177396b9bc7c42ef92c2501572b33fed1806496d512ed90c2539f831L12-R12): Replaced `initialValue` prop with `value` prop in the `Checkbox` component. Updated the state management and useEffect hook accordingly. [[1]](diffhunk://#diff-e3e26dd8177396b9bc7c42ef92c2501572b33fed1806496d512ed90c2539f831L12-R12) [[2]](diffhunk://#diff-e3e26dd8177396b9bc7c42ef92c2501572b33fed1806496d512ed90c2539f831L39-R41) *Usage in Forms and Fields:* * [`frontend/webapp/containers/main/actions/action-form-body/custom-fields/pii-masking.tsx`](diffhunk://#diff-1d91fa50761c80281ff07b7acecbeceb87478bdfd17634c6ee9ff0dd8905b5d5L69-R69): Updated `Checkbox` component to use `value` instead of `initialValue`. * [`frontend/webapp/containers/main/destinations/destination-form-body/dynamic-fields/index.tsx`](diffhunk://#diff-c17889e1ffea148a206f57df5da9f8cc755e7e522a9057a339f6887c01ed5815L27-R27): Updated `Checkbox` component to use `value` instead of `initialValue`. * [`frontend/webapp/containers/main/instrumentation-rules/rule-form-body/custom-fields/payload-collection.tsx`](diffhunk://#diff-e24d6b5b41b8be540f0fb09e0cc33f0d4aff8a7e61e19053129e9e1d36c845daL94-R94): Updated `Checkbox` component to use `value` instead of `initialValue`. *Usage in Source Selection:* * [`frontend/webapp/containers/main/sources/choose-sources/choose-sources-body/choose-sources-body-fast/source-controls/index.tsx`](diffhunk://#diff-9730809c6d075f90b2e6e31dc914c93f5507fc1ad62343607b690162c0af150dL37-R37): Updated `Checkbox` component to use `value` instead of `initialValue`. * [`frontend/webapp/containers/main/sources/choose-sources/choose-sources-body/choose-sources-body-fast/sources-list/index.tsx`](diffhunk://#diff-6b67649d370d208941f4e5a78c0c9de2f5b9b65fd49e0ede8ef57066982450aaL142-R142): Updated `Checkbox` component to use `value` instead of `initialValue`. [[1]](diffhunk://#diff-6b67649d370d208941f4e5a78c0c9de2f5b9b65fd49e0ede8ef57066982450aaL142-R142) [[2]](diffhunk://#diff-6b67649d370d208941f4e5a78c0c9de2f5b9b65fd49e0ede8ef57066982450aaL169-R169) *Other Updates:* * [`frontend/webapp/hooks/destinations/useConnectDestinationForm.ts`](diffhunk://#diff-ff55b24fb020911d3ee70fd88fce706bdc4348bfdebe633f7e6967f560218b4eL8-R61): Refactored the `buildFormDynamicFields` function to use the `value` prop for various input types including `CHECKBOX`. * [`frontend/webapp/reuseable-components/dropdown/index.tsx`](diffhunk://#diff-707b6e11fbf977d74c45816fab07924a0eaa2d139b296cc58b74c98fd76f463dL253-R253): Updated `Checkbox` component to use `value` instead of `initialValue` in the dropdown list item. These changes ensure that the `Checkbox` component is consistently using the `value` prop, which improves the readability and maintainability of the codebase. --- .../custom-fields/pii-masking.tsx | 2 +- .../dynamic-fields/index.tsx | 2 +- .../custom-fields/payload-collection.tsx | 2 +- .../source-controls/index.tsx | 2 +- .../sources-list/index.tsx | 4 +- .../source-controls/index.tsx | 7 +-- .../sources-list/index.tsx | 2 +- .../destinations/useConnectDestinationForm.ts | 60 +++++++++---------- .../reuseable-components/checkbox/index.tsx | 8 +-- .../reuseable-components/dropdown/index.tsx | 2 +- .../reuseable-components/input/index.tsx | 8 +-- .../monitoring-checkboxes/index.tsx | 4 +- .../nodes-data-flow/nodes/base-node.tsx | 2 +- .../nodes-data-flow/nodes/header-node.tsx | 2 +- 14 files changed, 48 insertions(+), 59 deletions(-) diff --git a/frontend/webapp/containers/main/actions/action-form-body/custom-fields/pii-masking.tsx b/frontend/webapp/containers/main/actions/action-form-body/custom-fields/pii-masking.tsx index 3a719af67..e386c8941 100644 --- a/frontend/webapp/containers/main/actions/action-form-body/custom-fields/pii-masking.tsx +++ b/frontend/webapp/containers/main/actions/action-form-body/custom-fields/pii-masking.tsx @@ -66,7 +66,7 @@ const PiiMasking: React.FC = ({ value, setValue, errorMessage }) => { {strictPicklist.map(({ id, label }) => ( - handleChange(id, bool)} /> + handleChange(id, bool)} /> ))} {!!errorMessage && {errorMessage}} diff --git a/frontend/webapp/containers/main/destinations/destination-form-body/dynamic-fields/index.tsx b/frontend/webapp/containers/main/destinations/destination-form-body/dynamic-fields/index.tsx index d7e73213d..e3c3ddff5 100644 --- a/frontend/webapp/containers/main/destinations/destination-form-body/dynamic-fields/index.tsx +++ b/frontend/webapp/containers/main/destinations/destination-form-body/dynamic-fields/index.tsx @@ -24,7 +24,7 @@ export const DestinationDynamicFields: React.FC = ({ fields, onChange, fo case INPUT_TYPES.TEXTAREA: return