You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2021/11/24 18:46:46 UTC

[superset] 12/14: continued refactoring (#16377)

This is an automated email from the ASF dual-hosted git repository.

elizabeth pushed a commit to branch refactorReports
in repository https://gitbox.apache.org/repos/asf/superset.git

commit d6b758ee090601b59debd5bde4a50737c4b3c0fd
Author: AAfghahi <48...@users.noreply.github.com>
AuthorDate: Fri Aug 20 18:04:57 2021 -0400

    continued refactoring (#16377)
---
 .../HeaderReportActionsDropdown/index.tsx           | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx b/superset-frontend/src/components/ReportModal/HeaderReportActionsDropdown/index.tsx
index d6e6ec3..40a7c35 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,13 +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<AlertObject | null>(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);
@@ -103,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 = () => (
     <Menu selectable={false} css={{ width: '200px' }}>
       <Menu.Item>