Skip to content

Commit c057d76

Browse files
authored
Show workspace settings modal if clicked on deactivated AI field (baserow#4138)
1 parent 8b10d99 commit c057d76

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"type": "feature",
3+
"message": "Show workspace settings modal if clicked on deactivated AI field.",
4+
"domain": "database",
5+
"issue_number": null,
6+
"bullet_points": [],
7+
"created_at": "2025-10-29"
8+
}

premium/web-frontend/modules/baserow_premium/fieldTypes.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import PremiumFeatures from '@baserow_premium/features'
1313
import PaidFeaturesModal from '@baserow_premium/components/PaidFeaturesModal'
1414
import { AIPaidFeature } from '@baserow_premium/paidFeatures'
1515
import _ from 'lodash'
16+
import WorkspaceSettingsModal from '@baserow/modules/core/components/workspace/WorkspaceSettingsModal.vue'
1617

1718
export class AIFieldType extends FieldType {
1819
static getType() {
@@ -204,6 +205,14 @@ export class AIFieldType extends FieldType {
204205
)
205206
}
206207

208+
getDisabledClickModal(workspace) {
209+
return [WorkspaceSettingsModal, { workspace }]
210+
}
211+
212+
getDisabledTooltip() {
213+
return 'Click to configure API key'
214+
}
215+
207216
isDeactivated(workspaceId) {
208217
return !this.app.$hasFeature(PremiumFeatures.PREMIUM, workspaceId)
209218
}

premium/web-frontend/modules/baserow_premium/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@
350350
"label": "Prompt",
351351
"labelDescription": "Describe the formula you would like to generate",
352352
"generate": "Generate",
353-
"noModels": "Your Baserow instance and workspace doesn't have any AI models configured. Click on the three dots next to your workspace, then on settings to configure them."
353+
"noModels": "Your Baserow instance and workspace doesn't have any AI models configured. Navigate to the homepage, click on the name of your workspace, then on settings to configure them."
354354
},
355355
"formulaFieldAI": {
356356
"generateWithAI": "Generate using AI",

web-frontend/modules/database/components/field/FieldForm.vue

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
<DropdownItem
4141
v-for="(fieldType, type) in fieldTypes"
4242
:key="type"
43+
v-tooltip="
44+
!fieldType.isDeactivated(workspace.id) &&
45+
!fieldType.isEnabled(workspace)
46+
? fieldType.getDisabledTooltip(workspace)
47+
: null
48+
"
49+
tooltip-position="top"
4350
:icon="fieldType.iconClass"
4451
:name="fieldType.getName()"
4552
:alias="fieldType.getAlias()"
@@ -49,7 +56,7 @@
4956
!fieldType.isEnabled(workspace) ||
5057
fieldType.isDeactivated(workspace.id)
5158
"
52-
@click="clickOnDeactivatedItem($event, fieldType)"
59+
@click="clickOnItem($event, fieldType)"
5360
>
5461
<i class="select__item-icon" :class="fieldType.iconClass" />
5562
<span
@@ -79,6 +86,24 @@
7986
"
8087
:workspace="workspace"
8188
></component>
89+
<component
90+
:is="
91+
fieldType.getDisabledClickModal(workspace)
92+
? fieldType.getDisabledClickModal(workspace)[0]
93+
: null
94+
"
95+
:ref="'disabledClickModal-' + fieldType.type"
96+
:v-if="
97+
!fieldType.isEnabled(workspace) &&
98+
fieldType.getDisabledClickModal(workspace)
99+
"
100+
v-bind="
101+
fieldType.getDisabledClickModal(workspace)
102+
? fieldType.getDisabledClickModal(workspace)[1]
103+
: null
104+
"
105+
:workspace="workspace"
106+
></component>
82107
</DropdownItem>
83108
</Dropdown>
84109

@@ -394,9 +419,11 @@ export default {
394419
this.$emit('keydown-enter')
395420
this.submit()
396421
},
397-
clickOnDeactivatedItem(event, fieldType) {
422+
clickOnItem(event, fieldType) {
398423
if (fieldType.isDeactivated(this.workspace.id)) {
399424
this.$refs[`deactivatedClickModal-${fieldType.type}`][0].show()
425+
} else if (!fieldType.isEnabled(this.workspace)) {
426+
this.$refs[`disabledClickModal-${fieldType.type}`][0].show()
400427
}
401428
},
402429
/**

web-frontend/modules/database/fieldTypes.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,21 @@ export class FieldType extends Registerable {
964964
return true
965965
}
966966

967+
/**
968+
* Can return a modal vue component that's opened when the user clicks in this
969+
* field type, but `isEnabled` is false. Should return [component, props as {}]
970+
*/
971+
getDisabledClickModal(workspace) {
972+
return null
973+
}
974+
975+
/**
976+
* Can return a tooltip text that's shown on hover when the `isEnabled` is False.
977+
*/
978+
getDisabledTooltip(workspace) {
979+
return null
980+
}
981+
967982
/**
968983
* Indicates whether the field is visible, but in a deactivated state.
969984
*/

0 commit comments

Comments
 (0)