Skip to content

Commit

Permalink
🐛 Fix default version handling for Objects API registration
Browse files Browse the repository at this point in the history
Because the `version` configuration option was absent for freshly
added registration backends, you can't immediately configure them in
the variables table unless you save the form first and then edit it.

Another crash has been observed where doing the above resulted in the
variables table not rendering (crashing), but I wasn't able to
reproduce this. I suspect it's because the variablesMapping config
option was undefined or null which may happen because of toggling
between v1/v2.

A fix worth backporting, but no need for urgent hotfix releases since
you can work around it by saving the form after adding the registration
backend, and then finishing the registration configuration in the
variables table.
  • Loading branch information
sergei-maertens committed Jan 17, 2025
1 parent 5ca4ffd commit 226f1b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const ObjectsApiOptionsForm = ({index, name, label, schema, formData, onChange})
/>
}
initialFormData={{
version: 2, // default to version 2, existing form data can override this
variablesMapping: [],
...formData,
// Ensure that if there's only one option, it is automatically selected.
objectsApiGroup: formData.objectsApiGroup ?? defaultGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const INDEX_TO_VERSION_MAP = Object.fromEntries(

const ObjectsApiOptionsFormFields = ({name, apiGroupChoices}) => {
const intl = useIntl();
const {values, setValues} = useFormikContext();
const {values, setValues, initialValues} = useFormikContext();
const validationErrors = useContext(ValidationErrorContext);
const {version = 2} = values;

Expand Down

0 comments on commit 226f1b3

Please sign in to comment.