From 0cf8281f4d49463e3015bb8ad38f7c014a69ba9d Mon Sep 17 00:00:00 2001 From: wdoconnell <91283923+wdoconnell@users.noreply.github.com> Date: Fri, 3 Mar 2023 14:44:57 -0500 Subject: [PATCH] chore: limit graphColorMapping to CLOUD --- src/timeMachine/components/Vis.tsx | 5 ++- src/visualization/types/Graph/options.tsx | 30 ++++++++++------- src/visualization/types/Graph/view.tsx | 39 ++++++++++++++--------- 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/timeMachine/components/Vis.tsx b/src/timeMachine/components/Vis.tsx index ea7b329748..555b55926a 100644 --- a/src/timeMachine/components/Vis.tsx +++ b/src/timeMachine/components/Vis.tsx @@ -34,6 +34,9 @@ import {RemoteDataState, AppState, ViewProperties} from 'src/types' import {getActiveTimeRange} from 'src/timeMachine/selectors/index' import {setViewProperties} from 'src/timeMachine/actions' +// Constants +import {CLOUD} from 'src/shared/constants' + type ReduxProps = ConnectedProps type Props = ReduxProps @@ -95,7 +98,7 @@ const TimeMachineVis: FC = ({ !!giraffeResult.table.length) useEffect(() => { - if (viewProperties.hasOwnProperty('colors')) { + if (CLOUD && viewProperties.hasOwnProperty('colors')) { const groupKey = [...giraffeResult.fluxGroupKeyUnion, 'result'] const [, fillColumnMap] = createGroupIDColumn( giraffeResult.table, diff --git a/src/visualization/types/Graph/options.tsx b/src/visualization/types/Graph/options.tsx index 3689e113f6..da2168d326 100644 --- a/src/visualization/types/Graph/options.tsx +++ b/src/visualization/types/Graph/options.tsx @@ -43,7 +43,9 @@ import AxisTicksGenerator from 'src/visualization/components/internal/AxisTicksG import {XYViewProperties} from 'src/types' import {VisualizationOptionProps} from 'src/visualization' +// Constants const {BASE_2, BASE_10} = AXES_SCALE_OPTIONS +import {CLOUD} from 'src/shared/constants' interface Props extends VisualizationOptionProps { properties: XYViewProperties @@ -250,19 +252,23 @@ export const GraphOptions: FC = ({properties, results, update}) => { c.type === 'scale') ?? []} onChange={colors => { - const [, fillColumnMap] = createGroupIDColumn( - results.table, - groupKey - ) - // the properties that we use to calculate the colors are updated in the next render cycle so we need - // to make a new object and override the colors - const newProperties = {...properties, colors} - const colorMapping = generateSeriesToColorHex( - fillColumnMap, - newProperties - ) + if (CLOUD) { + const [, fillColumnMap] = createGroupIDColumn( + results.table, + groupKey + ) + // the properties that we use to calculate the colors are updated in the next render cycle so we need + // to make a new object and override the colors + const newProperties = {...properties, colors} + const colorMapping = generateSeriesToColorHex( + fillColumnMap, + newProperties + ) - update({colors, colorMapping}) + update({colors, colorMapping}) + } else { + update({colors}) + } }} /> diff --git a/src/visualization/types/Graph/view.tsx b/src/visualization/types/Graph/view.tsx index 0cce673d96..452cbf8e38 100644 --- a/src/visualization/types/Graph/view.tsx +++ b/src/visualization/types/Graph/view.tsx @@ -72,6 +72,9 @@ interface Props extends VisualizationProps { properties: XYViewProperties } +// Constants +import {CLOUD} from 'src/shared/constants' + export const Graph: FC = ({ properties, annotations, @@ -244,20 +247,24 @@ export const Graph: FC = ({ return } - const memoizedGetColorMappingObjects = memoizeOne(getColorMappingObjects) - const [, fillColumnMap] = createGroupIDColumn(resultState.table, groupKey) - const {colorMappingForGiraffe, colorMappingForIDPE, needsToSaveToIDPE} = - memoizedGetColorMappingObjects(fillColumnMap, properties) - const colorMapping = colorMappingForGiraffe + let colorMapping = null + + if (CLOUD) { + const memoizedGetColorMappingObjects = memoizeOne(getColorMappingObjects) + const [, fillColumnMap] = createGroupIDColumn(resultState.table, groupKey) + const {colorMappingForGiraffe, colorMappingForIDPE, needsToSaveToIDPE} = + memoizedGetColorMappingObjects(fillColumnMap, properties) + colorMapping = colorMappingForGiraffe - // when the view is in a dashboard cell, and there is a need to save to IDPE, save it. - // when VEO is open, prevent from saving because it causes state issues. It will be handled in the timemachine code separately. - if (needsToSaveToIDPE && view?.dashboardID && !isVeoOpen) { - const newView = {...view} - newView.properties.colorMapping = colorMappingForIDPE + // when the view is in a dashboard cell, and there is a need to save to IDPE, save it. + // when VEO is open, prevent from saving because it causes state issues. It will be handled in the timemachine code separately. + if (needsToSaveToIDPE && view?.dashboardID && !isVeoOpen) { + const newView = {...view} + newView.properties.colorMapping = colorMappingForIDPE - // save to IDPE - dispatch(updateViewAndVariables(view.dashboardID, newView)) + // save to IDPE + dispatch(updateViewAndVariables(view.dashboardID, newView)) + } } const config: Config = { @@ -298,11 +305,13 @@ export const Graph: FC = ({ ], } - const layer = {...(config.layers[0] as LineLayerConfig)} + if (CLOUD) { + const layer = {...(config.layers[0] as LineLayerConfig)} - layer.colorMapping = colorMapping + layer.colorMapping = colorMapping - config.layers[0] = layer + config.layers[0] = layer + } addAnnotationLayer( config,