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

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

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

Loading…
Cancel
Save