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

   ### SUMMARY
   
   Implements Phase 3 of the chatbot extension architecture: the four context 
namespaces that give chatbot extensions stable, host-managed access to page 
context without coupling to Redux internals.
   
   **New namespaces in `@apache-superset/core`** (declarations — the stable 
extension contract):
   - `navigation` — `getPageType()`, `getCurrentPage()`, `onDidChangePage` 
event. `PageType` covers `dashboard | explore | sqllab | dataset | home | 
other`.
   - `explore` — `getCurrentChart()`, `onDidChangeChart` event. Exposes 
`ChartContext` (chart id, name, viz type, datasource) normalized from Redux 
explore state.
   - `dataset` — `getCurrentDataset()`, `onDidChangeDataset` event. Push model: 
the Dataset page calls the host-internal `setCurrentDataset()` as it loads.
   - `dashboard` — `getCurrentDashboard()`, `onDidChangeDashboard` event. 
Exposes `DashboardContext` (id, title, active native filter values) normalized 
from Redux `dashboardInfo` + `dataMask`.
   
   **Host implementations in `src/core/`** (internal, not exported on the 
public API):
   - `navigation` backed by `window.location` + `notifyPageChange` driven by 
React Router in `ExtensionsStartup`
   - `explore` backed by Redux action listener on `HYDRATE_EXPLORE`, 
`SET_FORM_DATA`, `UPDATE_CHART_TITLE`
   - `dataset` backed by a simple push store (`setCurrentDataset`)
   - `dashboard` backed by Redux action listener on `HYDRATE_DASHBOARD`, 
`UPDATE_DATA_MASK`, `SET_DATA_MASK_FOR_FILTER_CHANGES_COMPLETE`
   
   **Also in this PR:**
   - `PUT /api/v1/extensions/settings` restricted to Admin role 
(`security_manager.is_admin()`)
   - `enabled` flag now enforced in `getActiveChatbot` — disabled extensions 
are excluded from selection, not just hidden in the UI
   - `update_extension_settings` uses `@transaction()` decorator (removes 
manual `db.session.commit()`)
   
   All four namespaces are wired into `window.superset` in `ExtensionsStartup`. 
Extensions compose them into their own `PageContext`:
   
   ```typescript
   const pageContext = {
     pageType: navigation.getPageType(),
     dashboard: dashboard.getCurrentDashboard(),
     chart: explore.getCurrentChart(),
     dataset: dataset.getCurrentDataset(),
   };
   ```
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — namespace APIs, no visible UI change.
   
   ### TESTING INSTRUCTIONS
   
   1. On a dashboard page: `window.superset.navigation.getPageType()` → 
`'dashboard'`
   2. `window.superset.dashboard.getCurrentDashboard()` → `{ dashboardId, 
title, filters: [...] }`
   3. Apply a native filter → `onDidChangeDashboard` fires with updated filter 
values
   4. Navigate to Explore → `navigation.getPageType()` → `'explore'`, 
`explore.getCurrentChart()` returns chart context
   5. `PUT /api/v1/extensions/settings` as a non-admin user → 403
   6. Disable a chatbot extension in the admin UI → it no longer renders
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [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