You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jo...@apache.org on 2019/01/11 02:22:24 UTC
[incubator-superset] 20/43: fixed expore link issue
This is an automated email from the ASF dual-hosted git repository.
johnbodley pushed a commit to branch feature--embeddable-charts-pilot
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit b13bfeea9b311d3e608753e85dc5b9620357e600
Author: Conglei Shi <co...@airbnb.com>
AuthorDate: Thu Dec 6 13:15:37 2018 -0800
fixed expore link issue
---
.../src/explore/components/EmbedCodeButton.jsx | 5 ++++-
.../src/explore/components/ExploreActionButtons.jsx | 2 +-
.../src/explore/components/ExploreViewContainer.jsx | 6 +++++-
superset/assets/src/explore/exploreUtils.js | 21 +++++++++++++++------
.../src/visualizations/deckgl/Multi/Multi.jsx | 2 +-
.../src/visualizations/nvd3/LineMulti/LineMulti.jsx | 2 +-
6 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/superset/assets/src/explore/components/EmbedCodeButton.jsx b/superset/assets/src/explore/components/EmbedCodeButton.jsx
index ff28fbb..23529df 100644
--- a/superset/assets/src/explore/components/EmbedCodeButton.jsx
+++ b/superset/assets/src/explore/components/EmbedCodeButton.jsx
@@ -31,7 +31,10 @@ export default class EmbedCodeButton extends React.Component {
generateEmbedHTML() {
const srcLink = (
window.location.origin +
- getExploreLongUrl(this.props.latestQueryFormData, 'standalone') +
+ getExploreLongUrl({
+ formData: this.props.latestQueryFormData,
+ endpointType: 'standalone',
+ }) +
`&height=${this.state.height}`
);
return (
diff --git a/superset/assets/src/explore/components/ExploreActionButtons.jsx b/superset/assets/src/explore/components/ExploreActionButtons.jsx
index 6bb059c..7e413cd 100644
--- a/superset/assets/src/explore/components/ExploreActionButtons.jsx
+++ b/superset/assets/src/explore/components/ExploreActionButtons.jsx
@@ -28,7 +28,7 @@ export default function ExploreActionButtons({
<div className="btn-group results" role="group">
{latestQueryFormData &&
<URLShortLinkButton
- url={getExploreLongUrl(latestQueryFormData)}
+ url={getExploreLongUrl({ formData: latestQueryFormData })}
emailSubject="Superset Chart"
emailContent="Check out this chart: "
/>
diff --git a/superset/assets/src/explore/components/ExploreViewContainer.jsx b/superset/assets/src/explore/components/ExploreViewContainer.jsx
index ae52a0b..8bea01f 100644
--- a/superset/assets/src/explore/components/ExploreViewContainer.jsx
+++ b/superset/assets/src/explore/components/ExploreViewContainer.jsx
@@ -171,7 +171,11 @@ class ExploreViewContainer extends React.Component {
addHistory({ isReplace = false, title }) {
const { payload } = getExploreUrlAndPayload({ formData: this.props.form_data });
- const longUrl = getExploreLongUrl(this.props.form_data, null, false);
+ const longUrl = getExploreLongUrl({
+ formData: this.props.form_data,
+ forceExplore: true,
+ allowOverflow: false,
+ });
try {
if (isReplace) {
history.replaceState(payload, title, longUrl);
diff --git a/superset/assets/src/explore/exploreUtils.js b/superset/assets/src/explore/exploreUtils.js
index 607dce7..d06b2ac 100644
--- a/superset/assets/src/explore/exploreUtils.js
+++ b/superset/assets/src/explore/exploreUtils.js
@@ -34,26 +34,36 @@ export function getAnnotationJsonUrl(slice_id, form_data, isNative) {
}).toString();
}
-export function getURIDirectory(formData, endpointType = 'base') {
+export function getURIDirectory({
+ formData,
+ endpointType = 'base',
+ forceExplore,
+}) {
// Building the directory part of the URI
let directory = '/superset/explore/';
if (['json', 'csv', 'query', 'results', 'samples'].indexOf(endpointType) >= 0) {
directory = '/superset/explore_json/';
}
// const buildQueryRegistry = getChartBuildQueryRegistry();
- if (formData.viz_type === 'word_cloud') {
+ if (formData.viz_type === 'word_cloud' && !forceExplore) {
directory = '/api/v1/query/';
}
return directory;
}
-export function getExploreLongUrl(formData, endpointType, allowOverflow = true, extraSearch = {}) {
+export function getExploreLongUrl({
+ formData,
+ endpointType,
+ forceExplore = false,
+ allowOverflow = true,
+ extraSearch = {},
+}) {
if (!formData.datasource) {
return null;
}
const uri = new URI('/');
- const directory = getURIDirectory(formData, endpointType);
+ const directory = getURIDirectory({ formData, endpointType, forceExplore });
const search = uri.search(true);
Object.keys(extraSearch).forEach((key) => {
search[key] = extraSearch[key];
@@ -100,7 +110,7 @@ export function getExploreUrlAndPayload({
uri = URI(URI(curUrl).search());
}
- const directory = getURIDirectory(formData, endpointType);
+ const directory = getURIDirectory({ formData, endpointType });
// Building the querystring (search) part of the URI
const search = uri.search(true);
@@ -138,7 +148,6 @@ export function getExploreUrlAndPayload({
const buildQuery = getChartBuildQueryRegistry().get(formData.viz_type);
if (buildQuery) {
- console.log(formData);
payload = { query_context: buildQuery(formData) };
}
diff --git a/superset/assets/src/visualizations/deckgl/Multi/Multi.jsx b/superset/assets/src/visualizations/deckgl/Multi/Multi.jsx
index 50dfa4b..0669e0b 100644
--- a/superset/assets/src/visualizations/deckgl/Multi/Multi.jsx
+++ b/superset/assets/src/visualizations/deckgl/Multi/Multi.jsx
@@ -49,7 +49,7 @@ class DeckMulti extends React.PureComponent {
};
SupersetClient.get({
- endpoint: getExploreLongUrl(subsliceCopy.form_data, 'json'),
+ endpoint: getExploreLongUrl({ formData: subsliceCopy.form_data, endpointType: 'json' }),
})
.then(({ json }) => {
const layer = layerGenerators[subsliceCopy.form_data.viz_type](
diff --git a/superset/assets/src/visualizations/nvd3/LineMulti/LineMulti.jsx b/superset/assets/src/visualizations/nvd3/LineMulti/LineMulti.jsx
index 42efb7b..11d9544 100644
--- a/superset/assets/src/visualizations/nvd3/LineMulti/LineMulti.jsx
+++ b/superset/assets/src/visualizations/nvd3/LineMulti/LineMulti.jsx
@@ -81,7 +81,7 @@ class LineMulti extends React.Component {
time_range: timeRange,
};
const addPrefix = prefixMetricWithSliceName;
- return getJson(getExploreLongUrl(combinedFormData, 'json'))
+ return getJson(getExploreLongUrl({ formData: combinedFormData, endpointType: 'json' }))
.then(data => data.map(({ key, values }) => ({
key: addPrefix ? `${subslice.slice_name}: ${key}` : key,
type: combinedFormData.viz_type,