Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): keep button disabled and show invalid tooltip

Ramesh Mane8519c36a1d3a
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Button/index.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Button/index.ts
index 38de994a10..8ec2cddbbe 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/Button/index.ts
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/Button/index.ts
@@ -248,7 +248,7 @@ export const ButtonCellRenderer: CellRenderer = {
const colOptions = column.columnObj?.colOptions as ButtonType
- if (!colOptions) return
+ if (!colOptions || !colOptions.type) return
const buttonMeta = {
label: colOptions?.label || '',
@@ -298,7 +298,10 @@ export const ButtonCellRenderer: CellRenderer = {
if (e.key === 'Enter') {
const isLoading = actionManager.isLoading(pk, column.id!)
- if (column.readonly || column.columnObj?.readonly || isLoading) return false
+ if (column.readonly || column.columnObj?.readonly || isLoading) {
+ return false
+ }
+
await actionManager.executeButtonAction([pk], column, { row: [row], path, allowLocalUrl })
return true
}
diff --git a/packages/nc-gui/components/virtual-cell/Button.vue b/packages/nc-gui/components/virtual-cell/Button.vue
index 02a2287674..a795fba97f 100644
--- a/packages/nc-gui/components/virtual-cell/Button.vue
+++ b/packages/nc-gui/components/virtual-cell/Button.vue
@@ -153,6 +153,15 @@ const componentProps = computed(() => {
generatingColumnRows.value.includes(column.value.id)),
}
}
+
+ // If button type is missing then keep it as disabled
+ if (!column.value.colOptions.type) {
+ return {
+ disabled: true,
+ }
+ }
+
+ return {}
})
const afterActionStatus = ref<{
@@ -164,6 +173,8 @@ const triggerAction = async () => {
const colOptions = column.value.colOptions
afterActionStatus.value = null
+ if (!colOptions.type) return
+
if (colOptions.type === ButtonActionsType.Url) {
confirmPageLeavingRedirect(componentProps.value?.href, componentProps.value?.target, appInfo.value?.allowLocalUrl)
} else if (colOptions.type === ButtonActionsType.Webhook) {
diff --git a/packages/nc-gui/utils/columnUtils.ts b/packages/nc-gui/utils/columnUtils.ts
index 5f1c44e894..67e58f57aa 100644
--- a/packages/nc-gui/utils/columnUtils.ts
+++ b/packages/nc-gui/utils/columnUtils.ts
@@ -339,6 +339,9 @@ const isColumnInvalid = ({
result.isInvalid = true
result.tooltip = `Input prompt has deleted column(s): ${missingIds.map((id) => id.title).join(', ')}`
}
+ } else if (!colOptions.type) {
+ result.isInvalid = true
+ result.tooltip = 'msg.invalidColumnConfiguration'
}
break
}