diff --git a/packages/builder/src/components/design/settings/controls/DataSourceSelect.svelte b/packages/builder/src/components/design/settings/controls/DataSourceSelect.svelte index 6da1bd6187..69249d3ba5 100644 --- a/packages/builder/src/components/design/settings/controls/DataSourceSelect.svelte +++ b/packages/builder/src/components/design/settings/controls/DataSourceSelect.svelte @@ -39,15 +39,33 @@ tableId: m._id, type: "table", })) - $: views = $tablesStore.list.reduce((acc, cur) => { - let viewsArr = Object.entries(cur.views || {}).map(([key, value]) => ({ - label: key, - name: key, - ...value, - type: "view", - })) - return [...acc, ...viewsArr] - }, []) + $: viewsV1 = $tablesStore.list.reduce( + (acc, table) => [ + ...acc, + ...Object.values(table.views || {}) + .filter(view => view.version !== 2) + .map(view => ({ + ...view, + label: view.name, + type: "view", + })), + ], + [] + ) + $: viewsV2 = $tablesStore.list.reduce( + (acc, table) => [ + ...acc, + ...Object.values(table.views || {}) + .filter(view => view.version === 2) + .map(view => ({ + ...view, + label: view.name, + type: "viewV2", + })), + ], + [] + ) + $: views = [...(viewsV1 || []), ...(viewsV2 || [])] $: queries = $queriesStore.list .filter(q => showAllQueries || q.queryVerb === "read" || q.readable) .map(query => ({ diff --git a/packages/client/src/utils/schema.js b/packages/client/src/utils/schema.js index e450c516d7..800e9b9be1 100644 --- a/packages/client/src/utils/schema.js +++ b/packages/client/src/utils/schema.js @@ -6,6 +6,7 @@ import RelationshipFetch from "@budibase/frontend-core/src/fetch/RelationshipFet import NestedProviderFetch from "@budibase/frontend-core/src/fetch/NestedProviderFetch.js" import FieldFetch from "@budibase/frontend-core/src/fetch/FieldFetch.js" import JSONArrayFetch from "@budibase/frontend-core/src/fetch/JSONArrayFetch.js" +import ViewV2Fetch from "@budibase/frontend-core/src/fetch/ViewV2Fetch.js" /** * Fetches the schema of any kind of datasource. @@ -21,6 +22,7 @@ export const fetchDatasourceSchema = async ( const handler = { table: TableFetch, view: ViewFetch, + viewV2: ViewV2Fetch, query: QueryFetch, link: RelationshipFetch, provider: NestedProviderFetch, diff --git a/packages/frontend-core/src/fetch/ViewV2Fetch.js b/packages/frontend-core/src/fetch/ViewV2Fetch.js index 3b8e432cd0..83af9453ca 100644 --- a/packages/frontend-core/src/fetch/ViewV2Fetch.js +++ b/packages/frontend-core/src/fetch/ViewV2Fetch.js @@ -13,7 +13,7 @@ export default class ViewV2Fetch extends DataFetch { } } - async getSchema(datasource, definition) { + getSchema(datasource, definition) { return definition?.schema }