Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix long dashboards screenshot emails #15954

Merged
merged 13 commits into from
Aug 2, 2021
Merged

Conversation

hughhhh
Copy link
Member

@hughhhh hughhhh commented Jul 29, 2021

SUMMARY

Before long reports would have header showing in the middle of the picture. Now i've added a specific standalone setting for reports, which will hide the report dashboard and tabs onCapture.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before

image

After

image

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Jul 29, 2021

Codecov Report

Merging #15954 (6018e8c) into master (3b9b2c9) will increase coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15954      +/-   ##
==========================================
+ Coverage   76.99%   77.13%   +0.13%     
==========================================
  Files         988      996       +8     
  Lines       52371    55481    +3110     
  Branches     6621     7308     +687     
==========================================
+ Hits        40324    42793    +2469     
- Misses      11824    12454     +630     
- Partials      223      234      +11     
Flag Coverage Δ
hive 81.38% <100.00%> (+0.04%) ⬆️
javascript 71.15% <100.00%> (-0.43%) ⬇️
mysql 82.26% <100.00%> (+0.66%) ⬆️
postgres 82.28% <100.00%> (+0.62%) ⬆️
python 82.63% <100.00%> (+0.60%) ⬆️
sqlite 81.90% <100.00%> (+0.60%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...d/components/DashboardBuilder/DashboardBuilder.tsx 89.81% <100.00%> (+0.09%) ⬆️
superset-frontend/src/dashboard/util/constants.ts 100.00% <100.00%> (ø)
superset/utils/webdriver.py 81.81% <100.00%> (+2.33%) ⬆️
superset/dashboards/commands/importers/v1/utils.py 87.50% <0.00%> (-6.62%) ⬇️
...perset-frontend/src/dashboard/containers/Chart.jsx 95.23% <0.00%> (-4.77%) ⬇️
...rontend/src/views/CRUD/dashboard/DashboardCard.tsx 73.77% <0.00%> (-3.51%) ⬇️
...d/src/dashboard/components/gridComponents/Tabs.jsx 86.50% <0.00%> (-2.39%) ⬇️
superset/dashboards/commands/export.py 88.54% <0.00%> (-1.79%) ⬇️
...rc/dashboard/components/dnd/dragDroppableConfig.js 33.33% <0.00%> (-1.67%) ⬇️
...erset-frontend/src/SqlLab/components/SqlEditor.jsx 53.58% <0.00%> (-0.41%) ⬇️
... and 52 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b9b2c9...6018e8c. Read the comment docs.

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments.

Comment on lines 47 to 49
HIDE_NAV = (1,)
HIDE_NAV_AND_TITLE = (2,)
REPORT = (3,)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
HIDE_NAV = (1,)
HIDE_NAV_AND_TITLE = (2,)
REPORT = (3,)
HIDE_NAV = 1
HIDE_NAV_AND_TITLE = 2
REPORT = 3

Otherwise the type is not int, but Tuple[int].

@@ -182,8 +182,9 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
? dashboardLayout[rootChildId]
: undefined;
const isStandalone = getUrlParam(URL_PARAMS.standalone);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bit confusing, the name isStandalone suggests that this is a boolean. We should rename this to standaloneMode or something more clear.

@@ -97,6 +104,7 @@ def get_screenshot(
self, url: str, element_name: str, user: "User",
) -> Optional[bytes]:

url = f"{url}?standalone={DashboardStandaloneMode.REPORT}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break if we change the URL in utils/screenshots.py to include other parameters, it would be safer to parse the URL and append the new parameter programmatically instead of doing string manipulation.

An easy way to do that is using the requests library:

Suggested change
url = f"{url}?standalone={DashboardStandaloneMode.REPORT}"
from requests.models import PreparedRequest
params = {"standalone": DashboardStandaloneMode.REPORT.value}
req = PreparedRequest()
req.prepare_url(url, params)
url = req.url

Or we can use urllib.parse, but it's more code: https://stackoverflow.com/a/25580545/807118

@hughhhh hughhhh merged commit 4cb79e5 into master Aug 2, 2021
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
* create serialize json function

* create new setting for reports

* cleanup

* address comments

* up the attributes
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
* create serialize json function

* create new setting for reports

* cleanup

* address comments

* up the attributes
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* create serialize json function

* create new setting for reports

* cleanup

* address comments

* up the attributes
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* create serialize json function

* create new setting for reports

* cleanup

* address comments

* up the attributes
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.0 labels Mar 13, 2024
@mistercrunch mistercrunch deleted the hugh/fix-report-header branch March 26, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/S 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants