diff --git a/packages/server/src/api/controllers/view/viewsV2.ts b/packages/server/src/api/controllers/view/viewsV2.ts index 00009ea17e..eb28883e15 100644 --- a/packages/server/src/api/controllers/view/viewsV2.ts +++ b/packages/server/src/api/controllers/view/viewsV2.ts @@ -6,6 +6,7 @@ import { UIFieldMetadata, UpdateViewRequest, ViewResponse, + ViewResponseEnriched, ViewV2, } from "@budibase/types" import { builderSocket, gridSocket } from "../../../websockets" @@ -39,9 +40,9 @@ async function parseSchema(view: CreateViewRequest) { return finalViewSchema } -export async function get(ctx: Ctx) { +export async function get(ctx: Ctx) { ctx.body = { - data: await sdk.views.get(ctx.params.viewId), + data: await sdk.views.getEnriched(ctx.params.viewId), } } diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index 9cfd2697f7..2edfd900c4 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -8,7 +8,6 @@ import { import { db as dbCore } from "@budibase/backend-core" import { cloneDeep } from "lodash" -import sdk from "../../../sdk" import * as utils from "../../../db/utils" import { isExternalTableID } from "../../../integrations/utils" @@ -64,10 +63,6 @@ export function enrichSchema( view: ViewV2, tableSchema: TableSchema ): ViewV2Enriched { - if (!sdk.views.isV2(view)) { - return view - } - let schema = cloneDeep(tableSchema) const anyViewOrder = Object.values(view.schema || {}).some( ui => ui.order != null diff --git a/packages/server/src/tests/utilities/api/viewV2.ts b/packages/server/src/tests/utilities/api/viewV2.ts index 36aa935696..53b67a23f8 100644 --- a/packages/server/src/tests/utilities/api/viewV2.ts +++ b/packages/server/src/tests/utilities/api/viewV2.ts @@ -4,9 +4,9 @@ import { ViewV2, SearchViewRowRequest, PaginatedSearchRowResponse, - ViewV2Enriched, } from "@budibase/types" import { Expectations, TestAPI } from "./base" +import sdk from "../../../sdk" export class ViewV2API extends TestAPI { create = async ( @@ -44,10 +44,10 @@ export class ViewV2API extends TestAPI { return await this._delete(`/api/v2/views/${viewId}`, { expectations: exp }) } - get = async (viewId: string, expectations?: Expectations) => { - return await this._get(`/api/v2/views/${viewId}`, { - expectations, - }) + get = async (viewId: string) => { + return await this.config.doInContext(this.config.getAppId(), () => + sdk.views.get(viewId) + ) } search = async (