From 08c4cfcec0a4c5ce3691b5dc87b243048d6a65e4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 27 Jan 2025 10:21:31 +0100 Subject: [PATCH] Validate links --- .../src/stores/builder/screenComponent.ts | 32 +++++++++++++++---- packages/types/src/ui/datasource.ts | 8 ++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/stores/builder/screenComponent.ts b/packages/builder/src/stores/builder/screenComponent.ts index d8169fdedb..aa6a854f77 100644 --- a/packages/builder/src/stores/builder/screenComponent.ts +++ b/packages/builder/src/stores/builder/screenComponent.ts @@ -6,7 +6,8 @@ import { findComponentsBySettingsType } from "@/helpers/screen" import { UIDatasourceType, Screen } from "@budibase/types" import { queries } from "./queries" import { views } from "./views" -import { featureFlag } from "@/helpers" +import { bindings, featureFlag } from "@/helpers" +import { screenComponentBindableProperties } from "./bindings" function reduceBy( key: TKey, @@ -31,14 +32,26 @@ const validationKeyByType: Record = { viewV2: "id", query: "_id", custom: null, + link: "rowId", } export const screenComponentErrors = derived( - [selectedScreen, tables, views, viewsV2, queries], - ([$selectedScreen, $tables, $views, $viewsV2, $queries]): Record< - string, - string[] - > => { + [ + selectedScreen, + tables, + views, + viewsV2, + queries, + screenComponentBindableProperties, + ], + ([ + $selectedScreen, + $tables, + $views, + $viewsV2, + $queries, + $screenComponentBindableProperties, + ]): Record => { if (!featureFlag.isEnabled("CHECK_SCREEN_COMPONENT_SETTINGS_ERRORS")) { return {} } @@ -56,6 +69,9 @@ export const screenComponentErrors = derived( const type = componentSettings.type as UIDatasourceType const validationKey = validationKeyByType[type] + if (type === "link") { + debugger + } if (!validationKey) { continue } @@ -76,6 +92,10 @@ export const screenComponentErrors = derived( ...reduceBy("name", $views.list), ...reduceBy("id", $viewsV2.list), ...reduceBy("_id", $queries.list), + ...reduceBy( + "rowId", + bindings.extractRelationships($screenComponentBindableProperties) + ), } return getInvalidDatasources($selectedScreen, datasources) diff --git a/packages/types/src/ui/datasource.ts b/packages/types/src/ui/datasource.ts index 53740e8c4d..a121d929c8 100644 --- a/packages/types/src/ui/datasource.ts +++ b/packages/types/src/ui/datasource.ts @@ -1 +1,7 @@ -export type UIDatasourceType = "table" | "view" | "viewV2" | "query" | "custom" +export type UIDatasourceType = + | "table" + | "view" + | "viewV2" + | "query" + | "custom" + | "link"