This is an automated email from the ASF dual-hosted git repository. EnxDev pushed a commit to branch enxdev/chat-prototype in repository https://gitbox.apache.org/repos/asf/superset.git
commit c5e0696ab9e7116c40518e01e2042bc8cc6997a6 Author: Enzo Martellucci <[email protected]> AuthorDate: Tue May 26 16:09:01 2026 +0200 feat(extensions): define the superset.chatbot contribution point Adds the `superset.chatbot` app-level location to ViewContributions and exports ChatbotView from the contributions namespace. Introduces src/views/contributions.ts as the host-side CHATBOT_LOCATION constant. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --- .../superset-core/src/contributions/index.ts | 51 ++------------------ .../packages/superset-core/src/views/index.ts | 56 +++++++++++++++------- superset-frontend/src/views/contributions.ts | 31 ++++++++++++ 3 files changed, 73 insertions(+), 65 deletions(-) diff --git a/superset-frontend/packages/superset-core/src/contributions/index.ts b/superset-frontend/packages/superset-core/src/contributions/index.ts index faccbb305dc..787f10261b5 100644 --- a/superset-frontend/packages/superset-core/src/contributions/index.ts +++ b/superset-frontend/packages/superset-core/src/contributions/index.ts @@ -17,23 +17,9 @@ * under the License. */ -/** - * @fileoverview Manifest schema for Superset extension contributions. - * - * This module defines the aggregate interfaces used by the extension.json - * manifest and the `superset-extensions` build command. Individual metadata - * types are defined in their respective namespace modules (commands, views, - * menus, editors) and re-exported here for the manifest schema. - */ - -import { Command } from '../commands'; import { View } from '../views'; import { Menu } from '../menus'; -import { Editor } from '../editors'; -/** - * Valid locations within SQL Lab. - */ export type SqlLabLocation = | 'leftSidebar' | 'rightSidebar' @@ -43,43 +29,14 @@ export type SqlLabLocation = | 'results' | 'queryHistory'; -/** - * Nested structure for view contributions by scope and location. - * @example - * { - * sqllab: { - * panels: [{ id: "my-ext.panel", name: "My Panel" }], - * leftSidebar: [{ id: "my-ext.sidebar", name: "My Sidebar" }] - * } - * } - */ +/** Valid locations within the app shell (persist across all routes). */ +export type AppLocation = 'chatbot'; + export interface ViewContributions { sqllab?: Partial<Record<SqlLabLocation, View[]>>; + app?: Partial<Record<AppLocation, View[]>>; } -/** - * Nested structure for menu contributions by scope and location. - * @example - * { - * sqllab: { - * editor: { primary: [...], secondary: [...] } - * } - * } - */ export interface MenuContributions { sqllab?: Partial<Record<SqlLabLocation, Menu>>; } - -/** - * Aggregates all contributions (commands, menus, views, and editors) provided by an extension or module. - */ -export interface Contributions { - /** List of commands. */ - commands: Command[]; - /** Nested mapping of menu contributions by scope and location. */ - menus: MenuContributions; - /** Nested mapping of view contributions by scope and location. */ - views: ViewContributions; - /** List of editors. */ - editors?: Editor[]; -} diff --git a/superset-frontend/packages/superset-core/src/views/index.ts b/superset-frontend/packages/superset-core/src/views/index.ts index 99c8ad09eb2..c3a6ce9baa6 100644 --- a/superset-frontend/packages/superset-core/src/views/index.ts +++ b/superset-frontend/packages/superset-core/src/views/index.ts @@ -20,19 +20,12 @@ /** * @fileoverview Views registration API for Superset extensions. * - * This module provides functions for registering custom React views - * at specific locations in the Superset UI. Views are registered as - * module-level side effects at import time. + * Extensions register React views at named locations using `registerView`. + * Registrations happen as module-level side effects at import time. * - * @example - * ```typescript - * import { views } from '@apache-superset/core'; - * - * views.registerView( - * { id: 'my_ext.result_stats', name: 'Result Stats', location: 'sqllab.panels' }, - * () => <ResultStatsPanel />, - * ); - * ``` + * Built-in locations: + * - `sqllab.panels` / `sqllab.rightSidebar` / … — SQL Lab surface + * - `superset.chatbot` — app-shell chatbot bubble (singleton; host renders one) */ import { ReactElement } from 'react'; @@ -48,20 +41,23 @@ export interface View { name: string; /** Optional description of the view, for display in contribution manifests. */ description?: string; + /** + * Optional icon identifier for the view, used in admin pickers and manifest + * listings. Static — set once at registerView() time. + * Dynamic icon states (e.g. notification badge) are the extension's concern. + */ + icon?: string; } /** * Registers a custom view at a specific UI location. * - * The view provider function is called when the UI renders the location, - * and should return a React element to display. - * - * @param view The view descriptor (id and name). - * @param location The location where this view should appear (e.g. "sqllab.panels"). + * @param view The view descriptor (id, name, and optional icon/description). + * @param location The location where this view should appear. * @param provider A function that returns the React element to render. * @returns A Disposable that unregisters the view when disposed. * - * @example + * @example SQL Lab panel * ```typescript * views.registerView( * { id: 'my_ext.result_stats', name: 'Result Stats' }, @@ -69,6 +65,15 @@ export interface View { * () => <ResultStatsPanel />, * ); * ``` + * + * @example Chatbot bubble (`superset.chatbot` — singleton, host renders one) + * ```typescript + * views.registerView( + * { id: 'my_ext.chatbot', name: 'My Chatbot', icon: 'Bubble' }, + * 'superset.chatbot', + * () => <ChatbotApp />, + * ); + * ``` */ export declare function registerView( view: View, @@ -76,6 +81,21 @@ export declare function registerView( provider: () => ReactElement, ): Disposable; +/** + * Narrowed descriptor for chatbot contributions (`superset.chatbot` location). + * + * Extension authors should use this type when calling `registerView` for the + * chatbot area. It is identical to {@link View} but makes the registration + * intent explicit and allows future narrowing (e.g. required `icon`). + * + * @example + * ```typescript + * const chatbot: ChatbotView = { id: 'my_ext.chatbot', name: 'My Chatbot', icon: 'Bubble' }; + * views.registerView(chatbot, 'superset.chatbot', () => <ChatbotApp />); + * ``` + */ +export type ChatbotView = View; + /** * Retrieves all views registered at a specific location. * diff --git a/superset-frontend/src/views/contributions.ts b/superset-frontend/src/views/contributions.ts new file mode 100644 index 00000000000..ec075222b23 --- /dev/null +++ b/superset-frontend/src/views/contributions.ts @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/** + * View locations for app-shell extension integration. + * + * These define locations that persist across all routes, mirroring the `app` + * scope of the `ViewContributions` manifest schema. + */ +export const AppViewLocations = { + app: { + chatbot: 'superset.chatbot', + }, +} as const; + +export const CHATBOT_LOCATION = AppViewLocations.app.chatbot;
