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: keep the tab order #30888

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

US579
Copy link
Contributor

@US579 US579 commented Nov 10, 2024

SUMMARY

When export all tabs to a PDF in report & alert, user noticed that the all tabs export doesn't seem to export the tabs in any specific order (our report with 3 tabs exported with tab 2, then 3, then 1 in the PDF)

reference: #30694 (comment)

Context

The exported tabs are now ordered based on the sequence of anchors under the all_tabs field from the tabs endpoint response. This enhancement aligns the export order with the order displayed on the dashboard.

BEFORE PDF

before.pdf

AFTER PDF

after.pdf

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • 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

@github-actions github-actions bot added the api Related to the REST API label Nov 10, 2024
@dosubot dosubot bot added alert-reports Namespace | Anything related to the Alert & Reports feature dashboard:tab Related to the usage of tabs in the Dashboard labels Nov 10, 2024
@US579
Copy link
Contributor Author

US579 commented Nov 10, 2024

FYI @yousoph

Copy link

codecov bot commented Nov 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.46%. Comparing base (76d897e) to head (3d2d8a6).
Report is 1350 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #30888       +/-   ##
===========================================
+ Coverage   60.48%   83.46%   +22.97%     
===========================================
  Files        1931      546     -1385     
  Lines       76236    39291    -36945     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    32794    -13320     
+ Misses      28017     6497    -21520     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 48.80% <12.50%> (-0.36%) ⬇️
javascript ?
mysql 75.99% <100.00%> (?)
postgres 76.05% <100.00%> (?)
presto 53.30% <12.50%> (-0.51%) ⬇️
python 83.46% <100.00%> (+19.97%) ⬆️
sqlite 75.53% <100.00%> (?)
unit 61.08% <12.50%> (+3.45%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rusackas
Copy link
Member

LGTM, but @eschutho might be better poised to actually test this before approving/merging.

@rusackas rusackas requested a review from eschutho November 11, 2024 16:57
response_data = json.dumps({"result": result})
return Response(
response_data, status=HTTPStatus.OK, mimetype="application/json"
)
Copy link
Member

Choose a reason for hiding this comment

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

@US579 was the self.response not including the correct mimetype? I would think that all the responses should be json, but maybe @dpgaspar has more info on this.

Copy link
Contributor Author

@US579 US579 Jan 8, 2025

Choose a reason for hiding this comment

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

yep it does has mimetype, but jsonify func will reorder the dict, and it is part of the func in self.response

This is a test example

Screenshot 2025-01-08 at 9 49 44 pm Screenshot 2025-01-08 at 9 48 59 pm

with response

Screenshot 2025-01-09 at 9 35 42 am Screenshot 2025-01-09 at 9 35 32 am

if (childs := node.get("children")) and node["type"] == "TABS":
tabs_order.extend(childs)
if tabs_order:
all_tabs = {str(t): all_tabs[str(t)] for t in tabs_order}
Copy link
Member

Choose a reason for hiding this comment

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

@US579 Since the api (in addition to the dictionary for all_tabs) returns a nested array structure of the tabs which would maintain their order, can you iterate through the tab_tree instead of relying on the all_tabs dict?
Screenshot 2025-01-27 at 5 34 32 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yep good found!

@US579 US579 force-pushed the fix-tabs-order-in-pdf branch from 3d2d8a6 to eceb68d Compare February 2, 2025 01:48
@pull-request-size pull-request-size bot added size/XS and removed size/L labels Feb 2, 2025
@github-actions github-actions bot removed the api Related to the REST API label Feb 2, 2025
@US579 US579 force-pushed the fix-tabs-order-in-pdf branch 4 times, most recently from 8a0f4a1 to 61d4830 Compare February 2, 2025 02:52
@pull-request-size pull-request-size bot added size/S and removed size/XS labels Feb 2, 2025
@US579 US579 force-pushed the fix-tabs-order-in-pdf branch from 61d4830 to 926b9a4 Compare February 2, 2025 02:57
@US579 US579 closed this Feb 2, 2025
@US579 US579 reopened this Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alert-reports Namespace | Anything related to the Alert & Reports feature dashboard:tab Related to the usage of tabs in the Dashboard size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants