Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#4031] Add a confirm popup when switching to v2 options #4054

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Comment on lines +44 to +47
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also not show the popup if variablesMapping is empty, but probably not necessary


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