Check if license key exists on AI Config page

This commit is contained in:
Peter Clement 2025-04-29 14:56:44 +01:00
parent e8b2c4dfbd
commit b773bf8e9b
3 changed files with 16 additions and 14 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { ModalContent, Body, Link } from "@budibase/bbui"
import { ModalContent, Link } from "@budibase/bbui"
import { admin } from "@/stores/portal"
export let confirmHandler: () => void
@ -8,14 +8,21 @@
<ModalContent
title="Setup BB AI"
confirmText="Go to Portal"
confirmText="Account portal"
cancelText="Cancel"
onConfirm={confirmHandler}
onCancel={cancelHandler}
>
<Body>To setup BB AI you must add a Budibase license key.</Body>
<Body>
<div>To setup BB AI you must add a Budibase license key.</div>
<div class="link-container">
To get your license key, account admins must sign up to the
<Link href={$admin.accountPortalUrl}>Budibase Account Portal</Link>
</Body>
</div>
</ModalContent>
<style>
.link-container {
margin-top: calc(var(--spacing-xl) * -1);
}
</style>

View File

@ -41,6 +41,7 @@
let modalKey: AIProviderPartial
let modalConfig: ProviderConfig
let providerKeys: AIProviderPartial[]
let hasLicenseKey: string | undefined
$: isCloud = $admin.cloud
$: providerKeys = isCloud ? [BBAI_KEY] : [BBAI_KEY, OPENAI_KEY, AZURE_KEY]
@ -164,11 +165,7 @@
}
function handleDisable(key: AIProviderPartial) {
if (
key === BBAI_KEY &&
!$admin.cloud &&
!$licensing.customAIConfigsEnabled
) {
if (key === BBAI_KEY && !$admin.cloud && !hasLicenseKey) {
portalModal.show()
return
}
@ -182,6 +179,8 @@
onMount(async () => {
try {
aiConfig = (await API.getConfig(ConfigType.AI)) as AIConfig
const licenseKeyResponse = await API.getLicenseKey()
hasLicenseKey = licenseKeyResponse?.licenseKey
} catch {
notifications.error("Error fetching AI settings")
}

View File

@ -200,9 +200,6 @@ class LicensingStore extends BudiStore<LicensingState> {
Constants.Features.APP_BUILDERS
)
const budibaseAIEnabled = features.includes(Constants.Features.BUDIBASE_AI)
const customAIConfigsEnabled = features.includes(
Constants.Features.AI_CUSTOM_CONFIGS
)
const customAppScriptsEnabled = features.includes(
Constants.Features.CUSTOM_APP_SCRIPTS
)
@ -220,7 +217,6 @@ class LicensingStore extends BudiStore<LicensingState> {
brandingEnabled,
pwaEnabled,
budibaseAIEnabled,
customAIConfigsEnabled,
scimEnabled,
environmentVariablesEnabled,
auditLogsEnabled,