diff --git a/packages/server/src/api/routes/tests/rowAction.spec.ts b/packages/server/src/api/routes/tests/rowAction.spec.ts index b2f322c01f..e459c45185 100644 --- a/packages/server/src/api/routes/tests/rowAction.spec.ts +++ b/packages/server/src/api/routes/tests/rowAction.spec.ts @@ -90,7 +90,12 @@ describe("/rowsActions", () => { expect(res).toEqual({ _id: `${tableId}_row_actions`, _rev: expect.stringMatching(/^1-\w+/), - actions: [{ name: rowAction.name }], + actions: [ + { + id: expect.any(String), + name: rowAction.name, + }, + ], tableId: tableId, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), @@ -107,7 +112,10 @@ describe("/rowsActions", () => { expect(res).toEqual({ _id: `${tableId}_row_actions`, _rev: expect.stringMatching(/^3-\w+/), - actions: rowActions, + actions: rowActions.map(a => ({ + id: expect.any(String), + ...a, + })), tableId: tableId, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), @@ -129,7 +137,12 @@ describe("/rowsActions", () => { expect(res1).toEqual({ _id: `${tableId}_row_actions`, _rev: expect.stringMatching(/^1-\w+/), - actions: [rowAction1], + actions: [ + { + id: expect.any(String), + ...rowAction1, + }, + ], tableId: tableId, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), @@ -138,7 +151,12 @@ describe("/rowsActions", () => { expect(res2).toEqual({ _id: `${otherTableId}_row_actions`, _rev: expect.stringMatching(/^1-\w+/), - actions: [rowAction2], + actions: [ + { + id: expect.any(String), + ...rowAction2, + }, + ], tableId: otherTableId, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), @@ -178,7 +196,10 @@ describe("/rowsActions", () => { expect(response).toEqual( expect.objectContaining({ tableId, - actions: rowActions, + actions: rowActions.map(a => ({ + id: expect.any(String), + ...a, + })), }) ) }) diff --git a/packages/server/src/sdk/app/rowActions.ts b/packages/server/src/sdk/app/rowActions.ts index 6d1a98d052..c283c183b8 100644 --- a/packages/server/src/sdk/app/rowActions.ts +++ b/packages/server/src/sdk/app/rowActions.ts @@ -1,4 +1,4 @@ -import { context } from "@budibase/backend-core" +import { context, utils } from "@budibase/backend-core" import { generateRowActionsID } from "../../db/utils" import { TableRowActions } from "@budibase/types" @@ -17,7 +17,10 @@ export async function create(tableId: string, rowAction: { name: string }) { doc = { _id: rowActionsId, actions: [] } } - doc.actions.push(rowAction) + doc.actions.push({ + id: utils.newid(), + ...rowAction, + }) await db.put(doc) return await get(tableId) diff --git a/packages/types/src/api/web/app/rowAction.ts b/packages/types/src/api/web/app/rowAction.ts index fd42de20f8..dc2731f9b6 100644 --- a/packages/types/src/api/web/app/rowAction.ts +++ b/packages/types/src/api/web/app/rowAction.ts @@ -5,6 +5,7 @@ export interface CreateRowActionRequest { export interface RowActionsResponse { tableId: string actions: { + id: string name: string }[] } diff --git a/packages/types/src/documents/app/rowActions.ts b/packages/types/src/documents/app/rowActions.ts index d6dea34f2e..5eaf5de5d6 100644 --- a/packages/types/src/documents/app/rowActions.ts +++ b/packages/types/src/documents/app/rowActions.ts @@ -3,6 +3,7 @@ import { Document } from "../document" export interface TableRowActions extends Document { _id: string actions: { + id: string name: string }[] }