Skip to content

Commit 7ad8936

Browse files
authored
feat(cubejs-playground): update query builder (#9118)
1 parent 42cbc8e commit 7ad8936

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+4643
-2359
lines changed

packages/cubejs-playground/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@apollo/client": "^3.11.4",
3434
"@graphiql/toolkit": "^0.4.3",
3535
"anser": "^2.1.1",
36+
"best-effort-json-parser": "^1.1.2",
3637
"camel-case": "^4.1.2",
3738
"codesandbox-import-utils": "^2.1.1",
3839
"cron-validator": "^1.2.1",
@@ -66,7 +67,7 @@
6667
"devDependencies": {
6768
"@ant-design/compatible": "^1.0.1",
6869
"@ant-design/icons": "^5.3.5",
69-
"@cube-dev/ui-kit": "0.38.0",
70+
"@cube-dev/ui-kit": "0.52.3",
7071
"@cubejs-client/core": "1.1.12",
7172
"@cubejs-client/react": "1.1.12",
7273
"@types/flexsearch": "^0.7.3",
@@ -97,7 +98,7 @@
9798
},
9899
"peerDependencies": {
99100
"@ant-design/icons": ">=4.7.0",
100-
"@cube-dev/ui-kit": ">=0.37.2",
101+
"@cube-dev/ui-kit": ">=0.52.3",
101102
"@cubejs-client/core": ">=0.30.0",
102103
"@cubejs-client/react": ">=0.30.0",
103104
"antd": ">=4.16.13",

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

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
import { useEffect, useMemo } from 'react';
2-
import cube, { Query } from '@cubejs-client/core';
31
import { Alert, Block, Card, PrismCode, Title } from '@cube-dev/ui-kit';
2+
import cube, { Query } from '@cubejs-client/core';
3+
import { useEffect, useMemo } from 'react';
44

5-
import { useLocalStorage } from './hooks';
6-
import { QueryBuilderProps } from './types';
75
import { QueryBuilderContext } from './context';
6+
import { useLocalStorage } from './hooks';
87
import { useQueryBuilder } from './hooks/query-builder';
98
import { QueryBuilderInternals } from './QueryBuilderInternals';
9+
import { QueryBuilderProps } from './types';
1010
import { useCommitPress } from './utils/use-commit-press';
1111

12-
export function QueryBuilder(props: Omit<QueryBuilderProps, 'apiUrl'> & { apiUrl: string | null }) {
12+
export function QueryBuilder(
13+
props: Omit<QueryBuilderProps, 'apiUrl'> & {
14+
displayPrivateItems?: boolean;
15+
apiUrl: string | null;
16+
disableLimitEnforcing?: boolean;
17+
children?: React.ReactNode;
18+
}
19+
) {
1320
const {
1421
apiUrl,
1522
apiToken,
@@ -22,9 +29,12 @@ export function QueryBuilder(props: Omit<QueryBuilderProps, 'apiUrl'> & { apiUrl
2229
tracking,
2330
isApiBlocked,
2431
apiVersion,
32+
memberViewType,
2533
VizardComponent,
2634
RequestStatusComponent,
2735
openSqlRunner,
36+
displayPrivateItems,
37+
disableSidebarResizing,
2838
} = props;
2939

3040
const cubeApi = useMemo(() => {
@@ -45,10 +55,6 @@ export function QueryBuilder(props: Omit<QueryBuilderProps, 'apiUrl'> & { apiUrl
4555
queryCopy.timezone = storedTimezones[0];
4656
}
4757

48-
if (typeof queryCopy.limit !== 'number' || queryCopy.limit < 1 || queryCopy.limit > 50_000) {
49-
queryCopy.limit = 5_000;
50-
}
51-
5258
return queryCopy;
5359
}
5460

@@ -72,8 +78,10 @@ export function QueryBuilder(props: Omit<QueryBuilderProps, 'apiUrl'> & { apiUrl
7278
defaultPivotConfig,
7379
schemaVersion,
7480
onQueryChange,
81+
memberViewType,
7582
tracking,
7683
queryValidator,
84+
displayPrivateItems,
7785
});
7886

7987
useEffect(() => {
@@ -86,7 +94,11 @@ export function QueryBuilder(props: Omit<QueryBuilderProps, 'apiUrl'> & { apiUrl
8694
return runQuery();
8795
}, true);
8896

89-
return apiToken && cubeApi && apiUrl ? (
97+
if (!apiToken || !cubeApi || !apiUrl) {
98+
return null;
99+
}
100+
101+
return (
90102
<QueryBuilderContext.Provider
91103
value={{
92104
runQuery,
@@ -108,6 +120,7 @@ export function QueryBuilder(props: Omit<QueryBuilderProps, 'apiUrl'> & { apiUrl
108120
VizardComponent,
109121
RequestStatusComponent,
110122
openSqlRunner,
123+
disableSidebarResizing,
111124
...otherProps,
112125
}}
113126
>
@@ -122,9 +135,11 @@ export function QueryBuilder(props: Omit<QueryBuilderProps, 'apiUrl'> & { apiUrl
122135
</Alert>
123136
)}
124137
</Block>
138+
) : props.children ? (
139+
props.children
125140
) : (
126141
<QueryBuilderInternals />
127142
)}
128143
</QueryBuilderContext.Provider>
129-
) : null;
144+
);
130145
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { ChartType } from '@cubejs-client/core';
2323
import { useLocalStorage } from './hooks';
2424
import { useQueryBuilderContext } from './context';
2525
import { PivotAxes, PivotOptions } from './Pivot';
26-
import { ArrowIcon } from './icons/ArrowIcon';
26+
import { ChevronIcon } from './icons/ChevronIcon';
2727
import { AccordionCard } from './components/AccordionCard';
2828
import { OutdatedLabel } from './components/OutdatedLabel';
2929
import { QueryBuilderChartResults } from './QueryBuilderChartResults';
@@ -117,7 +117,7 @@ export function QueryBuilderChart(props: QueryBuilderChartProps) {
117117
const pivotConfigurator = useMemo(() => {
118118
return pivotConfig ? (
119119
<DialogTrigger type="popover">
120-
<Button size="small" rightIcon={<ArrowIcon direction="bottom" />}>
120+
<Button size="small" rightIcon={<ChevronIcon direction="bottom" />}>
121121
Pivot
122122
</Button>
123123
<Dialog border overflow="hidden" width="40x max-content 80x">

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface QueryBuilderChartResultsProps {
1515
containerRef?: RefObject<HTMLDivElement>;
1616
}
1717

18-
const MAX_HEIGHT = 400;
18+
const MAX_HEIGHT = 350;
1919
const MAX_SERIES_LIMIT = 25;
2020

2121
const ChartContainer = tasty({
@@ -57,8 +57,8 @@ export function QueryBuilderChartResults({
5757
<ChartContainer
5858
ref={containerRef}
5959
style={{
60-
maxHeight: `${MAX_HEIGHT}px`,
61-
height: `${MAX_HEIGHT}px`,
60+
maxHeight: MAX_HEIGHT,
61+
height: MAX_HEIGHT,
6262
overflow,
6363
}}
6464
>
@@ -76,9 +76,9 @@ export function QueryBuilderChartResults({
7676
return (
7777
<Grid height={MAX_HEIGHT} columns="auto" placeContent="center" placeItems="center" gap="2x">
7878
<Title level={3} gridArea={false}>
79-
No data available
79+
No results available
8080
</Title>
81-
<Paragraph>Query metrics and dimensions with results to see the chart.</Paragraph>
81+
<Paragraph>Compose and run a query to see the results.</Paragraph>
8282
</Grid>
8383
);
8484
}

0 commit comments

Comments
 (0)