mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-29 16:15:51 +00:00
fix(frontend): Correctly handle undefined actions
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
export let initializing: boolean | undefined = undefined
|
||||
export let render: boolean
|
||||
export let customCss: ComponentCustomCSS<'aggridcomponent'> | undefined = undefined
|
||||
export let actions: TableAction[] = []
|
||||
export let actions: TableAction[] | undefined = undefined
|
||||
|
||||
const context = getContext<AppViewerContext>('AppViewerContext')
|
||||
|
||||
@@ -198,7 +198,7 @@
|
||||
|
||||
function actionRenderer(params) {
|
||||
const { rowIndex, data: row } = params
|
||||
if (rowIndex === -1) {
|
||||
if (rowIndex === -1 || actions == undefined || actions.length == 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@
|
||||
: []
|
||||
|
||||
// Add the action column if actions are defined
|
||||
if (actions.length > 0) {
|
||||
if (actions && actions.length > 0) {
|
||||
columnDefs.push({
|
||||
headerName: 'Actions',
|
||||
cellRenderer: actionRenderer,
|
||||
@@ -385,7 +385,7 @@
|
||||
: []
|
||||
|
||||
// Add the action column if actions are defined
|
||||
if (actions.length > 0) {
|
||||
if (actions && actions.length > 0) {
|
||||
columnDefs.push({
|
||||
headerName: 'Actions',
|
||||
cellRenderer: actionRenderer,
|
||||
|
||||
@@ -33,9 +33,11 @@
|
||||
<div>
|
||||
<AppComponentInput bind:component={gridItem.data} {resourceOnly} />
|
||||
<div class="ml-4 mt-4">
|
||||
{#each gridItem.data.actions as actionButton (actionButton.id)}
|
||||
<AppComponentInput bind:component={actionButton.data} {resourceOnly} />
|
||||
{/each}
|
||||
{#if Array.isArray(gridItem.data.actions)}
|
||||
{#each gridItem.data.actions as actionButton (actionButton.id)}
|
||||
<AppComponentInput bind:component={actionButton.data} {resourceOnly} />
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
|
||||
@@ -89,7 +89,10 @@
|
||||
)
|
||||
}
|
||||
|
||||
if (parent.data.type === 'aggridcomponent' || parent.data.type === 'aggridcomponentee') {
|
||||
if (
|
||||
parent.data.type === 'aggridcomponent' ||
|
||||
(parent.data.type === 'aggridcomponentee' && Array.isArray(parent.data.actions))
|
||||
) {
|
||||
parent.data.actions = parent.data.actions.filter(
|
||||
(x) => x.id !== tableActionSettings?.item.id
|
||||
)
|
||||
|
||||
@@ -74,7 +74,7 @@ export function dfs(
|
||||
return [item.id, id]
|
||||
} else if (
|
||||
(item.data.type == 'aggridcomponent' || item.data.type == 'aggridcomponentee') &&
|
||||
item.data.actions.find((x) => id == x.id)
|
||||
item.data.actions?.find((x) => id == x.id)
|
||||
) {
|
||||
return [item.id, id]
|
||||
} else {
|
||||
|
||||
@@ -351,7 +351,7 @@
|
||||
bind:initializing
|
||||
componentInput={component.componentInput}
|
||||
customCss={component.customCss}
|
||||
actions={component.actions}
|
||||
actions={component.actions ?? []}
|
||||
{render}
|
||||
/>
|
||||
{:else if component.type === 'aggridcomponentee'}
|
||||
@@ -362,7 +362,7 @@
|
||||
bind:initializing
|
||||
componentInput={component.componentInput}
|
||||
customCss={component.customCss}
|
||||
actions={component.actions}
|
||||
actions={component.actions ?? []}
|
||||
{render}
|
||||
/>
|
||||
{:else if component.type === 'textcomponent'}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{#if gridItem?.data?.type === 'aggridcomponent' || gridItem?.data?.type === 'aggridcomponentee'}
|
||||
{#if gridItem?.data?.type === 'aggridcomponent' || (gridItem?.data?.type === 'aggridcomponentee' && Array.isArray(gridItem.data.actions))}
|
||||
{#each gridItem.data.actions as actionButton, index (index)}
|
||||
{#if actionButton?.id === $selectedComponentInEditor || actionButton?.id + '_transformer' === $selectedComponentInEditor}
|
||||
<InlineScriptEditorPanel
|
||||
|
||||
@@ -292,7 +292,7 @@ export function getAllScriptNames(app: App): string[] {
|
||||
}
|
||||
|
||||
if (gridItem.data.type === 'aggridcomponent' || gridItem.data.type === 'aggridcomponentee') {
|
||||
gridItem.data.actions.forEach((actionButton) => {
|
||||
gridItem.data.actions?.forEach((actionButton) => {
|
||||
if (actionButton.componentInput?.type === 'runnable') {
|
||||
if (actionButton.componentInput.runnable?.type === 'runnableByName') {
|
||||
acc.push(actionButton.componentInput.runnable.name)
|
||||
|
||||
Reference in New Issue
Block a user