mirror of
https://github.com/apache/superset.git
synced 2026-06-08 09:09:27 +00:00
feat: call screenshot to store query_context (#15846)
* feat: call screenshot to store query_context * Add unit test * Move updateQueryContext to ExploreChartPanel * Add error handling * Fix code * Fix logic
This commit is contained in:
@@ -23,11 +23,10 @@ import Button from 'src/components/Button';
|
||||
import { OptionsType } from 'react-select/src/types';
|
||||
import { AsyncSelect } from 'src/components/Select';
|
||||
import rison from 'rison';
|
||||
import { t, SupersetClient, QueryFormData } from '@superset-ui/core';
|
||||
import { t, SupersetClient } from '@superset-ui/core';
|
||||
import Chart, { Slice } from 'src/types/Chart';
|
||||
import { Form, FormItem } from 'src/components/Form';
|
||||
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
|
||||
import { buildV1ChartDataPayload } from '../../exploreUtils';
|
||||
|
||||
type PropertiesModalProps = {
|
||||
slice: Slice;
|
||||
@@ -82,26 +81,6 @@ export default function PropertiesModal({
|
||||
label: `${owner.first_name} ${owner.last_name}`,
|
||||
})),
|
||||
);
|
||||
|
||||
if (chart.query_context === null) {
|
||||
// set query_context if null
|
||||
const queryContext = buildV1ChartDataPayload({
|
||||
formData: slice.form_data as QueryFormData,
|
||||
force: false,
|
||||
resultFormat: 'json',
|
||||
resultType: 'full',
|
||||
setDataMask: null,
|
||||
ownState: null,
|
||||
});
|
||||
|
||||
await SupersetClient.put({
|
||||
endpoint: `/api/v1/chart/${slice.slice_id}`,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
query_context: JSON.stringify(queryContext),
|
||||
}),
|
||||
});
|
||||
}
|
||||
} catch (response) {
|
||||
const clientError = await getClientErrorObject(response);
|
||||
showError(clientError);
|
||||
|
||||
Reference in New Issue
Block a user