Skip to content

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

fix(nc-gui): ai prompt to ai text and field default name issue in MFE

Ramesh Mane68c8c554a3eb
diff --git a/packages/nc-gui/components/smartsheet/column/ButtonOptions/index.vue b/packages/nc-gui/components/smartsheet/column/ButtonOptions/index.vue
index ca3864002e..8d69f2d517 100644
--- a/packages/nc-gui/components/smartsheet/column/ButtonOptions/index.vue
+++ b/packages/nc-gui/components/smartsheet/column/ButtonOptions/index.vue
@@ -31,7 +31,8 @@ const { getMeta } = useMetas()
const { isAiBetaFeaturesEnabled } = useNocoAi()
-const { isEdit, setAdditionalValidations, validateInfos, sqlUi, column, isAiMode } = useColumnCreateStoreOrThrow()
+const { isEdit, setAdditionalValidations, validateInfos, sqlUi, column, isAiMode, updateFieldName } =
+ useColumnCreateStoreOrThrow()
const { isRowActionsEnabled } = useActionPane()
@@ -382,6 +383,7 @@ const selectIcon = (icon: string) => {
}
const handleUpdateActionType = () => {
+ updateFieldName(true, undefined, true)
vModel.value.formula_raw = ''
}
</script>
diff --git a/packages/nc-gui/components/smartsheet/column/LongTextOptions.vue b/packages/nc-gui/components/smartsheet/column/LongTextOptions.vue
index 18ae65c961..0a0bc6fbef 100644
--- a/packages/nc-gui/components/smartsheet/column/LongTextOptions.vue
+++ b/packages/nc-gui/components/smartsheet/column/LongTextOptions.vue
@@ -21,7 +21,8 @@ const availableFields = computed(() => {
const vModel = useVModel(props, 'modelValue', emit)
-const { isEdit, setAdditionalValidations, column, formattedData, loadData, disableSubmitBtn } = useColumnCreateStoreOrThrow()
+const { isEdit, setAdditionalValidations, column, formattedData, loadData, disableSubmitBtn, updateFieldName } =
+ useColumnCreateStoreOrThrow()
const { isAiBetaFeaturesEnabled, aiIntegrationAvailable, generateRows } = useNocoAi()
@@ -157,6 +158,8 @@ const richMode = computed({
})
const handleDisableSubmitBtn = () => {
+ updateFieldName()
+
if (!isEnabledGenerateText.value) {
if (disableSubmitBtn.value) {
disableSubmitBtn.value = false
diff --git a/packages/nc-gui/components/smartsheet/column/UITypesOptionsWithSearch.vue b/packages/nc-gui/components/smartsheet/column/UITypesOptionsWithSearch.vue
index fe2808a7a6..ceeb0e3634 100644
--- a/packages/nc-gui/components/smartsheet/column/UITypesOptionsWithSearch.vue
+++ b/packages/nc-gui/components/smartsheet/column/UITypesOptionsWithSearch.vue
@@ -127,7 +127,7 @@ const { isSystem } = useColumnCreateStoreOrThrow()
'hover:bg-gray-100 cursor-pointer': !isDisabledUIType(option.name),
'bg-gray-100 nc-column-list-option-active': activeFieldIndex === index && !isDisabledUIType(option.name),
'!text-gray-400 cursor-not-allowed': isDisabledUIType(option.name),
- '!text-nc-content-purple-dark': option.name === 'AIButton' || option.name === 'AIPrompt',
+ '!text-nc-content-purple-dark': [AIButton, AIPrompt].includes(option.name),
},
]"
:data-testid="option.name"
diff --git a/packages/nc-gui/composables/useColumnCreateStore.ts b/packages/nc-gui/composables/useColumnCreateStore.ts
index c56d309861..4b7fcd310d 100644
--- a/packages/nc-gui/composables/useColumnCreateStore.ts
+++ b/packages/nc-gui/composables/useColumnCreateStore.ts
@@ -127,7 +127,7 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
const onUidtOrIdTypeChange = (preload?: Record<string, any>) => {
disableSubmitBtn.value = false
- const newTitle = updateFieldName(false)
+ const newTitle = updateFieldName(false, preload)
const colProp = sqlUi.value?.getDataTypeForUiType(formState.value as { uidt: UITypes }, idType ?? undefined) ?? {}
@@ -484,19 +484,19 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
}
}
- function updateFieldName(updateFormState = true) {
+ function updateFieldName(updateFormState = true, preload?: Record<string, any>, force = false) {
if (
formState.value?.is_ai_field ||
isEdit.value ||
!fromTableExplorer?.value ||
formState.value?.userHasChangedTitle ||
- !isColumnValid?.value?.(formState.value)
+ (!isColumnValid?.value?.(formState.value) && !force)
) {
return
}
const defaultColumnName = generateUniqueColumnName({
- formState: formState.value,
+ formState: { ...formState.value, ...(preload ?? {}) },
tableExplorerColumns: tableExplorerColumns?.value || [],
metaColumns: meta.value?.columns || [],
})
diff --git a/packages/nocodb-sdk/src/lib/UITypes.ts b/packages/nocodb-sdk/src/lib/UITypes.ts
index fe090b5fa4..44060b3258 100644
--- a/packages/nocodb-sdk/src/lib/UITypes.ts
+++ b/packages/nocodb-sdk/src/lib/UITypes.ts
@@ -99,7 +99,7 @@ export const UITypesName = {
[UITypes.CreatedBy]: 'Created by',
[UITypes.LastModifiedBy]: 'Last modified by',
AIButton: 'AI Button',
- AIPrompt: 'AI Prompt',
+ AIPrompt: 'AI Text',
};
export const UITypesSearchTerms = {
@@ -230,7 +230,7 @@ export const UITypesSearchTerms = {
'who changed',
],
AIButton: ['AI Button', 'AI action', 'smart button'],
- AIPrompt: ['AI Prompt', 'AI field', 'smart field'],
+ AIPrompt: ['AI Text', 'AI Prompt', 'AI field', 'smart field'],
};
export const columnTypeName = (column?: ColumnType) => {