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: add default position to dash export #12007

Merged
merged 2 commits into from
Dec 11, 2020

Conversation

betodealmeida
Copy link
Member

SUMMARY

The layout of dashboards is stored in the position_json attribute, containing the position and ID of charts. When a dashboard layout hasn't been modified the attribute is empty, and the relationship between which charts are contained in a given dashboard exists only in the dashboard_slices table and is not exported.

With this PR, if position_json is empty we add a default position to the attribute, so that the relationship between dashboards and charts is present in the export bundle. This doesn't change the layout, but allows us to extract the relationship when importing the dashboard together with the charts.

One alternative to this PR would be explicitly listing the UUIDs of charts when we export a dashboard, eg:

# dashboards/some_dashboard.yaml
dashboard_title: Test Import [copy]
description: null
css: ''
slug: null
uuid: a1a7dd04-d113-46b8-8cb9-29b9eef280f4
chart_uuids:
- foo
- bar

But since most dashboards will have the position_json attribute set, it seems more efficient to populate it when it's empty.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TEST PLAN

Exported dash, verified the YAML file, and imported again, ensuring that layout was not altered.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@codecov-io
Copy link

codecov-io commented Dec 11, 2020

Codecov Report

Merging #12007 (b7fd1d2) into master (9e07e10) will increase coverage by 0.04%.
The diff coverage is 46.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12007      +/-   ##
==========================================
+ Coverage   63.59%   63.64%   +0.04%     
==========================================
  Files         939      943       +4     
  Lines       45580    45702     +122     
  Branches     4371     4388      +17     
==========================================
+ Hits        28988    29087      +99     
- Misses      16416    16438      +22     
- Partials      176      177       +1     
Flag Coverage Δ
javascript 62.87% <ø> (+0.13%) ⬆️
python 64.10% <46.66%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
superset/dashboards/commands/export.py 77.08% <46.66%> (-14.10%) ⬇️
superset/views/alerts.py 75.00% <0.00%> (-4.42%) ⬇️
superset/db_engines/hive.py 82.14% <0.00%> (-3.58%) ⬇️
superset/datasets/api.py 91.24% <0.00%> (-0.89%) ⬇️
superset/reports/logs/api.py 95.34% <0.00%> (ø)
superset-frontend/src/views/App.tsx 0.00% <0.00%> (ø)
superset/charts/commands/importers/v1/__init__.py 100.00% <0.00%> (ø)
...uperset/datasets/commands/importers/v1/__init__.py 100.00% <0.00%> (ø)
...perset/databases/commands/importers/v1/__init__.py 100.00% <0.00%> (ø)
...erset/dashboards/commands/importers/v1/__init__.py 100.00% <0.00%> (ø)
... and 10 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 9e07e10...b7fd1d2. Read the comment docs.

"id": chart_hash,
"meta": {
"chartId": chart.id,
"height": 50,
Copy link
Member

Choose a reason for hiding this comment

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

i'd make height and width constants at the top

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, let me do that!

Copy link
Member

@hughhhh hughhhh left a comment

Choose a reason for hiding this comment

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

👍

@betodealmeida betodealmeida merged commit 5d8ecc0 into apache:master Dec 11, 2020
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.0.0 labels Mar 12, 2024
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/M 🚢 1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants