Skip to content

Commit 05ce626

Browse files
committed
fix: pivot control
1 parent 9c4fd1d commit 05ce626

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

packages/cubejs-api-gateway/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ class ApiGateway {
458458
}
459459

460460
async getNormalizedQueries(query, context) {
461+
query = this.parseQueryParam(query);
461462
let queryType = QUERY_TYPE.REGULAR_QUERY;
462463

463464
if (!Array.isArray(query)) {

packages/cubejs-client-react/src/QueryBuilder.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ export default class QueryBuilder extends React.Component {
238238
sourceIndex,
239239
destinationIndex,
240240
sourceAxis,
241-
destinationAxis
241+
destinationAxis,
242+
callback
242243
}) => {
243244
const nextPivotConfig = {
244245
...pivotConfig,
@@ -257,6 +258,10 @@ export default class QueryBuilder extends React.Component {
257258
nextPivotConfig[sourceAxis].splice(sourceIndex, 1);
258259
nextPivotConfig[destinationAxis].splice(destinationIndex, 0, id);
259260

261+
if (callback) {
262+
callback(nextPivotConfig);
263+
}
264+
260265
this.updateVizState({
261266
pivotConfig: nextPivotConfig
262267
});
@@ -297,7 +302,7 @@ export default class QueryBuilder extends React.Component {
297302

298303
let pivotQuery = {};
299304
let finalState = this.applyStateChangeHeuristics(state);
300-
const { order: _, ...query } = finalState.query || {};
305+
const { order: _, ...query } = finalState.query || stateQuery;
301306

302307
if (QueryRenderer.isQueryPresent(query)) {
303308
try {
@@ -332,7 +337,6 @@ export default class QueryBuilder extends React.Component {
332337
const nextOrder = fromPairs(currentOrderMembers.map(({ id, order }) => (order !== 'none' ? [id, order] : false)).filter(Boolean));
333338

334339
const nextQuery = {
335-
...stateQuery,
336340
...query,
337341
order: nextOrder
338342
};

packages/cubejs-playground/src/QueryBuilder/TimeGroup.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PlusOutlined } from '@ant-design/icons';
22
import { DatePicker, Menu } from 'antd';
33
import moment from 'moment';
4-
import React, { useState } from 'react';
4+
import React, { useState, Fragment } from 'react';
55
import ButtonDropdown from './ButtonDropdown';
66
import MemberDropdown from './MemberDropdown';
77
import RemoveButtonGroup from './RemoveButtonGroup';
@@ -72,8 +72,8 @@ const TimeGroup = ({
7272

7373
return (
7474
<>
75-
{members.map((m) => (
76-
<>
75+
{members.map((m, index) => (
76+
<Fragment key={index}>
7777
<RemoveButtonGroup onRemoveClick={() => updateMethods.remove(m)}>
7878
<MemberDropdown
7979
onClick={(updateWith) =>
@@ -128,7 +128,7 @@ const TimeGroup = ({
128128
m.dimension.granularities.find((g) => g.name === m.granularity)
129129
.title}
130130
</ButtonDropdown>
131-
</>
131+
</Fragment>
132132
))}
133133

134134
{!members.length && (

packages/cubejs-playground/src/SchemaPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class SchemaPage extends Component {
225225

226226
return (
227227
<Layout style={{ height: '100%' }}>
228-
<Sider width={300} className="schema-sidebar">
228+
<Sider width={320} className="schema-sidebar">
229229
<Tabs
230230
activeKey={activeTab}
231231
onChange={(tab) => this.setState({ activeTab: tab })}

packages/cubejs-playground/src/components/Pivot/Axes.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
1-
import React from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { DragDropContext } from 'react-beautiful-dnd';
33
import { Row, Col, Divider } from 'antd';
44
import DroppableArea from './DroppableArea';
55

66
export default function Axes({ pivotConfig, onMove }) {
7+
const [uiPivotConfig, setUIPivotConfig] = useState(pivotConfig);
8+
9+
useEffect(() => {
10+
setUIPivotConfig(pivotConfig);
11+
}, [pivotConfig]);
12+
713
return (
814
<DragDropContext
9-
onDragEnd={({ source, destination }) => {
15+
onDragEnd={({ source, destination, ...props }) => {
1016
if (!destination) {
1117
return;
1218
}
13-
1419
onMove({
1520
sourceIndex: source.index,
1621
destinationIndex: destination.index,
1722
sourceAxis: source.droppableId,
1823
destinationAxis: destination.droppableId,
24+
callback(updatedPivotConfig) {
25+
setUIPivotConfig(updatedPivotConfig);
26+
},
1927
});
2028
}}
2129
>
2230
<Row>
2331
<Col span={11}>
24-
<DroppableArea pivotConfig={pivotConfig} axis="x" />
32+
<DroppableArea pivotConfig={uiPivotConfig} axis="x" />
2533
</Col>
2634

2735
<Col span={2}>
2836
<Divider style={{ height: '100%' }} type="vertical" />
2937
</Col>
3038

3139
<Col span={11}>
32-
<DroppableArea pivotConfig={pivotConfig} axis="y" />
40+
<DroppableArea pivotConfig={uiPivotConfig} axis="y" />
3341
</Col>
3442
</Row>
3543
</DragDropContext>

packages/cubejs-playground/src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ body {
44
-webkit-font-smoothing: antialiased;
55
-moz-osx-font-smoothing: grayscale;
66
background: #f8f8fb;
7+
overflow-x: hidden;
78
}
89

910
code {

0 commit comments

Comments
 (0)