diff --git a/superset/assets/javascripts/components/EditableTitle.jsx b/superset/assets/javascripts/components/EditableTitle.jsx
index 9ea64a34912b9..31c4c53c96e03 100644
--- a/superset/assets/javascripts/components/EditableTitle.jsx
+++ b/superset/assets/javascripts/components/EditableTitle.jsx
@@ -53,6 +53,14 @@ class EditableTitle extends React.PureComponent {
isEditing: false,
});
+ if (!this.state.title.length) {
+ this.setState({
+ title: this.state.lastTitle,
+ });
+
+ return;
+ }
+
if (this.state.lastTitle !== this.state.title) {
this.setState({
lastTitle: this.state.title,
diff --git a/superset/assets/javascripts/explore/actions/exploreActions.js b/superset/assets/javascripts/explore/actions/exploreActions.js
index 160828229786f..dbba7b7fbed73 100644
--- a/superset/assets/javascripts/explore/actions/exploreActions.js
+++ b/superset/assets/javascripts/explore/actions/exploreActions.js
@@ -150,3 +150,8 @@ export const RENDER_TRIGGERED = 'RENDER_TRIGGERED';
export function renderTriggered() {
return { type: RENDER_TRIGGERED };
}
+
+export const CREATE_NEW_SLICE = 'CREATE_NEW_SLICE';
+export function createNewSlice(can_add, can_download, can_overwrite, slice, form_data) {
+ return { type: CREATE_NEW_SLICE, can_add, can_download, can_overwrite, slice, form_data };
+}
diff --git a/superset/assets/javascripts/explore/components/ChartContainer.jsx b/superset/assets/javascripts/explore/components/ChartContainer.jsx
index 2d0830d324c50..f3c660adf66bc 100644
--- a/superset/assets/javascripts/explore/components/ChartContainer.jsx
+++ b/superset/assets/javascripts/explore/components/ChartContainer.jsx
@@ -153,15 +153,22 @@ class ChartContainer extends React.PureComponent {
this.props.actions.runQuery(this.props.formData, true, this.props.timeout);
}
- updateChartTitle(newTitle) {
+ updateChartTitleOrSaveSlice(newTitle) {
+ const isNewSlice = !this.props.slice;
const params = {
slice_name: newTitle,
- action: 'overwrite',
+ action: isNewSlice ? 'saveas' : 'overwrite',
};
const saveUrl = getExploreUrl(this.props.formData, 'base', false, null, params);
this.props.actions.saveSlice(saveUrl)
- .then(() => {
- this.props.actions.updateChartTitle(newTitle);
+ .then((data) => {
+ if (isNewSlice) {
+ this.props.actions.createNewSlice(
+ data.can_add, data.can_download, data.can_overwrite,
+ data.slice, data.form_data);
+ } else {
+ this.props.actions.updateChartTitle(newTitle);
+ }
});
}
@@ -263,8 +270,8 @@ class ChartContainer extends React.PureComponent {
>
{this.props.slice &&
diff --git a/superset/assets/javascripts/explore/components/SaveModal.jsx b/superset/assets/javascripts/explore/components/SaveModal.jsx
index ac76e3a5ad68e..9de835381b243 100644
--- a/superset/assets/javascripts/explore/components/SaveModal.jsx
+++ b/superset/assets/javascripts/explore/components/SaveModal.jsx
@@ -108,7 +108,7 @@ class SaveModal extends React.Component {
this.props.actions.saveSlice(saveUrl)
.then((data) => {
// Go to new slice url or dashboard url
- window.location = data;
+ window.location = data.slice.slice_url;
});
this.props.onHide();
}
@@ -185,6 +185,7 @@ class SaveModal extends React.Component {
{t('Add slice to existing dashboard')}