Disable row import button for users table and add optional chaining to spreadsheetsocket invocations to fix tests

This commit is contained in:
Andrew Kingston 2023-04-18 11:31:19 +01:00
parent d331072f9a
commit 91ee5be7c5
3 changed files with 12 additions and 8 deletions

View File

@ -39,9 +39,7 @@
{#if !isInternal}
<SheetRelationshipButton />
{/if}
{#if !isUsersTable}
<SheetImportButton />
{/if}
<SheetImportButton disabled={isUsersTable} />
<SheetExportButton />
<SheetFilterButton />
<SheetAddColumnModal />

View File

@ -2,7 +2,13 @@
import ImportButton from "../ImportButton.svelte"
import { getContext } from "svelte"
export let disabled = false
const { rows, tableId } = getContext("sheet")
</script>
<ImportButton tableId={$tableId} on:importrows={rows.actions.refreshData} />
<ImportButton
{disabled}
tableId={$tableId}
on:importrows={rows.actions.refreshData}
/>

View File

@ -50,7 +50,7 @@ export async function patch(ctx: any): Promise<any> {
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