diff --git a/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx b/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx index 3ebb1643a6a8b..dff3a9b5268f2 100644 --- a/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx +++ b/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx @@ -46,13 +46,11 @@ export default function HeaderReportActionsDropDown({ chart?: ChartState; }) { const dispatch = useDispatch(); - const reports: any = useSelector(state => - Object.values(state.reports).filter((report: any) => - dashboardId - ? report.dashboard_id === dashboardId - : report.chart_id === chart?.id, - ), + const reports: Record = useSelector( + state => state.reports, ); + const report: AlertObject = Object.values(reports)[0]; + const hasReport = !!report; const user: UserWithPermissionsAndRoles = useSelector< any, UserWithPermissionsAndRoles @@ -63,7 +61,6 @@ export default function HeaderReportActionsDropDown({ ] = useState(null); const theme = useTheme(); const [showModal, setShowModal] = useState(false); - const [showModal, setShowModal] = useState(false); const toggleActiveKey = async (data: AlertObject, checked: boolean) => { if (data?.id) { toggleActive(data, checked); @@ -103,10 +100,21 @@ export default function HeaderReportActionsDropDown({ }), ); } - return () => { - }; }, []); + useEffect(() => { + if (hasReport && report.dashboard_id !== dashboardId) { + dispatch( + fetchUISpecificReport({ + userId: user.userId, + filterField: dashboardId ? 'dashboard_id' : 'chart_id', + creationMethod: dashboardId ? 'dashboards' : 'charts', + resourceId: dashboardId || chart?.id, + }), + ); + } + }, [dashboardId]); + const menu = () => ( diff --git a/superset-frontend/src/views/CRUD/alert/types.ts b/superset-frontend/src/views/CRUD/alert/types.ts index 3f939a03bcfa1..24e5ddf13770a 100644 --- a/superset-frontend/src/views/CRUD/alert/types.ts +++ b/superset-frontend/src/views/CRUD/alert/types.ts @@ -66,6 +66,7 @@ export type AlertObject = { created_on?: string; crontab?: string; dashboard?: MetaObject; + dashboard_id?: number; database?: MetaObject; description?: string; grace_period?: number;