From 60d686b2bf4460ef407eb803ea4456a548f48a52 Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Fri, 12 Apr 2024 16:25:30 +0200 Subject: [PATCH] Fix aggrid 2 (#3548) * fix(frontend): Correctly handle undefined actions * fix(frontend): Correctly handle undefined actions * fix(frontend): Correctly handle undefined actions * fix(frontend): add missinng migration code --- .../settingsPanel/ComponentPanel.svelte | 2 +- .../editor/settingsPanel/TableActions.svelte | 166 ++++++++++-------- 2 files changed, 93 insertions(+), 75 deletions(-) diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentPanel.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentPanel.svelte index 8ae4b439ec..9d307dc23b 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/ComponentPanel.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/ComponentPanel.svelte @@ -365,7 +365,7 @@ bind:panes={componentSettings.item.data.panes} bind:component={componentSettings.item.data} /> - {:else if componentSettings.item.data.type === 'aggridcomponent' && Array.isArray(componentSettings.item.data.actions)} + {:else if componentSettings.item.data.type === 'aggridcomponent'} {:else if componentSettings.item.data.type === 'tablecomponent' && Array.isArray(componentSettings.item.data.actionButtons)} diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/TableActions.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/TableActions.svelte index 735f5aeeb6..8372ace64e 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/TableActions.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/TableActions.svelte @@ -3,21 +3,34 @@ import Button from '$lib/components/common/button/Button.svelte' import { getNextId } from '$lib/components/flows/idUtils' import { classNames } from '$lib/utils' - import { getContext } from 'svelte' + import { getContext, onMount } from 'svelte' import type { AppViewerContext, BaseAppComponent } from '../../types' import { appComponentFromType } from '../appUtils' import type { ButtonComponent, CheckboxComponent, SelectComponent } from '../component' import PanelSection from './common/PanelSection.svelte' import { Inspect, List, ToggleRightIcon, Trash } from 'lucide-svelte' - export let components: (BaseAppComponent & - (ButtonComponent | CheckboxComponent | SelectComponent))[] + export let components: + | (BaseAppComponent & (ButtonComponent | CheckboxComponent | SelectComponent))[] + | undefined + + // Migration code: + onMount(() => { + if (components === undefined) { + components = [] + } + }) + export let id: string const { selectedComponent, app, errorByComponent } = getContext('AppViewerContext') function addComponent(typ: 'buttoncomponent' | 'checkboxcomponent' | 'selectcomponent') { + if (!components) { + return + } + const actionId = getNextId(components.map((x) => x.id.split('_')[1])) const newComponent = { @@ -29,6 +42,9 @@ } function deleteComponent(cid: string) { + if (!components) { + return + } components = components.filter((x) => x.id !== cid) delete $errorByComponent[cid] @@ -38,77 +54,79 @@ } - - {#if components.length == 0} - No action buttons - {/if} - {#each components as component} - -
{ - $selectedComponent = [component.id] - }} - on:keypress - > - - {component.id} - +{#if components} + + {#if components.length == 0} + No action buttons + {/if} + {#each components as component} + +
{ + $selectedComponent = [component.id] + }} + on:keypress + > + + {component.id} + -
- {#if component.type == 'buttoncomponent'} - Button - {:else if component.type == 'selectcomponent'} - Select - {:else if component.type == 'checkboxcomponent'} - Toggle - {/if} -
-
-
+ {/each} +
+ + +
- {/each} -
- - - -
-
+ +{/if}