Skip to content

Commit

Permalink
Merge pull request #4054 from open-formulieren/feature/4031-v1-popup
Browse files Browse the repository at this point in the history
[#4031] Add a confirm popup when switching to v2 options
  • Loading branch information
sergei-maertens authored Mar 25, 2024
2 parents 08c82d0 + f9869f1 commit 755c3e8
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ const Wrapper = ({children}) => (
const ObjectsApiOptionsFormFields = ({index, name, schema, formData, onChange}) => {
const intl = useIntl();

const v1SwitchMessage = intl.formatMessage({
defaultMessage: `Switching to the legacy registration options will remove the existing variables mapping.
Are you sure you want to continue?
`,
description: 'Objects API registration backend: v1 switch warning message',
});

const v2SwitchMessage = intl.formatMessage({
defaultMessage: `Switching to the new registration options will remove the existing JSON templates.
You will also not be able to save the form until the variables are correctly mapped.
Expand All @@ -33,6 +40,12 @@ const ObjectsApiOptionsFormFields = ({index, name, schema, formData, onChange})

const changeVersion = v => {
const realVersion = v + 1;

if (realVersion === 1) {
const confirmV1Switch = window.confirm(v1SwitchMessage);
if (!confirmV1Switch) return;
}

if (realVersion === 2) {
const confirmV2Switch = window.confirm(v2SwitchMessage);
if (!confirmV2Switch) return;
Expand Down

0 comments on commit 755c3e8

Please sign in to comment.