Fix generating datsource structure for components which have a setting of type table

This commit is contained in:
Andrew Kingston 2022-09-30 15:56:06 +01:00
parent d68c8c45b1
commit 4b2a8aae7b
1 changed files with 8 additions and 8 deletions

View File

@ -243,18 +243,18 @@ export const getDatasourceForProvider = (asset, component) => {
return null return null
} }
// There are different types of setting which can be a datasource, for // For legacy compatibility, we need to be able to handle datasources that are
// example an actual datasource object, or a table ID string. // just strings. These are not generated any more, so could be removed in
// Convert the datasource setting into a proper datasource object so that // future.
// we can use it properly // TODO: remove at some point
if (datasourceSetting.type === "table") { const datasource = component[datasourceSetting?.key]
if (typeof datasource === "string") {
return { return {
tableId: component[datasourceSetting?.key], tableId: datasource,
type: "table", type: "table",
} }
} else {
return component[datasourceSetting?.key]
} }
return datasource
} }
/** /**