Skip to content

Commit

Permalink
Bug fixes in Save Modal
Browse files Browse the repository at this point in the history
Issues solved:
 - Save button doesn't pass in gotodash
 - slice_name was passed in from store as original slice_name instead of
   new one in 'saveas' action
 - datasource_type wasn't passed in to defaultViz and defaultForm
   function
  • Loading branch information
vera-liu committed Nov 29, 2016
1 parent 84e8f74 commit 6c4dc70
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
5 changes: 3 additions & 2 deletions superset/assets/javascripts/explorev2/components/SaveModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class SaveModal extends React.Component {
saveOrOverwrite(gotodash) {
this.setState({ alert: null });
this.props.actions.removeSaveModalAlert();
const params = getParamObject(this.props.form_data, this.props.datasource_type);
const params = getParamObject(
this.props.form_data, this.props.datasource_type, this.state.action === 'saveas');
const sliceParams = {};
params.datasource_name = this.props.form_data.datasource_name;

Expand Down Expand Up @@ -199,7 +200,7 @@ class SaveModal extends React.Component {
type="button"
id="btn_modal_save"
className="btn pull-left"
onClick={this.saveOrOverwrite.bind(this)}
onClick={this.saveOrOverwrite.bind(this, false)}
>
Save
</Button>
Expand Down
18 changes: 10 additions & 8 deletions superset/assets/javascripts/explorev2/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ const bootstrapData = JSON.parse(exploreViewContainer.getAttribute('data-bootstr

import { exploreReducer } from './reducers/exploreReducer';

const bootstrappedState = Object.assign(initialState(bootstrapData.viz.form_data.viz_type), {
can_edit: bootstrapData.can_edit,
can_download: bootstrapData.can_download,
datasources: bootstrapData.datasources,
datasource_type: bootstrapData.datasource_type,
viz: bootstrapData.viz,
user_id: bootstrapData.user_id,
});
const bootstrappedState = Object.assign(
initialState(bootstrapData.viz.form_data.viz_type, bootstrapData.datasource_type), {
can_edit: bootstrapData.can_edit,
can_download: bootstrapData.can_download,
datasources: bootstrapData.datasources,
datasource_type: bootstrapData.datasource_type,
viz: bootstrapData.viz,
user_id: bootstrapData.user_id,
}
);
bootstrappedState.viz.form_data.datasource = parseInt(bootstrapData.datasource_id, 10);
bootstrappedState.viz.form_data.datasource_name = bootstrapData.datasource_name;

Expand Down
8 changes: 4 additions & 4 deletions superset/assets/javascripts/explorev2/stores/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ export function defaultFormData(vizType = 'table', datasourceType = 'table') {
return data;
}

export function defaultViz(vizType) {
export function defaultViz(vizType, datasourceType = 'table') {
return {
cached_key: null,
cached_timeout: null,
Expand All @@ -1724,22 +1724,22 @@ export function defaultViz(vizType) {
csv_endpoint: null,
is_cached: false,
data: [],
form_data: defaultFormData(vizType),
form_data: defaultFormData(vizType, datasourceType),
json_endpoint: null,
query: null,
standalone_endpoint: null,
};
}

export function initialState(vizType = 'table') {
export function initialState(vizType = 'table', datasourceType = 'table') {
return {
dashboards: [],
isDatasourceMetaLoading: false,
datasources: null,
datasource_type: null,
filterColumnOpts: [],
fields,
viz: defaultViz(vizType),
viz: defaultViz(vizType, datasourceType),
isStarred: false,
};
}
Expand Down
5 changes: 3 additions & 2 deletions superset/assets/javascripts/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function formatFilters(filters) {
return params;
}

export function getParamObject(form_data, datasource_type) {
export function getParamObject(form_data, datasource_type, saveNewSlice) {
const data = {
// V2 tag temporarily for updating url
// Todo: remove after launch
Expand All @@ -177,7 +177,8 @@ export function getParamObject(form_data, datasource_type) {
};
Object.keys(form_data).forEach((field) => {
// filter out null fields
if (form_data[field] !== null && field !== 'datasource') {
if (form_data[field] !== null && field !== 'datasource'
&& !(saveNewSlice && field === 'slice_name')) {
data[field] = form_data[field];
}
});
Expand Down

0 comments on commit 6c4dc70

Please sign in to comment.