11// Libraries
22import { useMemo , useContext , useCallback } from 'react'
3- import { useDispatch , useSelector } from 'react-redux'
3+ import { useDispatch } from 'react-redux'
44
55// Context
66import { PipeContext } from 'src/flows/context/pipe'
@@ -12,15 +12,10 @@ import {setStaticLegend} from 'src/timeMachine/actions'
1212import { StaticLegend as StaticLegendConfig } from '@influxdata/giraffe'
1313import { StaticLegend as StaticLegendAPI } from 'src/types'
1414
15- // Utils
16- import { getActiveTimeMachine } from 'src/timeMachine/selectors'
17-
1815// Constants
1916import {
2017 LEGEND_COLORIZE_ROWS_DEFAULT ,
2118 LEGEND_OPACITY_DEFAULT ,
22- LEGEND_OPACITY_MINIMUM ,
23- LEGEND_OPACITY_MAXIMUM ,
2419 LEGEND_ORIENTATION_THRESHOLD_DEFAULT ,
2520 LEGEND_ORIENTATION_THRESHOLD_HORIZONTAL ,
2621 LEGEND_ORIENTATION_THRESHOLD_VERTICAL ,
@@ -71,7 +66,6 @@ const eventPrefix = 'visualization.customize.staticlegend'
7166export const useStaticLegend = ( properties ) : StaticLegendConfig => {
7267 const { id, data, update} = useContext ( PipeContext )
7368
74- const { isViewingVisOptions} = useSelector ( getActiveTimeMachine )
7569 const dispatch = useDispatch ( )
7670 const timeMachineUpdate = useCallback (
7771 ( staticLegend : StaticLegendAPI ) => {
@@ -102,8 +96,6 @@ export const useStaticLegend = (properties): StaticLegendConfig => {
10296
10397 return useMemo ( ( ) => {
10498 const {
105- legendColorizeRows = LEGEND_COLORIZE_ROWS_DEFAULT ,
106- legendOpacity = LEGEND_OPACITY_DEFAULT ,
10799 legendOrientationThreshold = LEGEND_ORIENTATION_THRESHOLD_DEFAULT ,
108100 } = properties
109101
@@ -119,47 +111,14 @@ export const useStaticLegend = (properties): StaticLegendConfig => {
119111 } = properties
120112
121113 const {
122- colorizeRows = false , // undefined is false because of omitempty
114+ colorizeRows = false ,
123115 heightRatio = STATIC_LEGEND_HEIGHT_RATIO_NOT_SET ,
124116 opacity = LEGEND_OPACITY_DEFAULT ,
125117 orientationThreshold = legendOrientationThreshold ,
126118 show = STATIC_LEGEND_SHOW_DEFAULT ,
127119 ...config
128120 } = staticLegend
129121
130- if (
131- isViewingVisOptions &&
132- ! show &&
133- heightRatio === STATIC_LEGEND_HEIGHT_RATIO_NOT_SET
134- ) {
135- let validOpacity = LEGEND_OPACITY_DEFAULT
136- if (
137- typeof legendOpacity === 'number' &&
138- legendOpacity === legendOpacity &&
139- legendOpacity >= LEGEND_OPACITY_MINIMUM &&
140- legendOpacity <= LEGEND_OPACITY_MAXIMUM
141- ) {
142- validOpacity = legendOpacity
143- }
144-
145- let validThreshold : number
146- if (
147- typeof legendOrientationThreshold !== 'number' ||
148- legendOrientationThreshold !== legendOrientationThreshold ||
149- legendOrientationThreshold > 0
150- ) {
151- validThreshold = LEGEND_ORIENTATION_THRESHOLD_HORIZONTAL
152- } else {
153- validThreshold = LEGEND_ORIENTATION_THRESHOLD_VERTICAL
154- }
155-
156- updateStaticLegendProperties ( {
157- colorizeRows : legendColorizeRows ,
158- opacity : validOpacity ,
159- orientationThreshold : validThreshold ,
160- } )
161- }
162-
163122 return {
164123 ...config ,
165124 colorizeRows,
@@ -226,5 +185,5 @@ export const useStaticLegend = (properties): StaticLegendConfig => {
226185 }
227186 } ,
228187 }
229- } , [ properties , isViewingVisOptions , updateStaticLegendProperties ] )
188+ } , [ properties , updateStaticLegendProperties ] )
230189}
0 commit comments