fix: Fix long dashboards screenshot emails (#15954)

* create serialize json function

* create new setting for reports

* cleanup

* address comments

* up the attributes
This commit is contained in:
Hugh A. Miles II 2021-08-02 16:37:34 -04:00 committed by GitHub
parent 41e8190575
commit 4cb79e5017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 5 deletions

View File

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

View File

@ -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={[

View File

@ -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,
}

View File

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