From 21c335caabe6093f9f7af280ae980b4c9fb90d1a Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 26 Jun 2024 14:29:42 +0100 Subject: [PATCH] Lint and tidying up --- .../bbui/src/Tooltip/TooltipWrapper.svelte | 1 - .../SetupPanel/AutomationBlockSetup.svelte | 8 ++++---- .../SetupPanel/FieldSelector.svelte | 1 - .../automation/SetupPanel/RowSelector.svelte | 20 +++++++++---------- .../SetupPanel/RowSelectorTypes.svelte | 1 - .../server/src/automations/steps/updateRow.ts | 6 +++--- .../server/src/utilities/rowProcessor/map.ts | 1 - 7 files changed, 16 insertions(+), 22 deletions(-) diff --git a/packages/bbui/src/Tooltip/TooltipWrapper.svelte b/packages/bbui/src/Tooltip/TooltipWrapper.svelte index bddd204dea..8d12b88086 100644 --- a/packages/bbui/src/Tooltip/TooltipWrapper.svelte +++ b/packages/bbui/src/Tooltip/TooltipWrapper.svelte @@ -7,7 +7,6 @@ export let disabled = true -
{#if tooltip} diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index c120adbf8e..53f0dccef4 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -272,7 +272,7 @@ */ const onRowTriggerUpdate = async update => { if ( - update.hasOwnProperty("tableId") && + Object.hasOwn(update, "tableId") && $selectedAutomation.testData?.row?.tableId !== update.tableId ) { try { @@ -301,7 +301,7 @@ return } catch (e) { - console.error("Error saving automation", error) + console.error("Error saving automation", e) notifications.error("Error saving automation") } } @@ -328,7 +328,7 @@ // Exclude default or invalid data from the test data let updatedFields = {} for (const key of Object.keys(block?.inputs?.fields || {})) { - if (update.fields.hasOwnProperty(key)) { + if (Object.hasOwn(update.fields, key)) { if (key !== "") { updatedFields[key] = updatedAutomation.testData?.fields?.[key] } @@ -343,7 +343,7 @@ }, }) } catch (e) { - console.error("Error saving automation", error) + console.error("Error saving automation", e) notifications.error("Error saving automation") } } diff --git a/packages/builder/src/components/automation/SetupPanel/FieldSelector.svelte b/packages/builder/src/components/automation/SetupPanel/FieldSelector.svelte index 4469526e91..252705f6a0 100644 --- a/packages/builder/src/components/automation/SetupPanel/FieldSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/FieldSelector.svelte @@ -20,7 +20,6 @@ $: { let fields = {} - // DEAN - review this for (const [key, type] of Object.entries(block?.inputs?.fields ?? {})) { fields = { ...fields, diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte index 37c908c0f4..38f455b0d9 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte @@ -1,7 +1,6 @@ {#each schemaFields || [] as [field, schema]} - {#if !schema.autocolumn && editableFields.hasOwnProperty(field)} + {#if !schema.autocolumn && Object.hasOwn(editableFields, field)}
{#if isTestModal} @@ -329,9 +327,9 @@ {#if !schema.autocolumn}
  • { - if (editableFields.hasOwnProperty(field)) { + class:is-selected={Object.hasOwn(editableFields, field)} + on:click={() => { + if (Object.hasOwn(editableFields, field)) { editableFields[field] = null } else { editableFields[field] = {} diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte index a8e9eb2ddb..db19a21e0b 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte @@ -42,7 +42,6 @@ function handleAttachmentParams(keyValueObj) { let params = {} - // DEAN - review this if (!keyValueObj) { return null } diff --git a/packages/server/src/automations/steps/updateRow.ts b/packages/server/src/automations/steps/updateRow.ts index 8f8ff6879b..f8094357e0 100644 --- a/packages/server/src/automations/steps/updateRow.ts +++ b/packages/server/src/automations/steps/updateRow.ts @@ -93,7 +93,7 @@ export async function run({ inputs, appId, emitter }: AutomationStepInput) { if (isEmpty) { if ( - inputs.meta?.fields.hasOwnProperty(key) && + Object.hasOwn(inputs.meta?.fields, key) && fieldConfig?.clearRelationships === true ) { // Explicitly clear the field on update @@ -113,11 +113,11 @@ export async function run({ inputs, appId, emitter }: AutomationStepInput) { (acc: Record, key: string) => { const fieldConfig = inputs.meta?.fields?.[key] // Ignore legacy config. - if (fieldConfig.hasOwnProperty("clearRelationships")) { + if (Object.hasOwn(fieldConfig, "clearRelationships")) { return acc } acc[key] = - inputs.row.hasOwnProperty(key) && + Object.hasOwn(inputs.row, key) && (!inputs.row[key] || inputs.row[key]?.length === 0) ? null : inputs.row[key] diff --git a/packages/server/src/utilities/rowProcessor/map.ts b/packages/server/src/utilities/rowProcessor/map.ts index 6055bfb292..2e0ac9efe1 100644 --- a/packages/server/src/utilities/rowProcessor/map.ts +++ b/packages/server/src/utilities/rowProcessor/map.ts @@ -21,7 +21,6 @@ const parseArrayString = (value: any) => { */ export const TYPE_TRANSFORM_MAP: any = { [FieldType.LINK]: { - null: [], "": [], //@ts-ignore [null]: [],