Skip to content
Snippets Groups Projects
Commit f3725cb9 authored by Atte Keinänen's avatar Atte Keinänen
Browse files

Show CardBuilder for dirty saved cards too

parent a382ed7d
No related branches found
No related tags found
No related merge requests found
......@@ -142,7 +142,9 @@ export default class CardBuilder extends Component {
}
componentWillMount() {
this.props.initializeQB(this.props.location, this.props.params);
if (!this.props.qbIsAlreadyInitialized) {
this.props.initializeQB(this.props.location, this.props.params);
}
}
componentDidMount() {
......
......@@ -4,6 +4,7 @@ import { connect } from "react-redux";
import cx from "classnames";
import _ from "underscore";
import { getIn } from "icepick";
import { loadTableAndForeignKeys } from "metabase/lib/table";
import { isPK, isFK } from "metabase/lib/types";
......@@ -52,6 +53,7 @@ import * as actions from "../actions";
import { push } from "react-router-redux";
import { MetabaseApi } from "metabase/services";
import CardBuilder from "metabase/query_builder/containers/CardBuilder";
function cellIsClickable(queryResult, rowIndex, columnIndex) {
if (!queryResult) return false;
......@@ -193,11 +195,19 @@ export default class QueryBuilder extends Component {
}
render() {
return (
<div className="flex-full flex relative">
<LegacyQueryBuilder {...this.props} />
</div>
)
const isSavedCard = !!getIn(this.props.card, ["id"]);
const isDirtySavedCard = !!(getIn(this.props.card, ["original_card_id"]) && this.props.isDirty);
const redirectToCardBuilder = isSavedCard || isDirtySavedCard;
if (redirectToCardBuilder) {
return <CardBuilder {...this.props} qbIsAlreadyInitialized />
} else {
return (
<div className="flex-full flex relative">
<LegacyQueryBuilder {...this.props} />
</div>
)
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment