From 1d2d096ab0cfc41a5c72c02dc68ce5473d2ccad8 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 15 Oct 2024 10:05:03 +0100 Subject: [PATCH] PR comments --- .../table/[tableId]/[viewId]/index.svelte | 2 +- .../data/table/[tableId]/index.svelte | 3 ++- .../src/components/app/GridBlock.svelte | 2 ++ packages/client/src/stores/features.js | 6 +++++ .../src/components/FilterField.svelte | 3 ++- .../src/components/grid/layout/Grid.svelte | 4 ++-- .../grid/overlays/MenuOverlay.svelte | 16 ++++++------- .../src/components/grid/stores/columns.js | 1 + .../src/components/grid/stores/rows.js | 24 ------------------- packages/pro | 2 +- 10 files changed, 24 insertions(+), 39 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte index 448fd47ba0..9b0fe8beea 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte @@ -49,7 +49,7 @@ {buttons} allowAddRows allowDeleteRows - licensing={$licensing} + aiEnabled={$licensing.budibaseAIEnabled || $licensing.customAIConfigsEnabled} showAvatars={false} on:updatedatasource={handleGridViewUpdate} isCloud={$admin.cloud} diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/index.svelte index 3357f7ec98..69a23f3a0e 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/index.svelte @@ -125,7 +125,8 @@ schemaOverrides={isUsersTable ? userSchemaOverrides : null} showAvatars={false} isCloud={$admin.cloud} - licensing={$licensing} + aiEnabled={$licensing.budibaseAIEnabled || + $licensing.customAIConfigsEnabled} {buttons} buttonsCollapsed on:updatedatasource={handleGridTableUpdate} diff --git a/packages/client/src/components/app/GridBlock.svelte b/packages/client/src/components/app/GridBlock.svelte index 543bade382..c6b08e3869 100644 --- a/packages/client/src/components/app/GridBlock.svelte +++ b/packages/client/src/components/app/GridBlock.svelte @@ -3,6 +3,7 @@ // because it functions similarly to one import { getContext, onMount } from "svelte" import { get, derived, readable } from "svelte/store" + import { featuresStore } from "stores" import { Grid } from "@budibase/frontend-core" // table is actually any datasource, but called table for legacy compatibility @@ -186,6 +187,7 @@ {buttonsCollapsed} {buttonsCollapsedText} isCloud={$environmentStore.cloud} + aiEnabled={$featuresStore.aiEnabled} on:rowclick={e => onRowClick?.({ row: e.detail })} /> diff --git a/packages/client/src/stores/features.js b/packages/client/src/stores/features.js index 2bdc2bec1a..86c16bf344 100644 --- a/packages/client/src/stores/features.js +++ b/packages/client/src/stores/features.js @@ -2,6 +2,7 @@ import { derived } from "svelte/store" import { appStore } from "./app" import { authStore } from "./auth" import { Constants } from "@budibase/frontend-core" +import { Feature } from "@budibase/types" const createFeaturesStore = () => { return derived([authStore, appStore], ([$authStore, $appStore]) => { @@ -33,8 +34,13 @@ const createFeaturesStore = () => { } } + const license = getUserLicense() + return { logoEnabled: isFreePlan(), + aiEnabled: + license?.features?.includes(Feature.AI_CUSTOM_CONFIGS) || + license?.features?.includes(Feature.BUDIBASE_AI), } }) } diff --git a/packages/frontend-core/src/components/FilterField.svelte b/packages/frontend-core/src/components/FilterField.svelte index c763194d69..0fff774446 100644 --- a/packages/frontend-core/src/components/FilterField.svelte +++ b/packages/frontend-core/src/components/FilterField.svelte @@ -35,6 +35,7 @@ $: drawerValue = toDrawerValue(fieldValue) $: isJS = isJSBinding(fieldValue) $: fieldIsValid = isValid(fieldValue) + $: console.log(filter) const getFieldOptions = field => { const schema = schemaFields.find(x => x.name === field) @@ -174,7 +175,7 @@ /> {:else}
- {#if [FieldType.STRING, FieldType.LONGFORM, FieldType.NUMBER, FieldType.BIGINT, FieldType.FORMULA].includes(filter.type)} + {#if [FieldType.STRING, FieldType.LONGFORM, FieldType.NUMBER, FieldType.BIGINT, FieldType.FORMULA, FieldType.AI].includes(filter.type)} import { Menu, MenuItem, Helpers } from "@budibase/bbui" + import { FieldType } from "@budibase/types" import { getContext } from "svelte" import { NewRowID } from "../lib/constants" import GridPopover from "./GridPopover.svelte" @@ -26,9 +27,9 @@ $: style = makeStyle($menu) $: isNewRow = $focusedRowId === NewRowID - $: budibaseAIEnabled = - $config.licensing?.budibaseAIEnabled || - $config.licensing?.customAIConfigsEnabled + $: hasAIColumns = $visibleColumns.some( + col => col.schema.type === FieldType.AI + ) const makeStyle = menu => { return `left:${menu.left}px; top:${menu.top}px;` @@ -58,9 +59,8 @@ } const generateAIColumns = async () => { - await rows.actions.saveRow({ rowId: $focusedRowId }) - await rows.actions.refreshData() menu.actions.close() + await rows.actions.applyRowChanges({ rowId: $focusedRowId }) $notifications.success("Generated AI columns") } @@ -171,12 +171,10 @@ > Delete row - {#if budibaseAIEnabled} + {#if $config.aiEnabled} Generate AI Columns diff --git a/packages/frontend-core/src/components/grid/stores/columns.js b/packages/frontend-core/src/components/grid/stores/columns.js index 4823f2159c..f23a17f14c 100644 --- a/packages/frontend-core/src/components/grid/stores/columns.js +++ b/packages/frontend-core/src/components/grid/stores/columns.js @@ -109,6 +109,7 @@ export const createActions = context => { column.schema.autocolumn || column.schema.disabled || column.schema.type === "formula" || + column.schema.type === "ai" || column.schema.readonly ) } diff --git a/packages/frontend-core/src/components/grid/stores/rows.js b/packages/frontend-core/src/components/grid/stores/rows.js index 94fbdba5fa..4cfaa1cfd5 100644 --- a/packages/frontend-core/src/components/grid/stores/rows.js +++ b/packages/frontend-core/src/components/grid/stores/rows.js @@ -465,29 +465,6 @@ export const createActions = context => { return true } - const saveRow = async ({ rowId }) => { - const $rowLookupMap = get(rowLookupMap) - const row = $rowLookupMap[rowId] - if (row == null) { - return - } - let savedRow - - // Save row - try { - const newRow = cleanRow(row) - savedRow = await datasource.actions.updateRow(newRow) - - if (savedRow?.id) { - // Handle users table edge case - await refreshRow(savedRow.id) - } - } catch (error) { - handleValidationError(rowId, error) - } - return savedRow - } - // Saves any pending changes to a row, as well as any additional changes // specified const applyRowChanges = async ({ @@ -708,7 +685,6 @@ export const createActions = context => { ...rows, actions: { addRow, - saveRow, duplicateRow, bulkDuplicate, updateValue, diff --git a/packages/pro b/packages/pro index 69ad5e4f92..6139154961 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 69ad5e4f92b4749cd1609c0bb7feb2f3326d239c +Subproject commit 61391549614b5ac153f267633d0aaea9b07f05c5