Skip to content

Commit

Permalink
Move useLegacyApi inquiry to exploreUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed May 18, 2020
1 parent fe93273 commit 4e02f4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 3 additions & 5 deletions superset-frontend/src/chart/chartAction.js
Expand Up @@ -20,13 +20,11 @@
/* eslint no-param-reassign: ["error", { "props": false }] */
import moment from 'moment';
import { t } from '@superset-ui/translation';
import {
getChartBuildQueryRegistry,
getChartMetadataRegistry,
} from '@superset-ui/chart';
import { getChartBuildQueryRegistry } from '@superset-ui/chart';
import { SupersetClient } from '@superset-ui/connection';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import {
shouldUseLegacyApi,
getExploreUrl,
getAnnotationJsonUrl,
postForm,
Expand Down Expand Up @@ -260,7 +258,7 @@ export function exploreJSON(
const logStart = Logger.getTimestamp();
const controller = new AbortController();

const { useLegacyApi } = getChartMetadataRegistry().get(formData.viz_type);
const useLegacyApi = shouldUseLegacyApi(formData);

let requestParams = {
signal: controller.signal,
Expand Down
11 changes: 8 additions & 3 deletions superset-frontend/src/explore/exploreUtils.js
Expand Up @@ -18,6 +18,7 @@
*/
/* eslint camelcase: 0 */
import URI from 'urijs';
import { getChartMetadataRegistry } from '@superset-ui/chart';
import { availableDomains } from '../utils/hostNamesConfig';
import { safeStringify } from '../utils/safeStringify';

Expand Down Expand Up @@ -65,13 +66,12 @@ export function getAnnotationJsonUrl(slice_id, form_data, isNative) {

export function getURIDirectory(endpointType = 'base') {
// Building the directory part of the URI
let directory = '/superset/explore/';
if (
['json', 'csv', 'query', 'results', 'samples'].indexOf(endpointType) >= 0
) {
directory = '/superset/explore_json/';
return '/superset/explore_json/';
}
return directory;
return '/superset/explore/';
}

export function getExploreLongUrl(
Expand Down Expand Up @@ -107,6 +107,11 @@ export function getExploreLongUrl(
return url;
}

export function shouldUseLegacyApi(formData) {
const { useLegacyApi } = getChartMetadataRegistry().get(formData.viz_type);
return useLegacyApi || false;
}

export function getExploreUrl({
formData,
endpointType = 'base',
Expand Down

0 comments on commit 4e02f4e

Please sign in to comment.