From 91ee5be7c52e6994eb7d44d969e2e0410893f8e2 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 18 Apr 2023 11:31:19 +0100 Subject: [PATCH] Disable row import button for users table and add optional chaining to spreadsheetsocket invocations to fix tests --- .../src/components/backend/DataTable/DataTable.svelte | 4 +--- .../DataTable/buttons/sheet/SheetImportButton.svelte | 8 +++++++- packages/server/src/api/controllers/row/index.ts | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index bb5e31ff5d..720c449d01 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -39,9 +39,7 @@ {#if !isInternal} {/if} - {#if !isUsersTable} - - {/if} + diff --git a/packages/builder/src/components/backend/DataTable/buttons/sheet/SheetImportButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/sheet/SheetImportButton.svelte index 88e8e213ef..d54f00c203 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/sheet/SheetImportButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/sheet/SheetImportButton.svelte @@ -2,7 +2,13 @@ import ImportButton from "../ImportButton.svelte" import { getContext } from "svelte" + export let disabled = false + const { rows, tableId } = getContext("sheet") - + diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index 1801bcd208..f48d9bcf26 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -50,7 +50,7 @@ export async function patch(ctx: any): Promise { ctx.body = row // Notify websocket change - spreadsheetSocket.emit("row-update", { id: row._id }) + spreadsheetSocket?.emit("row-update", { id: row._id }) } catch (err) { ctx.throw(400, err) } @@ -75,7 +75,7 @@ export const save = async (ctx: any) => { ctx.body = row // Notify websocket change - spreadsheetSocket.emit("row-update", { id: row._id }) + spreadsheetSocket?.emit("row-update", { id: row._id }) } export async function fetchView(ctx: any) { const tableId = getTableId(ctx) @@ -115,7 +115,7 @@ export async function destroy(ctx: any) { for (let row of rows) { ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, row) // Notify websocket change - spreadsheetSocket.emit("row-update", { id: row._id }) + spreadsheetSocket?.emit("row-update", { id: row._id }) } } else { let resp = await quotas.addQuery(() => pickApi(tableId).destroy(ctx), { @@ -126,7 +126,7 @@ export async function destroy(ctx: any) { row = resp.row ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, row) // Notify websocket change - spreadsheetSocket.emit("row-update", { id: row._id }) + spreadsheetSocket?.emit("row-update", { id: row._id }) } ctx.status = 200 // for automations include the row that was deleted