PR comments

This commit is contained in:
Martin McKeaveney 2024-10-15 10:05:03 +01:00
parent 0fe61f36bb
commit 1d2d096ab0
10 changed files with 24 additions and 39 deletions

View File

@ -49,7 +49,7 @@
{buttons}
allowAddRows
allowDeleteRows
licensing={$licensing}
aiEnabled={$licensing.budibaseAIEnabled || $licensing.customAIConfigsEnabled}
showAvatars={false}
on:updatedatasource={handleGridViewUpdate}
isCloud={$admin.cloud}

View File

@ -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}

View File

@ -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 })}
/>
</div>

View File

@ -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),
}
})
}

View File

@ -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}
<div>
{#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)}
<Input
disabled={filter.noValue}
value={readableValue}

View File

@ -48,7 +48,7 @@
export let darkMode = false
export let isCloud = null
export let rowConditions = null
export let licensing = null
export let aiEnabled = false
// Unique identifier for DOM nodes inside this instance
const gridID = `grid-${Math.random().toString().slice(2)}`
@ -105,7 +105,7 @@
buttonsCollapsedText,
darkMode,
isCloud,
licensing,
aiEnabled,
rowConditions,
})

View File

@ -1,5 +1,6 @@
<script>
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")
}
</script>
@ -171,12 +171,10 @@
>
Delete row
</MenuItem>
{#if budibaseAIEnabled}
{#if $config.aiEnabled}
<MenuItem
icon="MagicWand"
disabled={isNewRow ||
!$focusedRow?._rev ||
!$hasBudibaseIdentifiers}
disabled={isNewRow || !hasAIColumns}
on:click={generateAIColumns}
>
Generate AI Columns

View File

@ -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
)
}

View File

@ -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,

@ -1 +1 @@
Subproject commit 69ad5e4f92b4749cd1609c0bb7feb2f3326d239c
Subproject commit 61391549614b5ac153f267633d0aaea9b07f05c5