This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch hm/ar-filters
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/hm/ar-filters by this push:
new 891e7f3c7d ok add label
891e7f3c7d is described below
commit 891e7f3c7dfdf5ba4fa5f23d52f8c1d6cba83cc0
Author: Hugh Miles <[email protected]>
AuthorDate: Mon Feb 10 14:37:11 2025 -0500
ok add label
---
.../src/features/alerts/AlertReportModal.tsx | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/superset-frontend/src/features/alerts/AlertReportModal.tsx
b/superset-frontend/src/features/alerts/AlertReportModal.tsx
index 222a3dde24..60b4b9aa25 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.tsx
@@ -79,6 +79,7 @@ import StyledPanel from './components/StyledPanel';
import { buildErrorTooltipMessage } from './buildErrorTooltipMessage';
import { getChartDataRequest } from 'src/components/Chart/chartAction';
import { getFormData } from '../../utils';
+import { native } from 'rimraf';
const TIMEOUT_MIN = 1;
const TEXT_BASED_VISUALIZATION_TYPES = [
@@ -458,6 +459,7 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
const [tabOptions, setTabOptions] = useState<TabNode[]>([]);
const [nativeFilterOptions, setNativeFilterOptions] = useState<object>([]);
const [nativeFilterValues, setNativeFilterValues] = useState<object>([]);
+ const [tabNativeFilters, setTabNativeFilters] = useState<object>({});
// todo(hughhh): refactor to handle multiple native filters
const [nativeFilter, setSelectedNativeFilter] = useState<object>({});
@@ -848,6 +850,7 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
value: JSON.stringify(Object.keys(allTabs)),
});
setTabOptions(tabTree);
+ setTabNativeFilters(nativeFilters);
const anchor = currentAlert?.extra?.dashboard?.anchor;
if (anchor) {
@@ -1135,15 +1138,20 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
};
const onChangeDashboardFilter = (nativeFilterId: string) => {
+ console.log('dashboardFilter', nativeFilterId);
+
// set dashboardFilter
const anchor = currentAlert?.extra?.dashboard?.anchor;
- const inScopeFilters = nativeFilters[anchor];
+ const inScopeFilters = tabNativeFilters[anchor];
const filter = inScopeFilters.filter(
(f: any) => f.id === nativeFilterId,
)[0];
const { datasetId } = filter.targets[0];
const columnName = filter.targets[0].column.name;
+ const columnLabel = nativeFilterOptions.filter(
+ filter => filter.value === nativeFilterId,
+ )[0].label;
const dashboardId = currentAlert?.dashboard?.value;
// Get values tied to the selected filter
@@ -1174,7 +1182,12 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
force: false,
ownState: {},
};
- setSelectedNativeFilter({ ...nativeFilter, columnName, nativeFilterId });
+ setSelectedNativeFilter({
+ ...nativeFilter,
+ columnName,
+ columnLabel,
+ nativeFilterId,
+ });
getChartDataRequest(filterValues).then(response => {
setNativeFilterValues(
response.json.result[0].data.map((item: any) => ({
@@ -1376,7 +1389,6 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
if (resource) {
console.log('editting...', resource);
// Add native filter settings
- const nativeFilterOptionLabel = nativeFilterOptions.find(
setSelectedNativeFilter(resource.extra?.dashboard.nativeFilters[0]);
// Add notification settings
@@ -1867,7 +1879,7 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
<Select
disabled={nativeFilterOptions?.length < 1}
ariaLabel={t('Select Filter')}
- value={nativeFilter.columnName}
+ value={nativeFilter.columnLabel}
options={nativeFilterOptions}
onChange={onChangeDashboardFilter}
/>