-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(native-filters): add refresh button to default value picker #14375
feat(native-filters): add refresh button to default value picker #14375
Conversation
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(); | ||
} | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is mostly copied over 1-1 from ./state.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #14375 +/- ##
==========================================
- Coverage 76.89% 76.86% -0.03%
==========================================
Files 954 954
Lines 48197 48207 +10
Branches 6006 6008 +2
==========================================
- Hits 37062 37056 -6
- Misses 10939 10956 +17
+ Partials 196 195 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
) * feat(native-filters): add refresh button to default value picker * skip flaky test (cherry picked from commit 87a895c)
…che#14375) * feat(native-filters): add refresh button to default value picker * skip flaky test
SUMMARY
Adds feature not automatically always populate the default value picker unless explicitly asked to do so.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
default_loader.mp4
TEST PLAN
ADDITIONAL INFORMATION