Skip to content

Commit 46a11e9

Browse files
brunozoricadrians5j
authored andcommitted
fix(api-form-builder): skip create fb on new locale if fb not installed on current locale
1 parent 485f870 commit 46a11e9

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

packages/api-form-builder-so-ddb/src/operations/form/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@ export const createFormStorageOperations = (
513513
}
514514
let latestPublishedKeys: Keys | undefined;
515515
const entityBatch = createEntityWriteBatch({
516-
entity
516+
entity,
517+
delete: [createLatestKeys(form)]
517518
});
518519

519520
for (const item of items) {

packages/api-form-builder/__tests__/forms.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Form Builder "Form" Test', () => {
4040
}
4141
});
4242

43-
test("should create a form and return it in the list of latest forms", async () => {
43+
it("should create a form and return it in the list of latest forms", async () => {
4444
const [create] = await createForm({ data: { name: "contact-us" } });
4545
const { id } = create.data.formBuilder.createForm.data;
4646

@@ -70,7 +70,7 @@ describe('Form Builder "Form" Test', () => {
7070
expect(data[0].id).toEqual(id);
7171
});
7272

73-
test("should update form and return new data from storage", async () => {
73+
it("should update form and return new data from storage", async () => {
7474
const [create] = await createForm({ data: { name: "contact-us" } });
7575
const { id } = create.data.formBuilder.createForm.data;
7676

@@ -219,7 +219,7 @@ describe('Form Builder "Form" Test', () => {
219219
expect(revisions[0].version).toEqual(2);
220220
});
221221

222-
test("should delete a form and all of its revisions", async () => {
222+
it("should delete a form and all of its revisions", async () => {
223223
const [create] = await createForm({ data: { name: "contact-us" } });
224224
const { id } = create.data.formBuilder.createForm.data;
225225

@@ -246,7 +246,7 @@ describe('Form Builder "Form" Test', () => {
246246
expect(list.data.formBuilder.listForms.data.length).toBe(0);
247247
});
248248

249-
test("should publish, add views and unpublish", async () => {
249+
it("should publish, add views and unpublish", async () => {
250250
const [create] = await createForm({ data: { name: "contact-us" } });
251251
const { id } = create.data.formBuilder.createForm.data;
252252

@@ -306,7 +306,7 @@ describe('Form Builder "Form" Test', () => {
306306
expect(latestPublished3.data.formBuilder.getPublishedForm.data.id).toEqual(id);
307307
});
308308

309-
test("should create, list and export submissions to file", async () => {
309+
it("should create, list and export submissions to file", async () => {
310310
const [create] = await createForm({ data: { name: "contact-us" } });
311311
const { id } = create.data.formBuilder.createForm.data;
312312

packages/api-form-builder/src/plugins/crud/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ export default (params: CreateFormBuilderCrudParams) => {
111111
// Once a new locale is created, we need to create a new settings entry for it.
112112
new ContextPlugin<FormBuilderContext>(async context => {
113113
context.i18n.locales.onLocaleAfterCreate.subscribe(async params => {
114+
// We don't want to auto-create the settings entry if Form Builder is not installed.
115+
// This is because the entry will be created by the app's installer.
116+
const fbIsInstalled = Boolean(await context.formBuilder.getSystemVersion());
117+
if (!fbIsInstalled) {
118+
return;
119+
}
114120
const { locale } = params;
115121
await context.i18n.withLocale(locale, async () => {
116122
return context.formBuilder.createSettings({});

0 commit comments

Comments
 (0)