mirror of https://github.com/apache/superset.git
refactor: add set data mask to build query (#13417)
* refactor: add set data mask to build query * refactor: update hooks placement
This commit is contained in:
parent
ca27b00f3a
commit
7f0fbb5b45
|
@ -41,6 +41,7 @@ import { logEvent } from '../logger/actions';
|
|||
import { Logger, LOG_ACTIONS_LOAD_CHART } from '../logger/LogUtils';
|
||||
import { getClientErrorObject } from '../utils/getClientErrorObject';
|
||||
import { allowCrossDomain as domainShardingEnabled } from '../utils/hostNamesConfig';
|
||||
import { updateExtraFormData } from '../dashboard/actions/nativeFilters';
|
||||
|
||||
export const CHART_UPDATE_STARTED = 'CHART_UPDATE_STARTED';
|
||||
export function chartUpdateStarted(queryController, latestQueryFormData, key) {
|
||||
|
@ -163,12 +164,14 @@ const v1ChartDataRequest = async (
|
|||
resultType,
|
||||
force,
|
||||
requestParams,
|
||||
setDataMask,
|
||||
) => {
|
||||
const payload = buildV1ChartDataPayload({
|
||||
formData,
|
||||
resultType,
|
||||
resultFormat,
|
||||
force,
|
||||
setDataMask,
|
||||
});
|
||||
|
||||
// The dashboard id is added to query params for tracking purposes
|
||||
|
@ -200,6 +203,7 @@ const v1ChartDataRequest = async (
|
|||
|
||||
export async function getChartDataRequest({
|
||||
formData,
|
||||
setDataMask = () => {},
|
||||
resultFormat = 'json',
|
||||
resultType = 'full',
|
||||
force = false,
|
||||
|
@ -234,6 +238,7 @@ export async function getChartDataRequest({
|
|||
resultType,
|
||||
force,
|
||||
querySettings,
|
||||
setDataMask,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -361,7 +366,11 @@ export function exploreJSON(
|
|||
};
|
||||
if (dashboardId) requestParams.dashboard_id = dashboardId;
|
||||
|
||||
const setDataMask = filtersState => {
|
||||
dispatch(updateExtraFormData(formData.slice_id, filtersState));
|
||||
};
|
||||
const chartDataRequest = getChartDataRequest({
|
||||
setDataMask,
|
||||
formData,
|
||||
resultFormat: 'json',
|
||||
resultType: 'full',
|
||||
|
|
|
@ -207,6 +207,7 @@ export const buildV1ChartDataPayload = ({
|
|||
force,
|
||||
resultFormat,
|
||||
resultType,
|
||||
setDataMask,
|
||||
}) => {
|
||||
const buildQuery =
|
||||
getChartBuildQueryRegistry().get(formData.viz_type) ??
|
||||
|
@ -216,12 +217,19 @@ export const buildV1ChartDataPayload = ({
|
|||
...baseQueryObject,
|
||||
},
|
||||
]));
|
||||
return buildQuery({
|
||||
...formData,
|
||||
force,
|
||||
result_format: resultFormat,
|
||||
result_type: resultType,
|
||||
});
|
||||
return buildQuery(
|
||||
{
|
||||
...formData,
|
||||
force,
|
||||
result_format: resultFormat,
|
||||
result_type: resultType,
|
||||
},
|
||||
{
|
||||
hooks: {
|
||||
setDataMask,
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
export const getLegacyEndpointType = ({ resultType, resultFormat }) =>
|
||||
|
|
Loading…
Reference in New Issue