You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2023/08/21 13:47:21 UTC
[superset] 01/05: chore: Pass the dashboard id when requesting filter values (#25025)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 88383ded80cf0a82dd4ed07917140bcb51b95701
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Fri Aug 18 13:19:19 2023 -0300
chore: Pass the dashboard id when requesting filter values (#25025)
(cherry picked from commit 52c7186b56a1591679bdc1dc537f92f545646074)
---
superset-frontend/src/components/Chart/chartAction.js | 1 -
.../nativeFilters/FilterBar/FilterControls/FilterValue.tsx | 5 ++++-
.../FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx | 6 ++++--
superset-frontend/src/dashboard/components/nativeFilters/utils.ts | 3 +++
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/superset-frontend/src/components/Chart/chartAction.js b/superset-frontend/src/components/Chart/chartAction.js
index c204d58ebe..d08070fe40 100644
--- a/superset-frontend/src/components/Chart/chartAction.js
+++ b/superset-frontend/src/components/Chart/chartAction.js
@@ -228,7 +228,6 @@ export async function getChartDataRequest({
credentials: 'include',
};
}
-
const [useLegacyApi, parseMethod] = getQuerySettings(formData);
if (useLegacyApi) {
return legacyChartDataRequest(
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
index b64f1bc8d9..5235edcdc3 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
@@ -101,6 +101,9 @@ const FilterValue: React.FC<FilterControlProps> = ({
const dependencies = useFilterDependencies(id, dataMaskSelected);
const shouldRefresh = useShouldFilterRefresh();
const [state, setState] = useState<ChartDataResponseResult[]>([]);
+ const dashboardId = useSelector<RootState, number>(
+ state => state.dashboardInfo.id,
+ );
const [error, setError] = useState<ClientErrorObject>();
const [formData, setFormData] = useState<Partial<QueryFormData>>({
inView: false,
@@ -146,6 +149,7 @@ const FilterValue: React.FC<FilterControlProps> = ({
groupby,
adhoc_filters,
time_range,
+ dashboardId,
});
const filterOwnState = filter.dataMask?.ownState || {};
// TODO: We should try to improve our useEffect hooks to depend more on
@@ -170,7 +174,6 @@ const FilterValue: React.FC<FilterControlProps> = ({
getChartDataRequest({
formData: newFormData,
force: false,
- requestParams: { dashboardId: 0 },
ownState: filterOwnState,
})
.then(({ response, json }) => {
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
index dcfbf3d43d..94b336af92 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx
@@ -354,7 +354,9 @@ const FiltersConfigForm = (
const [activeTabKey, setActiveTabKey] = useState<string>(
FilterTabs.configuration.key,
);
-
+ const dashboardId = useSelector<RootState, number>(
+ state => state.dashboardInfo.id,
+ );
const [undoFormValues, setUndoFormValues] = useState<Record<
string,
any
@@ -479,6 +481,7 @@ const FiltersConfigForm = (
}
const formData = getFormData({
datasetId: formFilter?.dataset?.value,
+ dashboardId,
groupby: formFilter?.column,
...formFilter,
});
@@ -492,7 +495,6 @@ const FiltersConfigForm = (
getChartDataRequest({
formData,
force,
- requestParams: { dashboardId: 0 },
})
.then(({ response, json }) => {
if (isFeatureEnabled(FeatureFlag.GLOBAL_ASYNC_QUERIES)) {
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/utils.ts b/superset-frontend/src/dashboard/components/nativeFilters/utils.ts
index 7086ac8512..b4284a8a63 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/utils.ts
+++ b/superset-frontend/src/dashboard/components/nativeFilters/utils.ts
@@ -54,7 +54,9 @@ export const getFormData = ({
time_range,
granularity_sqla,
type,
+ dashboardId,
}: Partial<Filter> & {
+ dashboardId: number;
datasetId?: number;
dependencies?: object;
groupby?: string;
@@ -91,6 +93,7 @@ export const getFormData = ({
inView: true,
viz_type: filterType,
type,
+ dashboardId,
};
};