diff --git a/superset-frontend/packages/superset-core/src/api/sqlLab.ts b/superset-frontend/packages/superset-core/src/api/sqlLab.ts index fb4984994dc..e5e501f9f1b 100644 --- a/superset-frontend/packages/superset-core/src/api/sqlLab.ts +++ b/superset-frontend/packages/superset-core/src/api/sqlLab.ts @@ -238,6 +238,20 @@ export interface QueryResult { * access to tab-specific state and events. */ +/** + * Gets the currently active panel in the current tab. + * The active panel defaults to 'Results' when SQL Lab loads. + * + * @returns The current active panel object. + * + * @example + * ```typescript + * const panel = getActivePanel(); + * console.log(`Active panel: ${panel.id}`); + * ``` + */ +export declare const getActivePanel: () => Panel; + /** * Gets the currently active tab in SQL Lab. * diff --git a/superset-frontend/src/core/sqlLab/index.ts b/superset-frontend/src/core/sqlLab/index.ts index c4c7ce92f28..4867f42bcfc 100644 --- a/superset-frontend/src/core/sqlLab/index.ts +++ b/superset-frontend/src/core/sqlLab/index.ts @@ -215,6 +215,11 @@ function createQueryErrorContext( const getCurrentTab: typeof sqlLabApi.getCurrentTab = () => getTab(activeEditorId()); +const getActivePanel: typeof sqlLabApi.getActivePanel = () => { + const { activeSouthPaneTab } = getSqlLabState(); + return new Panel(String(activeSouthPaneTab)); +}; + const getTabs: typeof sqlLabApi.getTabs = () => { const { queryEditors } = getSqlLabState(); return queryEditors @@ -389,6 +394,7 @@ const onDidChangeTabTitle: typeof sqlLabApi.onDidChangeTabTitle = ( export const sqlLab: typeof sqlLabApi = { CTASMethod, + getActivePanel, getCurrentTab, onDidChangeEditorDatabase, onDidChangeEditorSchema,