Skip to content
Snippets Groups Projects
Unverified Commit 4993382f authored by Kyle Doherty's avatar Kyle Doherty
Browse files

dont redirect on save

parent dcc3d219
No related branches found
No related tags found
Loading
import React from "react";
import { connect } from "react-redux";
import { push } from "react-router-redux";
import { Link } from "react-router";
import { withBackground } from "metabase/hoc/Background";
import ActionButton from "metabase/components/ActionButton";
import Icon from "metabase/components/Icon";
import cxs from "cxs";
import { t } from 'c-3po'
import { Dashboard } from "./Dashboard";
import DashboardData from "metabase/dashboard/hoc/DashboardData";
import Parameters from "metabase/parameters/components/Parameters";
import { addUndo, createUndo } from 'metabase/redux/undo'
import { DashboardApi } from "metabase/services";
import * as Urls from "metabase/lib/urls";
import * as Urls from "metabase/lib/urls"
import { dissoc } from "icepick";
......@@ -68,14 +69,26 @@ const mapStateToProps = (state, props) => ({
dashboardId: getDashboardId(state, props),
});
@connect(mapStateToProps, { push })
@connect(mapStateToProps, { addUndo, createUndo })
@DashboardData
class AutomaticDashboardApp extends React.Component {
save = async () => {
const { dashboard, push } = this.props;
const { dashboard, addUndo, createUndo } = this.props;
// remove the transient id before trying to save
const newDashboard = await DashboardApi.save(dissoc(dashboard, "id"));
push(Urls.dashboard(newDashboard.id));
addUndo(
createUndo({
type: 'metabase/automatic-dashboards/link-to-created-object',
message: () =>
<div className="flex align-center">
<Icon name='dashboard' size={22} className="mr2" />
<Link className="link" to={Urls.dashboard(newDashboard.id)}>
{ t`View your recently created dashboard` }
</Link>
</div>,
action: null
})
)
};
render() {
......
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