mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
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 { styled } from '@superset-ui/core';
|
||||||
import { isEqual } from 'lodash';
|
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 ChartContainer from 'src/chart/ChartContainer';
|
||||||
import {
|
import {
|
||||||
LOG_ACTIONS_CHANGE_DASHBOARD_FILTER,
|
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) {
|
exportCSV(isFullCSV = false) {
|
||||||
this.props.logEvent(LOG_ACTIONS_EXPORT_CSV_DASHBOARD_CHART, {
|
this.props.logEvent(LOG_ACTIONS_EXPORT_CSV_DASHBOARD_CHART, {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { getExploreLongUrl } from '.';
|
import { getExploreLongUrl, getExploreUrlFromDashboard } from '.';
|
||||||
|
|
||||||
const createParams = () => ({
|
const createParams = () => ({
|
||||||
formData: {
|
formData: {
|
||||||
@ -108,8 +108,12 @@ test('Get url from a dashboard', () => {
|
|||||||
lots: 'of other stuff here too',
|
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',
|
'/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;
|
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 uri = new URI('/');
|
||||||
const directory = getURIDirectory(endpointType);
|
const directory = getURIDirectory(endpointType);
|
||||||
const search = uri.search(true);
|
const search = uri.search(true);
|
||||||
Object.keys(extraSearch).forEach(key => {
|
Object.keys(extraSearch).forEach(key => {
|
||||||
search[key] = extraSearch[key];
|
search[key] = extraSearch[key];
|
||||||
});
|
});
|
||||||
search.form_data = safeStringify(trimmedFormData);
|
search.form_data = safeStringify(formData);
|
||||||
if (endpointType === URL_PARAMS.standalone.name) {
|
if (endpointType === URL_PARAMS.standalone.name) {
|
||||||
search.standalone = DashboardStandaloneMode.HIDE_NAV;
|
search.standalone = DashboardStandaloneMode.HIDE_NAV;
|
||||||
}
|
}
|
||||||
@ -133,6 +127,15 @@ export function getExploreLongUrl(
|
|||||||
return url;
|
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 }) {
|
export function getChartDataUri({ path, qs, allowDomainSharding = false }) {
|
||||||
// The search params from the window.location are carried through,
|
// The search params from the window.location are carried through,
|
||||||
// but can be specified with curUrl (used for unit tests to spoof
|
// but can be specified with curUrl (used for unit tests to spoof
|
||||||
|
Loading…
Reference in New Issue
Block a user