Validate links

This commit is contained in:
Adria Navarro 2025-01-27 10:21:31 +01:00
parent 5f3aaf458b
commit 08c4cfcec0
2 changed files with 33 additions and 7 deletions

View File

@ -6,7 +6,8 @@ import { findComponentsBySettingsType } from "@/helpers/screen"
import { UIDatasourceType, Screen } from "@budibase/types" import { UIDatasourceType, Screen } from "@budibase/types"
import { queries } from "./queries" import { queries } from "./queries"
import { views } from "./views" import { views } from "./views"
import { featureFlag } from "@/helpers" import { bindings, featureFlag } from "@/helpers"
import { screenComponentBindableProperties } from "./bindings"
function reduceBy<TItem extends {}, TKey extends keyof TItem>( function reduceBy<TItem extends {}, TKey extends keyof TItem>(
key: TKey, key: TKey,
@ -31,14 +32,26 @@ const validationKeyByType: Record<UIDatasourceType, string | null> = {
viewV2: "id", viewV2: "id",
query: "_id", query: "_id",
custom: null, custom: null,
link: "rowId",
} }
export const screenComponentErrors = derived( export const screenComponentErrors = derived(
[selectedScreen, tables, views, viewsV2, queries], [
([$selectedScreen, $tables, $views, $viewsV2, $queries]): Record< selectedScreen,
string, tables,
string[] views,
> => { viewsV2,
queries,
screenComponentBindableProperties,
],
([
$selectedScreen,
$tables,
$views,
$viewsV2,
$queries,
$screenComponentBindableProperties,
]): Record<string, string[]> => {
if (!featureFlag.isEnabled("CHECK_SCREEN_COMPONENT_SETTINGS_ERRORS")) { if (!featureFlag.isEnabled("CHECK_SCREEN_COMPONENT_SETTINGS_ERRORS")) {
return {} return {}
} }
@ -56,6 +69,9 @@ export const screenComponentErrors = derived(
const type = componentSettings.type as UIDatasourceType const type = componentSettings.type as UIDatasourceType
const validationKey = validationKeyByType[type] const validationKey = validationKeyByType[type]
if (type === "link") {
debugger
}
if (!validationKey) { if (!validationKey) {
continue continue
} }
@ -76,6 +92,10 @@ export const screenComponentErrors = derived(
...reduceBy("name", $views.list), ...reduceBy("name", $views.list),
...reduceBy("id", $viewsV2.list), ...reduceBy("id", $viewsV2.list),
...reduceBy("_id", $queries.list), ...reduceBy("_id", $queries.list),
...reduceBy(
"rowId",
bindings.extractRelationships($screenComponentBindableProperties)
),
} }
return getInvalidDatasources($selectedScreen, datasources) return getInvalidDatasources($selectedScreen, datasources)

View File

@ -1 +1,7 @@
export type UIDatasourceType = "table" | "view" | "viewV2" | "query" | "custom" export type UIDatasourceType =
| "table"
| "view"
| "viewV2"
| "query"
| "custom"
| "link"