mistercrunch commented on code in PR #34178:
URL: https://github.com/apache/superset/pull/34178#discussion_r2249320671


##########
superset-frontend/src/features/reports/ReportModal/HeaderReportDropdown/index.tsx:
##########
@@ -85,63 +60,59 @@ const DropdownItemExtension = extensionsRegistry.get(
   'report-modal.dropdown.item.icon',
 );
 
-export enum CreationMethod {
-  Charts = 'charts',
-  Dashboards = 'dashboards',
-}
 export interface HeaderReportProps {
   dashboardId?: number;
   chart?: ChartState;
-  useTextMenu?: boolean;
-  setShowReportSubMenu?: (show: boolean) => void;
-  showReportSubMenu?: boolean;
-  submenuTitle?: string;
   showReportModal: () => void;
   setCurrentReportDeleting: (report: AlertObject | null) => void;
 }
 
-// Same instance to be used in useEffects
-const EMPTY_OBJECT = {};
-
-export default function HeaderReportDropDown({
+export const useHeaderReportMenuItems = ({
   dashboardId,
   chart,
-  useTextMenu = false,
-  setShowReportSubMenu,
-  submenuTitle,
   showReportModal,
   setCurrentReportDeleting,
-}: HeaderReportProps) {
+}: HeaderReportProps): MenuItem | null => {
   const dispatch = useDispatch();
-  const report = useSelector<any, AlertObject>(state => {
-    const resourceType = dashboardId
-      ? CreationMethod.Dashboards
-      : CreationMethod.Charts;
-    return (
-      reportSelector(state, resourceType, dashboardId || chart?.id) ||
-      EMPTY_OBJECT
-    );
+  const resourceId = dashboardId || chart?.id;
+  const resourceType = dashboardId
+    ? CreationMethod.Dashboards
+    : CreationMethod.Charts;
+
+  // Select the reports state and specific report with proper reactivity
+  const report = useSelector<any, AlertObject | null>(state => {
+    if (!resourceId) return null;
+    // Select directly from the reports state to ensure reactivity
+    const reportsState = state.reports || {};
+    const resourceTypeReports = reportsState[resourceType] || {};
+    const reportData = resourceTypeReports[resourceId];
+
+    // Debug logging to understand what's happening

Review Comment:
   About the linter, we should set to error and fix the ones around the app. I 
believe we have a legit console logger someplace in the app that we can use and 
shuts itself off in prod but logs in dev.



-- 
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