mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
fix(explore): remove unnecessary parameters from the explore url (#17123)
* remove unnecessary parameters from the explore url * refactor, test
This commit is contained in:
parent
37944e18d6
commit
57f869cf22
@ -230,7 +230,7 @@ export default class Chart extends React.Component {
|
||||
});
|
||||
};
|
||||
|
||||
getChartUrl = () => getExploreLongUrl(this.props.formData);
|
||||
getChartUrl = () => getExploreLongUrl(this.props.formData, null, false);
|
||||
|
||||
exportCSV(isFullCSV = false) {
|
||||
this.props.logEvent(LOG_ACTIONS_EXPORT_CSV_DASHBOARD_CHART, {
|
||||
|
@ -90,3 +90,26 @@ test('Get url when endpointType:results and allowOverflow:false', () => {
|
||||
'/superset/explore_json/?same=any-string&form_data=%7B%22datasource%22%3A%22datasource%22%2C%22viz_type%22%3A%22viz_type%22%7D',
|
||||
);
|
||||
});
|
||||
|
||||
test('Get url from a dashboard', () => {
|
||||
const formData = {
|
||||
...createParams().formData,
|
||||
// these params should get filtered out
|
||||
extra_form_data: {
|
||||
filters: {
|
||||
col: 'foo',
|
||||
op: 'IN',
|
||||
val: ['bar'],
|
||||
},
|
||||
},
|
||||
dataMask: {
|
||||
'NATIVE_FILTER-bqEoUsEPe': {
|
||||
id: 'NATIVE_FILTER-bqEoUsEPe',
|
||||
lots: 'of other stuff here too',
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(getExploreLongUrl(formData, null, false)).toBe(
|
||||
'/superset/explore/?form_data=%7B%22datasource%22%3A%22datasource%22%2C%22viz_type%22%3A%22viz_type%22%2C%22extra_form_data%22%3A%7B%22filters%22%3A%7B%22col%22%3A%22foo%22%2C%22op%22%3A%22IN%22%2C%22val%22%3A%5B%22bar%22%5D%7D%7D%7D',
|
||||
);
|
||||
});
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { omit } from 'lodash';
|
||||
/* eslint camelcase: 0 */
|
||||
import URI from 'urijs';
|
||||
import {
|
||||
@ -103,13 +104,19 @@ export function getExploreLongUrl(
|
||||
return null;
|
||||
}
|
||||
|
||||
// remove formData params that we don't need in the explore url.
|
||||
// These are present when generating explore urls from the dashboard page.
|
||||
// This should be superseded by some sort of "exploration context" system
|
||||
// where form data and other context is referenced by id.
|
||||
const trimmedFormData = omit(formData, ['dataMask', 'url_params']);
|
||||
|
||||
const uri = new URI('/');
|
||||
const directory = getURIDirectory(endpointType);
|
||||
const search = uri.search(true);
|
||||
Object.keys(extraSearch).forEach(key => {
|
||||
search[key] = extraSearch[key];
|
||||
});
|
||||
search.form_data = safeStringify(formData);
|
||||
search.form_data = safeStringify(trimmedFormData);
|
||||
if (endpointType === URL_PARAMS.standalone.name) {
|
||||
search.standalone = DashboardStandaloneMode.HIDE_NAV;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user