villebro commented on a change in pull request #14375:
URL: https://github.com/apache/superset/pull/14375#discussion_r621248918
##########
File path:
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
##########
@@ -153,7 +172,56 @@ export const FiltersConfigForm:
React.FC<FiltersConfigFormProps> = ({
formFilter?.filterType,
);
- useBackendFormUpdate(form, filterId, filterToEdit, hasDataset, hasColumn);
+ const isDataDirty = formFilter?.isDataDirty ?? true;
+
+ useBackendFormUpdate(form, filterId);
+
+ const refreshHandler = () => {
+ if (!hasDataset || !formFilter?.dataset?.value) {
+ forceUpdate();
+ return;
+ }
+ const formData = getFormData({
+ datasetId: formFilter?.dataset?.value,
+ groupby: formFilter?.column,
+ defaultValue: formFilter?.defaultValue,
+ ...formFilter,
+ });
+ setNativeFilterFieldValues(form, filterId, {
+ defaultValueQueriesData: null,
+ isDataDirty: false,
+ });
+ forceUpdate();
+ getChartDataRequest({
+ formData,
+ force: false,
+ requestParams: { dashboardId: 0 },
+ }).then(response => {
+ if (isFeatureEnabled(FeatureFlag.GLOBAL_ASYNC_QUERIES)) {
+ // deal with getChartDataRequest transforming the response data
+ const result = 'result' in response ? response.result[0] : response;
+ waitForAsyncData(result)
+ .then((asyncResult: ChartDataResponseResult[]) => {
+ setNativeFilterFieldValues(form, filterId, {
+ defaultValueQueriesData: asyncResult,
+ });
+ forceUpdate();
+ })
+ .catch((error: ClientErrorObject) => {
+ // TODO: show error once this logic is moved into new NativeFilter
+ // component
+ console.error(
+ error.message || error.error || t('Check configuration'),
+ );
+ });
+ } else {
+ setNativeFilterFieldValues(form, filterId, {
+ defaultValueQueriesData: response.result,
+ });
+ forceUpdate();
+ }
+ });
+ };
Review comment:
This logic is mostly copied over 1-1 from `./state.ts`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]