mirror of https://github.com/apache/superset.git
small changes to dashboard->explore code (#17145)
This commit is contained in:
parent
bedb8f4dff
commit
a63a01f158
|
@ -22,7 +22,10 @@ import PropTypes from 'prop-types';
|
|||
import { styled } from '@superset-ui/core';
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import { exportChart, getExploreLongUrl } from 'src/explore/exploreUtils';
|
||||
import {
|
||||
exportChart,
|
||||
getExploreUrlFromDashboard,
|
||||
} from 'src/explore/exploreUtils';
|
||||
import ChartContainer from 'src/chart/ChartContainer';
|
||||
import {
|
||||
LOG_ACTIONS_CHANGE_DASHBOARD_FILTER,
|
||||
|
@ -230,7 +233,7 @@ export default class Chart extends React.Component {
|
|||
});
|
||||
};
|
||||
|
||||
getChartUrl = () => getExploreLongUrl(this.props.formData, null, false);
|
||||
getChartUrl = () => getExploreUrlFromDashboard(this.props.formData);
|
||||
|
||||
exportCSV(isFullCSV = false) {
|
||||
this.props.logEvent(LOG_ACTIONS_EXPORT_CSV_DASHBOARD_CHART, {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { getExploreLongUrl } from '.';
|
||||
import { getExploreLongUrl, getExploreUrlFromDashboard } from '.';
|
||||
|
||||
const createParams = () => ({
|
||||
formData: {
|
||||
|
@ -108,8 +108,12 @@ test('Get url from a dashboard', () => {
|
|||
lots: 'of other stuff here too',
|
||||
},
|
||||
},
|
||||
url_params: {
|
||||
native_filters: '(blah)',
|
||||
standalone: true,
|
||||
},
|
||||
};
|
||||
expect(getExploreLongUrl(formData, null, false)).toBe(
|
||||
expect(getExploreUrlFromDashboard(formData)).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',
|
||||
);
|
||||
});
|
||||
|
|
|
@ -104,19 +104,13 @@ 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(trimmedFormData);
|
||||
search.form_data = safeStringify(formData);
|
||||
if (endpointType === URL_PARAMS.standalone.name) {
|
||||
search.standalone = DashboardStandaloneMode.HIDE_NAV;
|
||||
}
|
||||
|
@ -133,6 +127,15 @@ export function getExploreLongUrl(
|
|||
return url;
|
||||
}
|
||||
|
||||
export function getExploreUrlFromDashboard(formData) {
|
||||
// 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']);
|
||||
return getExploreLongUrl(trimmedFormData, null, false);
|
||||
}
|
||||
|
||||
export function getChartDataUri({ path, qs, allowDomainSharding = false }) {
|
||||
// The search params from the window.location are carried through,
|
||||
// but can be specified with curUrl (used for unit tests to spoof
|
||||
|
|
Loading…
Reference in New Issue