Check if license key exists on AI Config page
This commit is contained in:
parent
e8b2c4dfbd
commit
b773bf8e9b
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ModalContent, Body, Link } from "@budibase/bbui"
|
import { ModalContent, Link } from "@budibase/bbui"
|
||||||
import { admin } from "@/stores/portal"
|
import { admin } from "@/stores/portal"
|
||||||
|
|
||||||
export let confirmHandler: () => void
|
export let confirmHandler: () => void
|
||||||
|
@ -8,14 +8,21 @@
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title="Setup BB AI"
|
title="Setup BB AI"
|
||||||
confirmText="Go to Portal"
|
confirmText="Account portal"
|
||||||
cancelText="Cancel"
|
cancelText="Cancel"
|
||||||
onConfirm={confirmHandler}
|
onConfirm={confirmHandler}
|
||||||
onCancel={cancelHandler}
|
onCancel={cancelHandler}
|
||||||
>
|
>
|
||||||
<Body>To setup BB AI you must add a Budibase license key.</Body>
|
<div>To setup BB AI you must add a Budibase license key.</div>
|
||||||
<Body>
|
|
||||||
|
<div class="link-container">
|
||||||
To get your license key, account admins must sign up to the
|
To get your license key, account admins must sign up to the
|
||||||
<Link href={$admin.accountPortalUrl}>Budibase Account Portal</Link>
|
<Link href={$admin.accountPortalUrl}>Budibase Account Portal</Link>
|
||||||
</Body>
|
</div>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.link-container {
|
||||||
|
margin-top: calc(var(--spacing-xl) * -1);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
let modalKey: AIProviderPartial
|
let modalKey: AIProviderPartial
|
||||||
let modalConfig: ProviderConfig
|
let modalConfig: ProviderConfig
|
||||||
let providerKeys: AIProviderPartial[]
|
let providerKeys: AIProviderPartial[]
|
||||||
|
let hasLicenseKey: string | undefined
|
||||||
|
|
||||||
$: isCloud = $admin.cloud
|
$: isCloud = $admin.cloud
|
||||||
$: providerKeys = isCloud ? [BBAI_KEY] : [BBAI_KEY, OPENAI_KEY, AZURE_KEY]
|
$: providerKeys = isCloud ? [BBAI_KEY] : [BBAI_KEY, OPENAI_KEY, AZURE_KEY]
|
||||||
|
@ -164,11 +165,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDisable(key: AIProviderPartial) {
|
function handleDisable(key: AIProviderPartial) {
|
||||||
if (
|
if (key === BBAI_KEY && !$admin.cloud && !hasLicenseKey) {
|
||||||
key === BBAI_KEY &&
|
|
||||||
!$admin.cloud &&
|
|
||||||
!$licensing.customAIConfigsEnabled
|
|
||||||
) {
|
|
||||||
portalModal.show()
|
portalModal.show()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -182,6 +179,8 @@
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
aiConfig = (await API.getConfig(ConfigType.AI)) as AIConfig
|
aiConfig = (await API.getConfig(ConfigType.AI)) as AIConfig
|
||||||
|
const licenseKeyResponse = await API.getLicenseKey()
|
||||||
|
hasLicenseKey = licenseKeyResponse?.licenseKey
|
||||||
} catch {
|
} catch {
|
||||||
notifications.error("Error fetching AI settings")
|
notifications.error("Error fetching AI settings")
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,9 +200,6 @@ class LicensingStore extends BudiStore<LicensingState> {
|
||||||
Constants.Features.APP_BUILDERS
|
Constants.Features.APP_BUILDERS
|
||||||
)
|
)
|
||||||
const budibaseAIEnabled = features.includes(Constants.Features.BUDIBASE_AI)
|
const budibaseAIEnabled = features.includes(Constants.Features.BUDIBASE_AI)
|
||||||
const customAIConfigsEnabled = features.includes(
|
|
||||||
Constants.Features.AI_CUSTOM_CONFIGS
|
|
||||||
)
|
|
||||||
const customAppScriptsEnabled = features.includes(
|
const customAppScriptsEnabled = features.includes(
|
||||||
Constants.Features.CUSTOM_APP_SCRIPTS
|
Constants.Features.CUSTOM_APP_SCRIPTS
|
||||||
)
|
)
|
||||||
|
@ -220,7 +217,6 @@ class LicensingStore extends BudiStore<LicensingState> {
|
||||||
brandingEnabled,
|
brandingEnabled,
|
||||||
pwaEnabled,
|
pwaEnabled,
|
||||||
budibaseAIEnabled,
|
budibaseAIEnabled,
|
||||||
customAIConfigsEnabled,
|
|
||||||
scimEnabled,
|
scimEnabled,
|
||||||
environmentVariablesEnabled,
|
environmentVariablesEnabled,
|
||||||
auditLogsEnabled,
|
auditLogsEnabled,
|
||||||
|
|
Loading…
Reference in New Issue