diff --git a/packages/frontend-core/src/components/grid/stores/config.ts b/packages/frontend-core/src/components/grid/stores/config.ts index e334b58495..2ddaf1b65c 100644 --- a/packages/frontend-core/src/components/grid/stores/config.ts +++ b/packages/frontend-core/src/components/grid/stores/config.ts @@ -69,7 +69,7 @@ export const deriveStores = (context: StoreContext): ConfigDerivedStore => { } // Disable features for non DS+ - if (!["table", "viewV2"].includes(type)) { + if (type && !["table", "viewV2"].includes(type)) { config.canAddRows = false config.canEditRows = false config.canDeleteRows = false diff --git a/packages/frontend-core/src/components/grid/stores/datasource.ts b/packages/frontend-core/src/components/grid/stores/datasource.ts index 74101701ed..fe8ff60fd3 100644 --- a/packages/frontend-core/src/components/grid/stores/datasource.ts +++ b/packages/frontend-core/src/components/grid/stores/datasource.ts @@ -74,7 +74,7 @@ export const deriveStores = (context: StoreContext): DerivedDatasourceStore => { let schema: Record = getDatasourceSchema({ API, datasource: get(datasource), - definition: $definition, + definition: $definition ?? undefined, }) if (!schema) { return null @@ -136,7 +136,7 @@ export const deriveStores = (context: StoreContext): DerivedDatasourceStore => { if (type === "viewV2" && $definition?.type === ViewV2Type.CALCULATION) { return false } - return ["table", "viewV2", "link"].includes(type) + return !!type && ["table", "viewV2", "link"].includes(type) } ) @@ -186,7 +186,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => { API, datasource: get(datasource), }) - definition.set(def) + definition.set((def as any) ?? null) } // Saves the datasource definition diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index 3afeec7684..4f4eafe8e8 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -10,7 +10,7 @@ import UserFetch from "./UserFetch.js" import GroupUserFetch from "./GroupUserFetch" import CustomFetch from "./CustomFetch" import QueryArrayFetch from "./QueryArrayFetch.js" -import { Table, UIDatasource } from "@budibase/types" +import { TableSchema, UIDatasource } from "@budibase/types" import { APIClient } from "../api/types.js" const DataFetchMap = { @@ -73,7 +73,7 @@ export const getDatasourceSchema = ({ }: { API: APIClient datasource: UIDatasource - definition: Table + definition?: { schema?: TableSchema } }) => { const instance = createEmptyFetchInstance({ API, datasource }) return instance?.getSchema(datasource, definition) diff --git a/packages/types/src/ui/stores/grid/view.ts b/packages/types/src/ui/stores/grid/view.ts index 270faaa160..f81cc34aaf 100644 --- a/packages/types/src/ui/stores/grid/view.ts +++ b/packages/types/src/ui/stores/grid/view.ts @@ -1,7 +1,6 @@ import { ViewV2 } from "@budibase/types" import { UIFieldSchema } from "./table" -export interface UIView extends Omit { - type: string +export interface UIView extends ViewV2 { schema: Record }