Browse Source

fix(nc-gui): ai button related changes

pull/9997/head
Ramesh Mane 3 days ago
parent
commit
4c0f06e12d
  1. 22
      packages/nc-gui/components/smartsheet/column/AiButtonOptions.vue
  2. 18
      packages/nc-gui/components/smartsheet/column/ButtonOptions.vue

22
packages/nc-gui/components/smartsheet/column/AiButtonOptions.vue

@ -32,10 +32,13 @@ const {
formattedData,
disableSubmitBtn,
tableExplorerColumns,
fromTableExplorer,
} = useColumnCreateStoreOrThrow()
const { aiIntegrationAvailable, aiLoading, aiError, generateRows } = useNocoAi()
const { isFeatureEnabled } = useBetaFeatureToggle()
const isOpenConfigModal = ref<boolean>(false)
const isOpenSelectOutputFieldDropdown = ref<boolean>(false)
@ -243,6 +246,14 @@ watch(isOpenSelectRecordDropdown, (newValue) => {
}
})
const isAiButtonEnabled = computed(() => {
if (isEdit.value) {
return true
}
return isFeatureEnabled(FEATURE_FLAG.AI_FEATURES)
})
const previewPanelDom = ref<HTMLElement>()
const isPreviewPanelOnScrollTop = ref(false)
@ -294,7 +305,7 @@ onBeforeUnmount(() => {
</script>
<template>
<div class="relative flex flex-col gap-4">
<div v-if="isAiButtonEnabled" class="relative flex flex-col gap-4">
<AiIntegrationNotFound v-if="!aiIntegrationAvailable" />
<template v-else-if="!!aiError"> </template>
<template v-else>
@ -332,6 +343,7 @@ onBeforeUnmount(() => {
</NcButton>
<NcButton
v-if="!fromTableExplorer"
size="small"
type="primary"
:disabled="disableSubmitBtn || saving"
@ -604,7 +616,7 @@ onBeforeUnmount(() => {
show-search-always
search-input-placeholder="Search records"
:item-height="60"
class="!w-auto min-w-[500px] max-w-[576px]"
class="!w-auto min-w-[550px] max-w-[550px]"
container-class-name="!px-0 !pb-0"
item-class-name="!rounded-none !p-0 !bg-none !hover:bg-none"
@update:value="handleResetOutput"
@ -691,8 +703,9 @@ onBeforeUnmount(() => {
<div class="h-2.5 w-2.5 flex-none absolute -top-[30px] border-1 border-current rounded-full bg-current"></div>
<NcTooltip :disabled="!!(selectedRecordPk && outputColumnIds.length && inputColumns.length)">
<template #title>
<div class="flex flex-col gap-2">
<div>Preview checklist</div>
<div class="flex flex-col gap-2 py-1 px-0.5">
<div class="text-[10px] leading-[14px] text-gray-300 uppercase mb-1">Preview checklist</div>
<div class="flex gap-2">
<div
class="h-4 w-4 rounded-full grid place-items-center children:(h-3.5 w-3.5 flex-none)"
@ -859,6 +872,7 @@ onBeforeUnmount(() => {
</div>
</NcModal>
</div>
<div v-else></div>
</template>
<style lang="scss">

18
packages/nc-gui/components/smartsheet/column/ButtonOptions.vue

@ -35,6 +35,8 @@ const meta = inject(MetaInj, ref())
const { isEdit, setAdditionalValidations, validateInfos, sqlUi, column, isWebhookCreateModalOpen, isAiMode } =
useColumnCreateStoreOrThrow()
const { isFeatureEnabled } = useBetaFeatureToggle()
const uiTypesNotSupportedInFormulas = [UITypes.QrCode, UITypes.Barcode, UITypes.Button]
const webhooksStore = useWebhooksStore()
@ -51,7 +53,15 @@ const manualHooks = computed(() => {
return hooks.value.filter((hook) => hook.event === 'manual' && hook.active)
})
const buttonTypes = [
const isAiButtonEnabled = computed(() => {
if (isEdit.value) {
return true
}
return isFeatureEnabled(FEATURE_FLAG.AI_FEATURES)
})
const buttonTypes = computed(() => [
{
label: t('labels.openUrl'),
value: ButtonActionsType.Url,
@ -60,7 +70,7 @@ const buttonTypes = [
label: t('labels.runWebHook'),
value: ButtonActionsType.Webhook,
},
...(isFeatureEnabled(FEATURE_FLAG.AI_FEATURES)
...(isAiButtonEnabled.value
? [
{
label: t('labels.generateFieldDataUsingAi'),
@ -69,7 +79,7 @@ const buttonTypes = [
},
]
: []),
]
])
const supportedColumns = computed(
() =>
@ -212,7 +222,7 @@ if (isEdit.value) {
vModel.value.fk_integration_id = colOptions?.fk_integration_id
}
} else {
vModel.value.type = vModel.value?.type || buttonTypes[0].value
vModel.value.type = vModel.value?.type || buttonTypes.value[0]?.value
if (vModel.value.type === ButtonActionsType.Ai) {
vModel.value.theme = 'light'

Loading…
Cancel
Save