fix(striker-ui): ignore deprecated fields in CommonFenceInputGroup

main
Tsu-ba-me 2 years ago
parent 2aedc2e74a
commit e755ae4fe8
  1. 16
      striker-ui/components/CommonFenceInputGroup.tsx

@ -82,35 +82,41 @@ const CommonFenceInputGroup: FC<CommonFenceInputGroupProps> = ({
{
content_type: contentType,
default: parameterDefault,
deprecated: rawDeprecated,
options: parameterSelectOptions,
required: isRequired,
required: rawRequired,
},
],
) => {
const isParameterDeprecated = String(rawDeprecated) === '1';
if (!isParameterDeprecated) {
const { optional, required } = previous;
const buildInput =
MAP_TO_INPUT_BUILDER[contentType] ??
MAP_TO_INPUT_BUILDER.string;
const fenceJoinParameterId = combineIds(fenceId, parameterId);
const initialValue =
mapToPreviousFenceParameterValues[fenceJoinParameterId] ??
parameterDefault;
const parameterIsRequired = isRequired === '1';
const isParameterRequired = String(rawRequired) === '1';
const parameterInput = buildInput({
id: fenceJoinParameterId,
isChecked: CHECKED_STATES.includes(initialValue),
isRequired: parameterIsRequired,
isRequired: isParameterRequired,
label: parameterId,
selectOptions: parameterSelectOptions,
value: initialValue,
});
if (parameterIsRequired) {
if (isParameterRequired) {
required.push(parameterInput);
} else {
optional.push(parameterInput);
}
}
return previous;
},

Loading…
Cancel
Save