geido commented on code in PR #32196:
URL: https://github.com/apache/superset/pull/32196#discussion_r1979832374
##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -35,10 +35,15 @@ import {
SupersetTheme,
t,
VizType,
+ useTheme,
} from '@superset-ui/core';
import rison from 'rison';
import { useSingleViewResource } from 'src/views/CRUD/hooks';
+import { AntdForm } from 'src/components';
Review Comment:
Can we use `src/components/Form` instead? We are gradually removing these
exports.
##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1767,7 +1898,103 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
onSelect={updateAnchorState}
placeholder={t('Select a tab')}
/>
- </>
+ </div>
+ <AntdForm
+ name="form1"
+ autoComplete="off"
+ style={{ margin: '5px 0' }}
Review Comment:
Let's use `css` from Emotion
##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -825,16 +852,27 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
endpoint: `/api/v1/dashboard/${dashboard.value}/tabs`,
})
.then(response => {
- const { tab_tree: tabTree, all_tabs: allTabs } =
response.json.result;
+ const {
+ tab_tree: tabTree,
+ all_tabs: allTabs,
+ native_filters: nativeFilters,
+ } = response.json.result;
tabTree.push({
title: 'All Tabs',
// select tree only works with string value
value: JSON.stringify(Object.keys(allTabs)),
});
setTabOptions(tabTree);
+ setTabNativeFilters(nativeFilters);
const anchor = currentAlert?.extra?.dashboard?.anchor;
if (anchor) {
+ setNativeFilterOptions(
Review Comment:
Do we need to handle both `setTabNativeFilters` and
`setNativeFilterOptions`? It seems that nativeFiltersOptions can be extracted
from the former
##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -665,6 +680,18 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
const shouldEnableForceScreenshot =
contentType === ContentType.Chart && !isReport;
+
+ // todo(hughhh): refactor to handle multiple native filters
+ console.log('nativeFilterData', nativeFilterData);
+ currentAlert.extra.dashboard.nativeFilters = nativeFilterData.map(
+ filter => ({
+ columnName: filter.columnName,
+ columnLabel: filter.columnLabel,
+ nativeFilterId: filter.nativeFilterId,
+ filterValues: filter.filterValues,
+ }),
+ );
Review Comment:
```suggestion
currentAlert.extra.dashboard.nativeFilters = nativeFilterData.map(({
columnName, columnLabel, nativeFilterId, filterValues }) => ({
columnName,
columnLabel,
nativeFilterId,
filterValues,
}));
##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -454,6 +462,13 @@ const AlertReportModal:
FunctionComponent<AlertReportModalProps> = ({
const [dashboardOptions, setDashboardOptions] = useState<MetaObject[]>([]);
const [chartOptions, setChartOptions] = useState<MetaObject[]>([]);
const [tabOptions, setTabOptions] = useState<TabNode[]>([]);
+ const [nativeFilterOptions, setNativeFilterOptions] = useState<object>([]);
+ const [nativeFilterValues, setNativeFilterValues] = useState<object>([]);
+ const [tabNativeFilters, setTabNativeFilters] = useState<object>({});
Review Comment:
I think the name might be confusing here. It seems this is hosting all
native filters independently of the current tab?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]