|
1 | 1 | // Libraries |
2 | | -import React, {FC, memo} from 'react' |
| 2 | +import React, {FC, memo, useEffect} from 'react' |
3 | 3 | import {connect, ConnectedProps, useDispatch} from 'react-redux' |
4 | 4 | import classnames from 'classnames' |
5 | 5 | import {createGroupIDColumn, fromFlux} from '@influxdata/giraffe' |
@@ -95,26 +95,31 @@ const TimeMachineVis: FC<Props> = ({ |
95 | 95 | giraffeResult.table.getColumnType('_value') !== 'number' && |
96 | 96 | !!giraffeResult.table.length) |
97 | 97 |
|
98 | | - if ( |
99 | | - isFlagEnabled('graphColorMapping') && |
100 | | - viewProperties.hasOwnProperty('colors') |
101 | | - ) { |
102 | | - const groupKey = [...giraffeResult.fluxGroupKeyUnion, 'result'] |
103 | | - const [, fillColumnMap] = createGroupIDColumn(giraffeResult.table, groupKey) |
104 | | - const {colorMappingForIDPE, needsToSaveToIDPE} = getColorMappingObjects( |
105 | | - fillColumnMap, |
106 | | - viewProperties as XYViewProperties |
107 | | - ) |
108 | | - |
109 | | - if (loading === RemoteDataState.Done && needsToSaveToIDPE) { |
110 | | - dispatch( |
111 | | - setViewProperties({ |
112 | | - ...viewProperties, |
113 | | - colorMapping: colorMappingForIDPE, |
114 | | - } as XYViewProperties) |
| 98 | + useEffect(() => { |
| 99 | + if ( |
| 100 | + isFlagEnabled('graphColorMapping') && |
| 101 | + viewProperties.hasOwnProperty('colors') |
| 102 | + ) { |
| 103 | + const groupKey = [...giraffeResult.fluxGroupKeyUnion, 'result'] |
| 104 | + const [, fillColumnMap] = createGroupIDColumn( |
| 105 | + giraffeResult.table, |
| 106 | + groupKey |
| 107 | + ) |
| 108 | + const {colorMappingForIDPE, needsToSaveToIDPE} = getColorMappingObjects( |
| 109 | + fillColumnMap, |
| 110 | + viewProperties as XYViewProperties |
115 | 111 | ) |
| 112 | + |
| 113 | + if (loading === RemoteDataState.Done && needsToSaveToIDPE) { |
| 114 | + dispatch( |
| 115 | + setViewProperties({ |
| 116 | + ...viewProperties, |
| 117 | + colorMapping: colorMappingForIDPE, |
| 118 | + } as XYViewProperties) |
| 119 | + ) |
| 120 | + } |
116 | 121 | } |
117 | | - } |
| 122 | + }) |
118 | 123 |
|
119 | 124 | // Handles deadman check edge case to allow non-numeric values |
120 | 125 | if (viewRawData && files && files?.length) { |
|
0 commit comments