From 156deac2e18a860a03d8568126b704092502223f Mon Sep 17 00:00:00 2001 From: AAfghahi <48933336+AAfghahi@users.noreply.github.com> Date: Fri, 20 Aug 2021 18:04:57 -0400 Subject: [PATCH] continued refactoring (#16377) --- .../HeaderReportActionsDropdown/index.tsx | 22 ++++++++++++++++--- .../components/DataTablesPane/index.tsx | 1 - 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx b/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx index 6e42b07531b4c..f9fdca066556e 100644 --- a/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx +++ b/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { t, SupersetTheme, css, useTheme } from '@superset-ui/core'; import Icons from 'src/components/Icons'; @@ -55,14 +55,13 @@ export default function HeaderReportActionsDropDown({ >(state => state.user || state.explore?.user); const reportsIds = Object.keys(reports || []); const report: AlertObject = reports?.[reportsIds[0]]; - console.log(report); const [ currentReportDeleting, setCurrentReportDeleting, ] = useState(null); const theme = useTheme(); const [showModal, setShowModal] = useState(false); - + const dashboardIdRef = useRef(dashboardId); const toggleActiveKey = async (data: AlertObject, checked: boolean) => { if (data?.id) { toggleActive(data, checked); @@ -104,6 +103,23 @@ export default function HeaderReportActionsDropDown({ } }, []); + useEffect(() => { + if ( + canAddReports() && + dashboardId && + dashboardId !== dashboardIdRef.current + ) { + dispatch( + fetchUISpecificReport({ + userId: user.userId, + filterField: 'dashboard_id', + creationMethod: 'dashboards', + resourceId: dashboardId, + }), + ); + } + }, [dashboardId]); + const menu = () => ( diff --git a/superset-frontend/src/explore/components/DataTablesPane/index.tsx b/superset-frontend/src/explore/components/DataTablesPane/index.tsx index 596cec89a0e57..deb95ef285545 100644 --- a/superset-frontend/src/explore/components/DataTablesPane/index.tsx +++ b/superset-frontend/src/explore/components/DataTablesPane/index.tsx @@ -217,7 +217,6 @@ export const DataTablesPane = ({ }, [queryFormData], ); - console.log(queryFormData); useEffect(() => { setInLocalStorage(STORAGE_KEYS.isOpen, panelOpen); }, [panelOpen]);