diff --git a/packages/builder/src/pages/builder/portal/settings/ai/AIConfigTile.svelte b/packages/builder/src/pages/builder/portal/settings/ai/AIConfigTile.svelte index d7688835c3..b9170dd558 100644 --- a/packages/builder/src/pages/builder/portal/settings/ai/AIConfigTile.svelte +++ b/packages/builder/src/pages/builder/portal/settings/ai/AIConfigTile.svelte @@ -1,65 +1,57 @@ - - -
-
- +
+
+
+ +
+
+ {config.name} +
+
+ {#if config.active} +
Enabled
+ {:else} +
Disabled
+ {/if} +
-
- {config.provider} - -
-
- {#if config.name !== "Budibase AI"} - - - {/if} - {#if config.active} -
Activated
- {:else if !config.active} -
Disabled
- {/if} - {#if config.isDefault} -
Default
+
+ {#if config.provider === "BudibaseAI"} + {#if config.active} + disableHandler && disableHandler()}> + Disable + + {:else} + editHandler && editHandler()}> + Enable + + {/if} + {:else} + + editHandler && editHandler()}> + {#if config.apiKey}Edit{:else}Set up{/if} + {/if}
@@ -71,10 +63,16 @@ padding: 16px; border-radius: 4px; cursor: pointer; - display: grid; - grid-template-columns: 6% 1fr auto; - grid-gap: 20px; + display: flex; align-items: center; + justify-content: space-between; + gap: 12px; + } + + .details { + display: flex; + align-items: center; + gap: 12px; } .option :global(label) { @@ -87,12 +85,13 @@ .header { align-items: center; + color: var(--spectrum-global-color-gray-900); } .icon { - background-color: white; - height: 38px; - width: 38px; + background-color: var(--spectrum-global-color-gray-200); + height: 40px; + width: 40px; display: flex; justify-content: center; align-items: center; @@ -103,33 +102,21 @@ pointer-events: none; } - .controls { - display: grid; - grid-auto-flow: column; - grid-gap: 10px; - align-items: center; - } - .tag { - display: flex; - color: #ffffff; padding: 4px 8px; justify-content: center; align-items: center; gap: 8px; font-size: 12px; border-radius: 5px; - } - - .default { - background: var(--grey-6); + color: #fff; } .active { - background: var(--spectrum-global-color-green-600); + background: #004c2e; } .disabled { - background: var(--spectrum-global-color-red-600); + background: var(--grey-3); } diff --git a/packages/builder/src/pages/builder/portal/settings/ai/AISettings.spec.js b/packages/builder/src/pages/builder/portal/settings/ai/AISettings.spec.js index 35f8859cd5..f6e579f7fc 100644 --- a/packages/builder/src/pages/builder/portal/settings/ai/AISettings.spec.js +++ b/packages/builder/src/pages/builder/portal/settings/ai/AISettings.spec.js @@ -56,66 +56,18 @@ describe("AISettings", () => { expect(instance).toBeDefined() }) - describe("Licensing", () => { - it("should show the premium label on self host for custom configs", async () => { - setupEnv(Hosting.Self) - setupDOM() - const premiumTag = instance.queryByText("Premium") - expect(premiumTag).toBeInTheDocument() - }) - - it("should show the enterprise label on cloud for custom configs", async () => { - setupEnv(Hosting.Cloud) - setupDOM() - const enterpriseTag = instance.queryByText("Enterprise") - expect(enterpriseTag).toBeInTheDocument() - }) - - it("the add configuration button should not do anything the user doesn't have the correct license on cloud", async () => { - let addConfigurationButton + describe("DOM Render tests", () => { + it("the enable bb ai button should not do anything if the user doesn't have the correct license on self host", async () => { + let addAiButton let configModal - setupEnv(Hosting.Cloud) + setupEnv(Hosting.Self, { customAIConfigsEnabled: false }) setupDOM() - addConfigurationButton = instance.queryByText("Add configuration") - expect(addConfigurationButton).toBeInTheDocument() - await fireEvent.click(addConfigurationButton) + addAiButton = instance.queryByText("Enable BB AI") + expect(addAiButton).toBeInTheDocument() + await fireEvent.click(addAiButton) configModal = instance.queryByText("Custom AI Configuration") expect(configModal).not.toBeInTheDocument() }) - - it("the add configuration button should open the config modal if the user has the correct license on cloud", async () => { - let addConfigurationButton - let configModal - - setupEnv( - Hosting.Cloud, - { customAIConfigsEnabled: true }, - { AI_CUSTOM_CONFIGS: true } - ) - setupDOM() - addConfigurationButton = instance.queryByText("Add configuration") - expect(addConfigurationButton).toBeInTheDocument() - await fireEvent.click(addConfigurationButton) - configModal = instance.queryByText("Custom AI Configuration") - expect(configModal).toBeInTheDocument() - }) - - it("the add configuration button should open the config modal if the user has the correct license on self host", async () => { - let addConfigurationButton - let configModal - - setupEnv( - Hosting.Self, - { customAIConfigsEnabled: true }, - { AI_CUSTOM_CONFIGS: true } - ) - setupDOM() - addConfigurationButton = instance.queryByText("Add configuration") - expect(addConfigurationButton).toBeInTheDocument() - await fireEvent.click(addConfigurationButton) - configModal = instance.queryByText("Custom AI Configuration") - expect(configModal).toBeInTheDocument() - }) }) }) diff --git a/packages/builder/src/pages/builder/portal/settings/ai/ConfigModal.svelte b/packages/builder/src/pages/builder/portal/settings/ai/ConfigModal.svelte index 26e7a1606c..ac6c578a1a 100644 --- a/packages/builder/src/pages/builder/portal/settings/ai/ConfigModal.svelte +++ b/packages/builder/src/pages/builder/portal/settings/ai/ConfigModal.svelte @@ -1,76 +1,42 @@ - updateHandler(config) + : () => enableHandler(config)} + onCancel={isEnabled + ? () => disableHandler(config) + : () => updateHandler(config)} + disabled={!complete} size="M" - title="Custom AI Configuration" + title={`Set up ${config.name}`} >
- - -
-
- - {#if config.provider !== Providers.Custom.name} - - {/if} + +
@@ -80,13 +46,14 @@ bind:value={config.baseUrl} />
+
- - -
-
- - + +