11import { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
22import {
3- Badge ,
43 Button ,
54 Dialog ,
65 DialogTrigger ,
@@ -26,6 +25,7 @@ import { useQueryBuilderContext } from './context';
2625import { PivotAxes , PivotOptions } from './Pivot' ;
2726import { ArrowIcon } from './icons/ArrowIcon' ;
2827import { AccordionCard } from './components/AccordionCard' ;
28+ import { OutdatedLabel } from './components/OutdatedLabel' ;
2929import { QueryBuilderChartResults } from './QueryBuilderChartResults' ;
3030
3131const CHART_HEIGHT = 400 ;
@@ -40,26 +40,21 @@ const ALLOWED_CHART_TYPES = ['table', 'line', 'bar', 'area'];
4040
4141export function QueryBuilderChart ( props : QueryBuilderChartProps ) {
4242 const [ isVizardLoaded , setIsVizardLoaded ] = useState ( false ) ;
43- const [ isExpanded , setIsExpanded ] = useLocalStorage (
44- 'QueryBuilder:Chart:expanded' ,
45- false
46- ) ;
43+ const [ isExpanded , setIsExpanded ] = useLocalStorage ( 'QueryBuilder:Chart:expanded' , false ) ;
4744 const { maxHeight = CHART_HEIGHT , onToggle } = props ;
4845 let {
4946 query,
5047 isLoading,
51- isQueryTouched,
52- executedQuery,
5348 chartType,
5449 setChartType,
5550 pivotConfig,
5651 updatePivotConfig,
5752 resultSet,
5853 apiToken,
5954 apiUrl,
55+ isResultOutdated,
6056 VizardComponent,
6157 } = useQueryBuilderContext ( ) ;
62- const isOutdated = executedQuery && isQueryTouched ;
6358 const containerRef = useRef < HTMLDivElement > ( null ) ;
6459
6560 if ( ! ALLOWED_CHART_TYPES . includes ( chartType || '' ) ) {
@@ -146,8 +141,8 @@ export function QueryBuilderChart(props: QueryBuilderChartProps) {
146141 isExpanded ? (
147142 < LoadingOutlined />
148143 ) : undefined
149- ) : isOutdated ? (
150- < Badge type = "disabled" > OUTDATED </ Badge >
144+ ) : isResultOutdated ? (
145+ < OutdatedLabel / >
151146 ) : undefined
152147 }
153148 extra = {
@@ -226,9 +221,7 @@ export function QueryBuilderChart(props: QueryBuilderChartProps) {
226221 } }
227222 >
228223 < >
229- { isLoading ? (
230- < Skeleton height = { 400 } layout = "chart" padding = "0 1x 1x 1x" />
231- ) : undefined }
224+ { isLoading ? < Skeleton height = { 400 } layout = "chart" padding = "0 1x 1x 1x" /> : undefined }
232225 { chart }
233226 </ >
234227 </ AccordionCard >
0 commit comments