bxsx opened a new pull request, #42494:
URL: https://github.com/apache/superset/pull/42494

   ### SUMMARY
   
   Adds a per-schedule toggle controlling whether the "Explore in Superset" 
call-to-action link is included in Alerts & Reports notifications.
   
   Today the CTA link is hardcoded in both the email template and the Slack 
message template. The only related knob is `EMAIL_REPORTS_CTA` (#19779), which 
customizes the link *text* (email only) but cannot remove the link. Removing it 
has been requested since 2019 (#8698, and discussion #22344) — typical use 
cases are notifications delivered to external audiences or embedded 
deployments, where a link to the Superset host is dead weight or leaks the host 
URL. A global config switch would not serve mixed audiences (the same instance 
often sends internal reports where the link is wanted), hence per-schedule 
control.
   
   **What this PR does:**
   
   - New nullable `include_cta` boolean column on `report_schedule` (migration 
included), default `true`; `NULL` is treated as `true` everywhere, so existing 
schedules and pre-migration rows keep the link — no behavior change.
   - New "Include a link back to Superset" checkbox in the Alerts & Reports 
modal (Contents panel), checked by default, available for both alerts and 
reports.
   - The flag flows through a new `NotificationContent.include_cta` field, so 
all human-rendered channels honor it uniformly: email, Slack, and SlackV2. 
Error notifications (both the in-content error path and `send_error` to owners) 
respect it as well, giving one simple contract: *unchecked = no notification 
from this schedule contains the link*.
   
   **Design notes:**
   
   - Named `include_cta` to match the existing `EMAIL_REPORTS_CTA` vocabulary 
(`include_explore_link` was considered, but the email link text is 
operator-configurable and may not say "Explore in Superset").
   - The webhook channel is intentionally untouched — its `url` payload field 
is a machine-readable contract, not a rendered CTA.
   - Conditional message bodies are implemented as complete alternate `gettext` 
templates (email and Slack), never spliced substrings, for i18n correctness.
   - Making the Slack template text itself configurable is out of scope 
(possible follow-up).
   - The legacy dashboard/chart "schedule email report" quick modal is out of 
scope; reports created there keep the default (link included).
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   BEFORE:
   <img width="491" height="775" alt="Screenshot 2026-07-28 at 02 37 24" 
src="https://github.com/user-attachments/assets/0e142914-56e0-47b0-a4c3-d8521c0ec167";
 />
   
   AFTER:
   <img width="532" height="805" alt="Screenshot 2026-07-28 at 02 27 11" 
src="https://github.com/user-attachments/assets/14491c8a-facf-4383-a03a-6cc768b07d33";
 />
   
   
   ### TESTING INSTRUCTIONS
   
   Unit tests (new coverage for both flag states across email, Slack, SlackV2, 
the Slack truncation path, schema round-trip, and API create/update):
   
   ```bash
   pytest tests/unit_tests/reports/notifications/email_tests.py \
          tests/unit_tests/reports/notifications/slack_tests.py \
          tests/unit_tests/reports/schemas_test.py
   pytest tests/integration_tests/reports/api_tests.py
   cd superset-frontend && npm run test -- 
src/features/alerts/AlertReportModal.test.tsx
   ```
   
   Manual verification (docker compose dev stack + any local SMTP sink, e.g. 
Mailpit):
   
   1. Create a report on a table-type chart, format "Send as text", cron `* * * 
* *`.
   2. Uncheck "Include a link back to Superset" in the Contents panel → 
delivered email contains no "Explore in Superset" link and no schedule URL in 
the HTML source.
   3. Re-check the box → the next email contains the link again.
   4. Slack: same toggle governs `<url|Explore in Superset>` in the message 
body.
   5. Migration: `superset db upgrade` adds the column with server default 
`true`; `superset db downgrade` cleanly removes it (verified upgrade → 
downgrade → upgrade).
   
   ### ADDITIONAL INFORMATION
   
   <!--- Check any relevant boxes with "x" -->
   - [x] Has associated issue: #8698
   - [ ] Required feature flags:
   - [x] Changes UI
   - [x] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [x] Migration is atomic, supports rollback & is backwards-compatible
     - [x] Confirm DB migration upgrade and downgrade tested
     - [x] Runtime estimates and downtime expectations provided — single `ADD 
COLUMN` with a server default on `report_schedule` (typically a small table); 
effectively instantaneous, no downtime expected
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to