PromucFlow_constructor/app/client/src/utils/migrations/ButtonWidgetMigrations.ts
Vicky Bansal c9ec218b79
fix: change recaptcha key and type and add suggestion for recaptchaToken (#9464)
* Change recaptcha key and type and add suggestion for recaptchatoken

* Add recaptchaToken property as target for auto completion cypress tests

* Added cypress test to validate recaptcha v2 can be selected in button widget property pane

Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2022-01-02 08:27:39 -08:00

22 lines
767 B
TypeScript

import { WidgetProps } from "widgets/BaseWidget";
import { DSLWidget } from "widgets/constants";
import { RecaptchaTypes } from "components/constants";
export const migrateRecaptchaType = (currentDSL: DSLWidget): DSLWidget => {
currentDSL.children = currentDSL.children?.map((child: WidgetProps) => {
if (child.type === "BUTTON_WIDGET" || child.type === "FORM_BUTTON_WIDGET") {
const recaptchaV2 = child.recaptchaV2;
if (recaptchaV2) {
child.recaptchaType = RecaptchaTypes.V2;
} else {
child.recaptchaType = RecaptchaTypes.V3;
}
delete child.recaptchaV2;
} else if (child.children && child.children.length > 0) {
child = migrateRecaptchaType(child);
}
return child;
});
return currentDSL;
};