From 89df70890bba872bcacb3ee9f6d1a0f7cfe5f4db Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 17 Feb 2023 23:41:46 -0500 Subject: [PATCH] fix(striker-ui): ignore deprecated fields in CommonFenceInputGroup --- .../components/CommonFenceInputGroup.tsx | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/striker-ui/components/CommonFenceInputGroup.tsx b/striker-ui/components/CommonFenceInputGroup.tsx index 93a62e15..582ceacf 100644 --- a/striker-ui/components/CommonFenceInputGroup.tsx +++ b/striker-ui/components/CommonFenceInputGroup.tsx @@ -82,34 +82,40 @@ const CommonFenceInputGroup: FC = ({ { content_type: contentType, default: parameterDefault, + deprecated: rawDeprecated, options: parameterSelectOptions, - required: isRequired, + required: rawRequired, }, ], ) => { - const { optional, required } = previous; - const buildInput = - MAP_TO_INPUT_BUILDER[contentType] ?? - MAP_TO_INPUT_BUILDER.string; + const isParameterDeprecated = String(rawDeprecated) === '1'; - const fenceJoinParameterId = combineIds(fenceId, parameterId); - const initialValue = - mapToPreviousFenceParameterValues[fenceJoinParameterId] ?? - parameterDefault; - const parameterIsRequired = isRequired === '1'; - const parameterInput = buildInput({ - id: fenceJoinParameterId, - isChecked: CHECKED_STATES.includes(initialValue), - isRequired: parameterIsRequired, - label: parameterId, - selectOptions: parameterSelectOptions, - value: initialValue, - }); + if (!isParameterDeprecated) { + const { optional, required } = previous; + const buildInput = + MAP_TO_INPUT_BUILDER[contentType] ?? + MAP_TO_INPUT_BUILDER.string; + const fenceJoinParameterId = combineIds(fenceId, parameterId); - if (parameterIsRequired) { - required.push(parameterInput); - } else { - optional.push(parameterInput); + const initialValue = + mapToPreviousFenceParameterValues[fenceJoinParameterId] ?? + parameterDefault; + const isParameterRequired = String(rawRequired) === '1'; + + const parameterInput = buildInput({ + id: fenceJoinParameterId, + isChecked: CHECKED_STATES.includes(initialValue), + isRequired: isParameterRequired, + label: parameterId, + selectOptions: parameterSelectOptions, + value: initialValue, + }); + + if (isParameterRequired) { + required.push(parameterInput); + } else { + optional.push(parameterInput); + } } return previous;