@@ -73,6 +73,7 @@ import {
7373 queryBrowserToggleAllSeries ,
7474 queryBrowserToggleIsEnabled ,
7575 queryBrowserToggleSeries ,
76+ showGraphs ,
7677 toggleGraphs ,
7778} from '../actions/observe' ;
7879
@@ -94,7 +95,7 @@ import {
9495import { MonitoringState } from '../reducers/observe' ;
9596import { DropDownPollInterval } from './dropdown-poll-interval' ;
9697import { useBoolean } from './hooks/useBoolean' ;
97- import { getLegacyObserveState , usePerspective } from './hooks/usePerspective' ;
98+ import { getLegacyObserveState , getObserveState , usePerspective } from './hooks/usePerspective' ;
9899import KebabDropdown from './kebab-dropdown' ;
99100import { colors , Error , QueryBrowser } from './query-browser' ;
100101import { QueryParams } from './query-params' ;
@@ -321,7 +322,7 @@ export const ToggleGraph: React.FC = () => {
321322 const { perspective } = usePerspective ( ) ;
322323
323324 const hideGraphs = useSelector (
324- ( state : MonitoringState ) => ! ! getLegacyObserveState ( perspective , state ) ?. get ( 'hideGraphs' ) ,
325+ ( state : MonitoringState ) => ! ! getObserveState ( perspective , state ) ?. get ( 'hideGraphs' ) ,
325326 ) ;
326327
327328 const dispatch = useDispatch ( ) ;
@@ -338,6 +339,14 @@ export const ToggleGraph: React.FC = () => {
338339 [ hideGraphs ] ,
339340 ) ;
340341
342+ // Use an empty useEffect to get access to the cleanup function so that if graphs are
343+ // currently hidden then we show the graphs as we unmount
344+ React . useEffect ( ( ) => {
345+ return ( ) => {
346+ dispatch ( showGraphs ( ) ) ;
347+ } ;
348+ } , [ dispatch ] ) ;
349+
341350 const icon = hideGraphs ? < ChartLineIcon /> : < CompressIcon /> ;
342351
343352 return (
@@ -987,7 +996,7 @@ const QueryBrowserWrapper: React.FC<{
987996 const dispatch = useDispatch ( ) ;
988997
989998 const hideGraphs = useSelector (
990- ( state : MonitoringState ) => ! ! getLegacyObserveState ( perspective , state ) ?. get ( 'hideGraphs' ) ,
999+ ( state : MonitoringState ) => ! ! getObserveState ( perspective , state ) ?. get ( 'hideGraphs' ) ,
9911000 ) ;
9921001 const queriesList = useSelector ( ( state : MonitoringState ) =>
9931002 getLegacyObserveState ( perspective , state ) ?. getIn ( [ 'queryBrowser' , 'queries' ] ) ,
0 commit comments