Skip to content

fix(dashboard): hide Edit button in embedded dashboards#40687

Merged
rusackas merged 1 commit into
masterfrom
fix/hide-edit-button-embedded-dashboard
Jun 2, 2026
Merged

fix(dashboard): hide Edit button in embedded dashboards#40687
rusackas merged 1 commit into
masterfrom
fix/hide-edit-button-embedded-dashboard

Conversation

@rusackas
Copy link
Copy Markdown
Member

@rusackas rusackas commented Jun 2, 2026

SUMMARY

Embedded dashboards (rendered via the Embedded SDK) authenticate with a guest token, so they have no logged-in userId. The dashboard header already derives embedded state from this (isEmbedded = !dashboardInfo?.userId, used elsewhere e.g. to hide the metadata bar), but the Edit dashboard button was gated only on userCanEdit. As a result it rendered inside embedded dashboards, where editing isn't a supported flow.

Per #30893, clicking Edit dashboardDiscard in an embedded dashboard leaves the iframe stuck on a perpetual loading screen (the discard navigation can't resolve in the embedded context). Hiding the Edit button removes that broken entry point.

This gates the Edit button on !isEmbedded in addition to userCanEdit. No behavior change for normal (logged-in) dashboards.

Closes #30893

BEFORE/AFTER

Before: embedded dashboards with edit permission show the Edit dashboard button → entering edit mode and discarding hangs the iframe.
After: the Edit dashboard button is not rendered in embedded dashboards.

TESTING INSTRUCTIONS

  1. Embed a dashboard via the Embedded SDK with a guest token whose role has edit permission.
  2. Confirm the Edit dashboard button no longer appears.
  3. Confirm a normal (logged-in) dashboard with edit permission still shows the button and can enter edit mode.

Unit test added: Header.test.tsx → "should NOT render the Edit dashboard button when embedded" (asserts the button is absent when userId is undefined even with dash_edit_perm: true).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

Embedded (Embedded SDK) dashboards authenticate with a guest token and have no
userId, so the header already derives `isEmbedded = !dashboardInfo?.userId`.
The Edit button was gated only on `userCanEdit`, so it appeared in embedded
dashboards; entering edit mode there and discarding leaves the iframe stuck on
a perpetual loading screen (#30893). Gate the button on `!isEmbedded` as well.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Jun 2, 2026

Code Review Agent Run #d43495

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 8d13ce2..8d13ce2
    • superset-frontend/src/dashboard/components/Header/Header.test.tsx
    • superset-frontend/src/dashboard/components/Header/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added dashboard Namespace | Anything related to the Dashboard embedded labels Jun 2, 2026
@github-actions github-actions Bot removed the embedded label Jun 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents a broken editing flow in Embedded SDK dashboards by hiding the Edit dashboard button when the dashboard is rendered in an embedded (guest token) context, while preserving existing behavior for normal logged-in dashboards.

Changes:

  • Gate rendering of the Edit dashboard button on userCanEdit && !isEmbedded.
  • Add unit coverage ensuring the button is not shown when dashboardInfo.userId is missing (embedded context).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
superset-frontend/src/dashboard/components/Header/index.tsx Hide the Edit button in embedded dashboards by adding an !isEmbedded guard and updating memo deps accordingly.
superset-frontend/src/dashboard/components/Header/Header.test.tsx Add a unit test asserting the Edit button is absent when userId is undefined even if edit permission is present.

Copy link
Copy Markdown
Contributor

@aminghadersohi aminghadersohi left a comment

Choose a reason for hiding this comment

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

Review

Head SHA verified: 8d13ce2

19-Scan Coverage

All 19 Python-specific scans N/A — TypeScript-only PR (2 files, +17/-1).

Key Checks

Rule 26 (behavioral test): Verified. testIdAttribute: 'data-test' is configured in spec/helpers/setup.ts, so queryByTestId('edit-dashboard-button') correctly maps to the button's data-test attribute. Removing the !isEmbedded guard would cause this test to fail — not a false positive.

Rule 26 (positive case): Covered by the existing "should toggle the edit mode" test (line 600), which uses dash_edit_perm: true + userId: '1' (non-embedded) and asserts the button is present.

useMemo deps: isEmbedded correctly added to the dependency array at line 779 — prevents stale closure renders.

Entry-point completeness: The Edit dashboard button is the only call site for handleEnterEditMode. No keyboard shortcut for edit mode exists in the component. The actions dropdown (useHeaderActionsDropdownMenu.tsx) already gated the fullscreen toggle with !isEmbedded at line 228.

Findings

BLOCKER: None · HIGH: None · MEDIUM: None · NIT: None

PRAISE

  • Minimal fix — 1 condition, 1 dep entry, 15-line test.
  • Reuses the established isEmbedded = !dashboardInfo?.userId pattern already applied to the metadata bar (line 652) — no new logic.
  • Test comment correctly documents the non-obvious guest-token → no userIdisEmbedded chain.

CI: CodeQL, pre-commit, playwright, cypress, frontend-build all pass. Jest/lint queued but no failures.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.96%. Comparing base (e2ed989) to head (8d13ce2).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #40687   +/-   ##
=======================================
  Coverage   63.96%   63.96%           
=======================================
  Files        2658     2658           
  Lines      143095   143095           
  Branches    32907    32907           
=======================================
  Hits        91537    91537           
  Misses      49991    49991           
  Partials     1567     1567           
Flag Coverage Δ
javascript 67.41% <100.00%> (ø)

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.

🚀 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.

@rusackas rusackas merged commit d26a7aa into master Jun 2, 2026
71 checks passed
@rusackas rusackas deleted the fix/hide-edit-button-embedded-dashboard branch June 2, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard Namespace | Anything related to the Dashboard size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded dashboard- discard button does not work after click on Edit dashboard in embedded dashboard

4 participants