Skip to content

Commit

Permalink
[Enhancement] call layer methods to validate visconfig when switching…
Browse files Browse the repository at this point in the history
… dataset (#2532)

- when switching from one dataset to another, we call layer.validateVisConfig to validate visConfig with new dataset

Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta authored Mar 7, 2024
1 parent 1f9757b commit 400120f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/reducers/src/vis-state-merger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,12 @@ export function validateLayersByDatasets(
*/
// eslint-disable-next-line complexity
export function validateLayerWithData(
{fields, id: dataId}: KeplerTable,
dataset: KeplerTable,
savedLayer: ParsedLayer,
layerClasses: VisState['layerClasses'],
options: ValidateLayerOption = {}
): Layer | null {
const {fields, id: dataId} = dataset;
const {type} = savedLayer;
const {throwOnError} = options;
// layer doesnt have a valid type
Expand Down Expand Up @@ -832,14 +833,19 @@ export function validateLayerWithData(
: newLayer.config.textLabel;

// copy visConfig over to emptyLayer to make sure it has all the props
const visConfig = newLayer.copyLayerConfig(
const copiedVisConfig = newLayer.copyLayerConfig(
newLayer.config.visConfig,
savedLayer.config.visConfig || {},
{
shallowCopy: ['colorRange', 'strokeColorRange']
}
);

// call layer methods to validate visConfig when switching dataset
const visConfig = newLayer.validateVisConfig
? newLayer.validateVisConfig(dataset, copiedVisConfig)
: copiedVisConfig;

newLayer.updateLayerConfig({
visConfig,
textLabel
Expand Down

0 comments on commit 400120f

Please sign in to comment.