diff --git a/superset-frontend/src/chart/chartAction.js b/superset-frontend/src/chart/chartAction.js index 45341bbcccd9..3b46ae1498e6 100644 --- a/superset-frontend/src/chart/chartAction.js +++ b/superset-frontend/src/chart/chartAction.js @@ -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, @@ -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, diff --git a/superset-frontend/src/explore/exploreUtils.js b/superset-frontend/src/explore/exploreUtils.js index d54144e35ad6..63706e851562 100644 --- a/superset-frontend/src/explore/exploreUtils.js +++ b/superset-frontend/src/explore/exploreUtils.js @@ -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'; @@ -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( @@ -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',