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


##########
superset-frontend/src/dashboard/containers/DashboardPage.tsx:
##########
@@ -147,6 +147,7 @@ export const DashboardPage: FC<PageProps> = ({ idOrSlug }: 
PageProps) => {
         if (!isDashboardHydrated.current) {
           isDashboardHydrated.current = true;
         }
+        console.log('active tabs:', activeTabs);

Review Comment:
   ```suggestion
   ```



##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -774,6 +798,25 @@ const AlertReportModal: 
FunctionComponent<AlertReportModalProps> = ({
     [],
   );
 
+  const dashboard = currentAlert?.dashboard;
+  useEffect(() => {
+    if (!tabsEnabled) return;
+
+    if (dashboard?.value) {
+      SupersetClient.get({
+        endpoint: `/api/v1/dashboard/${dashboard.value}/tabs`,
+      }).then(response => {
+        const { tab_tree: tabTree, all_tabs: allTabs } = response.json.result;
+        setTabOptions(tabTree);
+        if (currentAlert?.extra?.dashboard?.anchor) {
+          if (!(currentAlert?.extra?.dashboard?.anchor in allTabs)) {
+            updateAnchorState('');
+          }
+        }
+      });
+    }
+  }, [dashboard, tabsEnabled, currentAlert?.extra]);

Review Comment:
   ```suggestion
     }, [dashboard?.value, tabsEnabled, currentAlert?.extra]);
   ```



##########
superset-frontend/src/features/alerts/AlertReportModal.tsx:
##########
@@ -1602,6 +1649,21 @@ const AlertReportModal: 
FunctionComponent<AlertReportModalProps> = ({
               </>
             )}
           </StyledInputContainer>
+          {tabsEnabled && contentType === 'dashboard' && (
+            <StyledInputContainer>
+              <>
+                <div className="control-label">{t('Select tab')}</div>
+                <TreeSelect
+                  disabled={tabOptions?.length === 0}
+                  treeData={tabOptions}
+                  value={currentAlert?.extra?.dashboard?.anchor}
+                  onSelect={updateAnchorState}
+                  style={{ width: '100%' }}

Review Comment:
   Can we use styled or css from emotion for this?



##########
superset/commands/report/execute.py:
##########
@@ -168,15 +168,15 @@ def _get_url(
                 force=force,
                 **kwargs,
             )
-
         # If we need to render dashboard in a specific state, use stateful 
permalink
-        if dashboard_state := self._report_schedule.extra.get("dashboard"):
+        if (
+            dashboard_state := self._report_schedule.extra.get("dashboard")
+        ) and feature_flag_manager.is_feature_enabled("ALERT_REPORT_TABS"):

Review Comment:
   Is this supposed to be an `and`?



##########
superset-frontend/src/features/alerts/AlertReportModal.test.tsx:
##########
@@ -413,6 +420,21 @@ test('renders screenshot options when dashboard is 
selected', async () => {
   ).toBeInTheDocument();
 });
 
+test('renders tab selection when Dashboard is selected', async () => {
+  render(<AlertReportModal {...generateMockedProps(false, true, true)} />, {
+    useRedux: true,
+  });
+  userEvent.click(screen.getByTestId('contents-panel'));
+  await screen.findByText(/test dashboard/i);
+  expect(
+    screen.getByRole('combobox', { name: /select content type/i }),
+  ).toBeInTheDocument();
+  expect(
+    screen.getByRole('combobox', { name: /dashboard/i }),
+  ).toBeInTheDocument();
+  expect(screen.getByText(/select tab/i)).toBeInTheDocument();

Review Comment:
   Should we verify that the TreeSelect renders and has some options?



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