You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2021/08/02 20:38:25 UTC

[superset] branch master updated: fix: Fix long dashboards screenshot emails (#15954)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4cb79e5  fix: Fix long dashboards screenshot emails (#15954)
4cb79e5 is described below

commit 4cb79e50172cc857d73dc3ba76f9f2063d97d762
Author: Hugh A. Miles II <hu...@gmail.com>
AuthorDate: Mon Aug 2 16:37:34 2021 -0400

    fix: Fix long dashboards screenshot emails (#15954)
    
    * create serialize json function
    
    * create new setting for reports
    
    * cleanup
    
    * address comments
    
    * up the attributes
---
 .pylintrc                                                  |  2 +-
 .../components/DashboardBuilder/DashboardBuilder.tsx       |  9 +++++----
 superset-frontend/src/dashboard/util/constants.ts          |  1 +
 superset/utils/webdriver.py                                | 14 ++++++++++++++
 4 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index 837291c..b624dfb 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -382,7 +382,7 @@ max-statements=50
 max-parents=7
 
 # Maximum number of attributes for a class (see R0902).
-max-attributes=7
+max-attributes=8
 
 # Minimum number of public methods for a class (see R0903).
 min-public-methods=2
diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
index 614ceb4..cc897b8 100644
--- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
+++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
@@ -181,9 +181,10 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
     rootChildId !== DASHBOARD_GRID_ID
       ? dashboardLayout[rootChildId]
       : undefined;
-  const isStandalone = getUrlParam(URL_PARAMS.standalone);
+  const StandaloneMode = getUrlParam(URL_PARAMS.standalone);
+  const isReport = StandaloneMode === DashboardStandaloneMode.REPORT;
   const hideDashboardHeader =
-    isStandalone === DashboardStandaloneMode.HIDE_NAV_AND_TITLE;
+    StandaloneMode === DashboardStandaloneMode.HIDE_NAV_AND_TITLE || isReport;
 
   const barTopOffset =
     (hideDashboardHeader ? 0 : HEADER_HEIGHT) +
@@ -210,7 +211,7 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
 
   const offset =
     FILTER_BAR_HEADER_HEIGHT +
-    (isSticky || isStandalone ? 0 : MAIN_HEADER_HEIGHT) +
+    (isSticky || StandaloneMode ? 0 : MAIN_HEADER_HEIGHT) +
     (filterSetEnabled ? FILTER_BAR_TABS_HEIGHT : 0);
 
   const filterBarHeight = `calc(100vh - ${offset}px)`;
@@ -255,7 +256,7 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
             <div>
               {!hideDashboardHeader && <DashboardHeader />}
               {dropIndicatorProps && <div {...dropIndicatorProps} />}
-              {topLevelTabs && (
+              {!isReport && topLevelTabs && (
                 <WithPopoverMenu
                   shouldFocus={shouldFocusTabs}
                   menuItems={[
diff --git a/superset-frontend/src/dashboard/util/constants.ts b/superset-frontend/src/dashboard/util/constants.ts
index 917ea36..6fd6247 100644
--- a/superset-frontend/src/dashboard/util/constants.ts
+++ b/superset-frontend/src/dashboard/util/constants.ts
@@ -73,4 +73,5 @@ export const ALL_FILTERS_ROOT = 'ALL_FILTERS_ROOT';
 export enum DashboardStandaloneMode {
   HIDE_NAV = 1,
   HIDE_NAV_AND_TITLE = 2,
+  REPORT = 3,
 }
diff --git a/superset/utils/webdriver.py b/superset/utils/webdriver.py
index 732f52a..dbe94e4 100644
--- a/superset/utils/webdriver.py
+++ b/superset/utils/webdriver.py
@@ -16,6 +16,7 @@
 # under the License.
 
 import logging
+from enum import Enum
 from time import sleep
 from typing import Any, Dict, Optional, Tuple, TYPE_CHECKING
 
@@ -42,6 +43,12 @@ if TYPE_CHECKING:
     from flask_appbuilder.security.sqla.models import User
 
 
+class DashboardStandaloneMode(Enum):
+    HIDE_NAV = 1
+    HIDE_NAV_AND_TITLE = 2
+    REPORT = 3
+
+
 class WebDriverProxy:
     def __init__(
         self, driver_type: str, window: Optional[WindowSize] = None,
@@ -97,6 +104,13 @@ class WebDriverProxy:
         self, url: str, element_name: str, user: "User",
     ) -> Optional[bytes]:
 
+        from requests.models import PreparedRequest
+
+        params = {"standalone": DashboardStandaloneMode.REPORT.value}
+        req = PreparedRequest()
+        req.prepare_url(url, params)
+        url = req.url or ""
+
         driver = self.auth(user)
         driver.set_window_size(*self._window)
         driver.get(url)