Skip to content

Commit

Permalink
fix(playground): schemaVersion updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilev-alex committed Nov 11, 2022
1 parent 6ef8ce9 commit 5c4880f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 5 additions & 7 deletions packages/cubejs-client-react/src/QueryBuilder.jsx
Expand Up @@ -31,7 +31,7 @@ const granularities = [

export default class QueryBuilder extends React.Component {
static contextType = CubeContext;

static defaultProps = {
cubejsApi: null,
stateChangeHeuristics: null,
Expand All @@ -42,7 +42,7 @@ export default class QueryBuilder extends React.Component {
defaultQuery: {},
initialVizState: null,
onVizStateChanged: null,

// deprecated
query: null,
setQuery: null,
Expand Down Expand Up @@ -134,7 +134,6 @@ export default class QueryBuilder extends React.Component {

async componentDidUpdate(prevProps) {
const { schemaVersion, onSchemaChange } = this.props;
const { meta } = this.state;

if (this.prevContext?.cubejsApi !== this.context?.cubejsApi) {
this.prevContext = this.context;
Expand All @@ -143,8 +142,7 @@ export default class QueryBuilder extends React.Component {

if (prevProps.schemaVersion !== schemaVersion) {
try {
const newMeta = await this.cubejsApi().meta();
if (!equals(newMeta, meta) && typeof onSchemaChange === 'function') {
if (typeof onSchemaChange === 'function') {
onSchemaChange({
schemaVersion,
refresh: async () => {
Expand Down Expand Up @@ -223,7 +221,7 @@ export default class QueryBuilder extends React.Component {

prepareRenderProps(queryRendererProps) {
const getName = (member) => member.name;

const toTimeDimension = (member) => {
const rangeSelection = member.compareDateRange
? { compareDateRange: member.compareDateRange }
Expand All @@ -235,7 +233,7 @@ export default class QueryBuilder extends React.Component {
...rangeSelection,
});
};

const toFilter = (member) => ({
member: member.member?.name || member.dimension?.name,
operator: member.operator,
Expand Down
Expand Up @@ -73,8 +73,10 @@ export function QueryBuilderContainer(props: QueryBuilderContainerProps) {
token={currentToken!}
dashboardSource={props.dashboardSource}
securityContextToken={securityContextToken}
onTabChange={props.onTabChange}
extra={props.extra}
schemaVersion={props.schemaVersion}
onSchemaChange={props.onSchemaChange}
onTabChange={props.onTabChange}
onVizStateChanged={props.onVizStateChanged}
onSecurityContextModalOpen={() => setIsModalOpen(true)}
/>
Expand Down Expand Up @@ -105,7 +107,6 @@ function QueryTabsRenderer({
token,
securityContextToken,
dashboardSource,
schemaVersion,
onSecurityContextModalOpen,
...props
}: QueryTabsRendererProps) {
Expand Down Expand Up @@ -158,8 +159,9 @@ function QueryTabsRenderer({
chartType,
}}
dashboardSource={dashboardSource}
schemaVersion={schemaVersion}
schemaVersion={props.schemaVersion}
extra={props.extra}
onSchemaChange={props.onSchemaChange}
onVizStateChanged={(vizState) => {
saveTab({
query: vizState.query || {},
Expand Down

0 comments on commit 5c4880f

Please sign in to comment.