Skip to content

feat(extensions): add download menu locations and a toasts API for extensions - #46014

Open
orion222 wants to merge 21 commits into
apache:masterfrom
orion222:utsc/feature/gsheet-integration-fe
Open

orion222 wants to merge 21 commits into
apache:masterfrom
orion222:utsc/feature/gsheet-integration-fe

Conversation

@orion222

@orion222 orion222 commented Nov 4, 2026 •

Copy link
Copy Markdown

SUMMARY

Lets extensions add their own entries to the chart and dashboard Download menus, and show Superset toasts. This is the frontend half of the work the Google Sheets export extension needs. Superset itself gains no Google-specific code: it never learns what a contributed item does.

Download menu locations. Eight new menu locations, one per download menu that offers "Export to Excel":

Surface Location
Explore → Data Export Options explore.chart.download, explore.chart.download.pivoted
Explore standalone / embedded download control explore.standalone.download
Dashboard chart header → Download dashboard.chart.download, dashboard.chart.download.pivoted
Drill to Detail → download chart.drillDetail.download
Drill By (table view) → download chart.drillBy.download
Dashboard header → Download dashboard.download
  • Contributed items appear right after "Export to Excel" (or "Export to Pivoted Excel" for the pivoted locations). With no extension installed, every menu is unchanged.
  • Clicking an item runs the extension's command with context:
    • Chart locations pass { getPayload, chartName, canDownload }. getPayload() builds, at click time, the same query context the CSV export would post, with result_format: 'json'.
    • The dashboard location passes { dashboardId, dashboardTitle, activeDataMask, canDownload }. The mask holds the applied native filters, each with extraFormData plus filterState.
  • Chart items are disabled, not hidden, when the user lacks export permission, matching "Export to .CSV". The dashboard item appears only where "Export Data to Excel" does.
  • Image-only charts get no contributed items.
  • Items registered after a menu first renders appear without a reload.
  • A command that throws or rejects is logged and doesn't break the menu.

All of this goes through one shared hook, useExtensionMenuItems. The drill modals receive their context from a React provider, so props aren't threaded through the four components that sit between the modal and its download menu.

Toasts API. @apache-superset/core gains a toasts namespace that mirrors Superset's own action-creator names: addInfoToast, addSuccessToast, addWarningToast, addDangerToast(text, { link?, duration? }) and removeToast(id).

  • The toasts use Superset's existing toast store.
  • Text is never rendered as HTML.
  • A link renders as a button that opens the URL in a new tab through openInNewTab, so it goes through the navigation safety guard. Toasts with a link stay open until closed.

Docs. New extension-points/download-menus.md and extensions/toasts.md pages, linked from contribution-types.md and sidebars.js.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

gsheet-integration-test.mp4

TESTING INSTRUCTIONS

Automated:

  • JEST_MAX_WORKERS=2 npm run test (full frontend suite): 1455 suites passed. Six suites failed only because their Jest workers ran out of memory or segfaulted on a shared machine, and all six passed when re-run on their own (196/196 tests).
  • pre-commit run --from-ref 891d780223 --to-ref HEAD: oxfmt, oxlint, custom rules and stylelint passed. Two hooks couldn't run cleanly locally:
    • oxlint (docs) needs yarn, which isn't installed here.
    • Type-Checking (Frontend) failed only on errors from unbuilt plugin libraries (TS6305), which are already on master. None are in files this PR changes.

Manual:

  1. With no extension installed, open each surface in the table above. The Download menus are unchanged.
  2. Register an item and its command from the browser console:
    window.superset.commands.registerCommand({ id: 'test.export', title: 'Test export' }, ctx => console.log(ctx));
    window.superset.menus.registerMenuItem({ view: 'test', command: 'test.export' }, 'dashboard.chart.download', 'primary');
  3. Open a dashboard chart's Download menu. "Test export" appears right after "Export to Excel". Clicking it logs a context whose getPayload() resolves to the chart's query context.
  4. Run window.superset.toasts.addSuccessToast('Done', { link: { href: 'https://example.com', label: 'Open' } }). The toast stays open, and its button opens the link in a new tab.

ADDITIONAL INFORMATION

Sibling PR: #45991

@orion222
orion222 marked this pull request as draft November 4, 2026 16:58
@github-actions github-actions Bot added doc Namespace | Anything related to documentation packages utsc2026 UTSC 2026 course contributions labels Nov 4, 2026
@netlify

netlify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit e4c8c37
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6aebd7ada5cecebcd671298c
😎 Deploy Preview https://deploy-preview-46014--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: e4c8c37e805d

@github-actions github-actions Bot added the i18n Namespace | Anything related to localization label Nov 4, 2026
@orion222

orion222 commented Nov 4, 2026

Copy link
Copy Markdown
Author

I only added the new string to messages.pot and deliberately left out the full ./scripts/translations/babel_update.sh regeneration (which also rewraps unrelated entries and refreshes every .po catalog) to keep this PR's scope small. Happy to run it if needed.

@sadpandajoe sadpandajoe added the review:checkpoint Last PR reviewed during the daily review standup label Nov 4, 2026
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.99%. Comparing base (3d9de97) to head (e4c8c37).
⚠️ Report is 27 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #46014      +/-   ##
==========================================
+ Coverage   84.93%   84.99%   +0.06%     
==========================================
  Files        3077     3081       +4     
  Lines      208205   209154     +949     
  Branches    49105    49228     +123     
==========================================
+ Hits       176834   177778     +944     
+ Misses      28002    27995       -7     
- Partials     3369     3381      +12     
Flag Coverage Δ
hive 34.19% <ø> (+<0.01%) ⬆️
javascript 81.28% <100.00%> (+0.02%) ⬆️
mysql 52.02% <ø> (-0.16%) ⬇️
postgres 52.03% <ø> (-0.16%) ⬇️
presto 35.85% <ø> (-0.05%) ⬇️
python 87.96% <ø> (+0.07%) ⬆️
sqlite 51.78% <ø> (-0.16%) ⬇️
unit 82.90% <ø> (+0.18%) ⬆️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

orion222 and others added 6 commits November 4, 2026 13:22
- Add a public ChartDataRequest type and return it from getPayload, so
  surfaces no longer cast or spread the payload.
- ChartDownloadProvider resolves the menu items itself; consumers only
  read them, so dropdowns outside a provider no longer subscribe to an
  unrelated location with a dummy context.
- The dashboard chart menu and Drill to Detail use the title shown on
  the dashboard, including a dashboard-level rename.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Namespace | Anything related to documentation i18n Namespace | Anything related to localization packages plugins review:checkpoint Last PR reviewed during the daily review standup size/XXL utsc2026 UTSC 2026 course contributions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants