Skip to content

Commit 7d77b4a

Browse files
authored
feat(cubejs-playground): add support for ungrouped and offset options (#8719)
1 parent 4875b8e commit 7d77b4a

22 files changed

+375
-476
lines changed

packages/cubejs-playground/src/QueryBuilderV2/QueryBuilder.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ export function QueryBuilder(props: Omit<QueryBuilderProps, 'apiUrl'> & { apiUrl
4040
function queryValidator(query: Query) {
4141
const queryCopy = JSON.parse(JSON.stringify(query));
4242

43-
if (typeof queryCopy.limit !== 'number' || queryCopy.limit < 1 || queryCopy.limit > 50_000) {
44-
queryCopy.limit = 5_000;
43+
// add the last stored timezone if the query is empty
44+
if (JSON.stringify(queryCopy) === '{}' && storedTimezones[0]) {
45+
queryCopy.timezone = storedTimezones[0];
4546
}
4647

47-
/**
48-
* @TODO: Add support for offset
49-
*/
50-
delete queryCopy.offset;
51-
52-
if (!queryCopy.timezone && storedTimezones[0]) {
53-
queryCopy.timezone = storedTimezones[0];
48+
if (typeof queryCopy.limit !== 'number' || queryCopy.limit < 1 || queryCopy.limit > 50_000) {
49+
queryCopy.limit = 5_000;
5450
}
5551

5652
return queryCopy;

packages/cubejs-playground/src/QueryBuilderV2/QueryBuilderChart.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
22
import {
3-
Badge,
43
Button,
54
Dialog,
65
DialogTrigger,
@@ -26,6 +25,7 @@ import { useQueryBuilderContext } from './context';
2625
import { PivotAxes, PivotOptions } from './Pivot';
2726
import { ArrowIcon } from './icons/ArrowIcon';
2827
import { AccordionCard } from './components/AccordionCard';
28+
import { OutdatedLabel } from './components/OutdatedLabel';
2929
import { QueryBuilderChartResults } from './QueryBuilderChartResults';
3030

3131
const CHART_HEIGHT = 400;
@@ -40,26 +40,21 @@ const ALLOWED_CHART_TYPES = ['table', 'line', 'bar', 'area'];
4040

4141
export 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

Comments
 (0)