geido commented on code in PR #32196:
URL: https://github.com/apache/superset/pull/32196#discussion_r2058651467


##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -513,6 +593,8 @@ const AlertReportModal: 
FunctionComponent<AlertReportModalProps> = ({
   const formatOptionEnabled =
     isFeatureEnabled(FeatureFlag.AlertsAttachReports) || isReport;
   const tabsEnabled = isFeatureEnabled(FeatureFlag.AlertReportTabs);
+  // const filtersEnabled = isFeatureEnabled(FeatureFlag.AlertReportsFilter);
+  const filtersEnabled = true;

Review Comment:
   Just making sure we remove this



##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1126,6 +1384,152 @@ const AlertReportModal: 
FunctionComponent<AlertReportModalProps> = ({
     setForceScreenshot(event.target.checked);
   };
 
+  const onChangeDashboardFilter = (idx: number, nativeFilterId: string) => {
+    // find specific filter tied to the selected filter
+    const filters = Object.values(tabNativeFilters).flat();
+    const filter = filters.filter((f: any) => f.id === nativeFilterId)[0];
+
+    const { filterType } = filter;
+
+    const filterAlreadyExist = nativeFilterData.some(
+      filter => filter.nativeFilterId === nativeFilterId,
+    );
+
+    if (filterAlreadyExist) {
+      addDangerToast(t('This filter already exist on the report'));
+      return;
+    }
+
+    const filterName = filter.name;
+
+    let columnName: string;
+    if (
+      filterType === 'filter_time' ||
+      filterType === 'filter_timecolumn' ||
+      filterType === 'filter_timegrain'
+    ) {
+      columnName = filter.name;
+    } else {
+      columnName = filter.targets[0].column.name;
+    }
+
+    const datasetId = filter.targets[0].datasetId || null;
+
+    const columnLabel = nativeFilterOptions.filter(
+      // @ts-ignore

Review Comment:
   What are these ignores for?



##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -583,6 +665,106 @@ const AlertReportModal: 
FunctionComponent<AlertReportModalProps> = ({
     grace_period: undefined,
   };
 
+  const fetchDashboardFilterValues = async (
+    dashboardId: number | string | undefined,
+    columnName: string,
+    datasetId: string,
+    vizType = 'filter_select',
+  ) => {
+    if (vizType === 'filter_time') {
+      return;
+    }
+
+    const filterValues = {
+      formData: {
+        datasource: `${datasetId}__table`,
+        groupby: [columnName],
+        metrics: ['count'],
+        row_limit: 1000,
+        showSearch: true,
+        viz_type: vizType,
+        type: 'NATIVE_FILTER',
+        dashboardId,
+      },
+      force: false,
+      ownState: {},
+    };
+
+    const data = await getChartDataRequest(filterValues).then(response =>
+      response.json.result[0].data.map((item: any) => {
+        if (vizType === 'filter_timegrain') {
+          return {
+            value: item.duration,
+            label: item.name,
+          };
+        }
+
+        if (vizType === 'filter_timecolumn') {
+          return {
+            value: item.column_name,
+            label: item.verbose_name || item.column_name,
+          };
+        }
+
+        return {
+          value: item[columnName],
+          label: item[columnName],
+        };
+      }),
+    );
+
+    // eslint-disable-next-line consistent-return
+    return data;
+  };
+
+  const addNativeFilterOptions = (nativeFilters: any) => {

Review Comment:
   Can better type definitions be used?



##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -47,7 +48,14 @@ import TimezoneSelector from 
'src/components/TimezoneSelector';
 import { propertyComparator } from 'src/components/Select/utils';
 import withToasts from 'src/components/MessageToasts/withToasts';
 import Owner from 'src/types/Owner';
-import { AntdCheckbox, AsyncSelect, Select, TreeSelect } from 'src/components';
+// todo(hughhh): migrate to src/components/Form

Review Comment:
   @hughhhh it will be important to finalize this TODO before we merge as we 
are completing the work on the theming branch to get rid of direct ant design 
imports. This would be a step in the wrong direction. Thanks!



##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -322,6 +333,55 @@ export const StyledInputContainer = styled.div`
     .input-label {
       margin-left: 10px;
     }
+
+    .filters {
+      margin: 5px 0;

Review Comment:
   Can we use gridUnit for margins and paddings across the styles?



##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1168,6 +1572,55 @@ const AlertReportModal: 
FunctionComponent<AlertReportModalProps> = ({
     });
   };
 
+  const renderFilterValueSelect = (filter: ExtraNativeFilter, idx: number) => {
+    if (!filter) return null; // todo(hugh): Fix this..

Review Comment:
   Is there anything left `todo` here?



-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to