You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2026/07/20 18:48:38 UTC

(superset) branch 6.2 updated (a1fd226396d -> 19a2e29f000)

This is an automated email from the ASF dual-hosted git repository.

michael-s-molina pushed a change to branch 6.2
in repository https://gitbox.apache.org/repos/asf/superset.git


    from a1fd226396d fix(nav): prevent full reload when clicking logo; redirect / to welcome (#41119)
     new e54c93df05b fix(event-log): add event logging for embedded Superset (#41938)
     new 2af7650975d fix(embedded): backport hideTab + filter-bar fix to 6.1 (#38846, #39417) (#42008)
     new 1e1241e9e3d fix(event-log): backport stricter embedded-route regex to 6.1 (#42048)
     new a11250a49ae fix(dashboard): restore top-level tab drop target for dashboards with content (#39423)
     new e0b8bbcb216 feat(explore): add CSV/XLS download to drill-to-detail modal (backport #37109) (#42051)
     new 36accb034c0 feat(ci): install helm-docs directly instead of using whole brew setup (backport #41629) (#42113)
     new 19a2e29f000 fix(table): prevent pagination reset on cell click (#42136)

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/pre-commit.yml                   |  17 +-
 .../plugin-chart-table/src/DataTable/DataTable.tsx |   1 +
 .../components/Chart/DrillBy/DrillByModal.test.tsx | 148 ++++++
 .../src/components/Chart/DrillBy/DrillByModal.tsx  |  65 ++-
 .../Chart/DrillBy/useResultsTableView.tsx          |   9 +
 .../Chart/DrillDetail/DownloadDropdown.test.tsx    |  57 +++
 .../Chart/DrillDetail/DownloadDropdown.tsx         |  89 ++++
 .../Chart/DrillDetail/DrillDetailPane.test.tsx     | 143 +++++-
 .../Chart/DrillDetail/DrillDetailPane.tsx          |  75 +++
 .../DrillDetailTableControls.stories.tsx           |   6 +
 .../DrillDetail/DrillDetailTableControls.test.tsx  |  28 +-
 .../Chart/DrillDetail/DrillDetailTableControls.tsx |  40 +-
 .../DashboardBuilder/DashboardBuilder.test.tsx     |  43 ++
 .../DashboardBuilder/DashboardBuilder.tsx          |  56 ++-
 .../components/nativeFilters/state.test.ts         | 504 ++++++++++++++++++++-
 .../dashboard/components/nativeFilters/state.ts    |  76 +++-
 .../components/DataTableControls.test.tsx          | 133 ++++++
 .../components/DataTableControls.tsx               |  35 +-
 .../components/SingleQueryResultPane.tsx           |   6 +
 .../src/explore/components/DataTablesPane/types.ts |  11 +-
 superset-frontend/src/middleware/logger.test.ts    |  34 ++
 .../src/middleware/loggerMiddleware.ts             |  23 +-
 .../Spin/index.tsx => src/types/emotion-jest.d.ts} |   2 +-
 superset/views/base.py                             |   1 +
 24 files changed, 1532 insertions(+), 70 deletions(-)
 create mode 100644 superset-frontend/src/components/Chart/DrillDetail/DownloadDropdown.test.tsx
 create mode 100644 superset-frontend/src/components/Chart/DrillDetail/DownloadDropdown.tsx
 create mode 100644 superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.test.tsx
 copy superset-frontend/{packages/superset-ui-core/src/components/Spin/index.tsx => src/types/emotion-jest.d.ts} (95%)


(superset) 07/07: fix(table): prevent pagination reset on cell click (#42136)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michael-s-molina pushed a commit to branch 6.2
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 19a2e29f000c607a4efd743f88e4bf50e274b07a
Author: PRATHAMESH HUKKERI <pr...@gmail.com>
AuthorDate: Sat Jul 18 00:03:19 2026 +0530

    fix(table): prevent pagination reset on cell click (#42136)
    
    Co-authored-by: Prathamesh Hukkeri <pr...@users.noreply.github.com>
    (cherry picked from commit c05ac138fb9d1f00ceeb66b954b5620269bf652d)
---
 superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx | 1 +
 1 file changed, 1 insertion(+)

diff --git a/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx b/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx
index 4cec527e8cd..8cc24086de5 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx
@@ -257,6 +257,7 @@ export default typedMemo(function DataTable<D extends object>({
       sortTypes,
       autoResetGlobalFilter: !isEqual(columnNames, previousColumnNames),
       autoResetSortBy: !isEqual(columnNames, previousColumnNames),
+      autoResetPage: !isEqual(columnNames, previousColumnNames),
       manualSortBy: !!serverPagination,
       ...moreUseTableOptions,
     },


(superset) 02/07: fix(embedded): backport hideTab + filter-bar fix to 6.1 (#38846, #39417) (#42008)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michael-s-molina pushed a commit to branch 6.2
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 2af7650975de1f437e3982e4bae55880d8fd0c48
Author: Luiz Otavio <45...@users.noreply.github.com>
AuthorDate: Tue Jul 14 08:55:23 2026 -0300

    fix(embedded): backport hideTab + filter-bar fix to 6.1 (#38846, #39417) (#42008)
    
    Co-authored-by: Michael S. Molina <70...@users.noreply.github.com>
    Co-authored-by: Joe Li <jo...@preset.io>
    Co-authored-by: Claude Opus 4.6 (1M context) <no...@anthropic.com>
---
 .../DashboardBuilder/DashboardBuilder.tsx          |  52 ++-
 .../components/nativeFilters/state.test.ts         | 504 ++++++++++++++++++++-
 .../dashboard/components/nativeFilters/state.ts    |  76 +++-
 3 files changed, 597 insertions(+), 35 deletions(-)

diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
index c2ea76ca2f8..a507c65318d 100644
--- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
+++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
@@ -523,30 +523,33 @@ const DashboardBuilder = () => {
     ({ dropIndicatorProps }: { dropIndicatorProps: JsonObject }) => (
       <div>
         {dropIndicatorProps && <div {...dropIndicatorProps} />}
-        {!isReport && topLevelTabs && !uiConfig.hideNav && (
-          <WithPopoverMenu
-            shouldFocus={shouldFocusTabs}
-            menuItems={[
-              <IconButton
-                key="collapse-tabs"
-                icon={<Icons.FallOutlined iconSize="xl" />}
-                label={t('Collapse tab content')}
-                onClick={handleDeleteTopLevelTabs}
-              />,
-            ]}
-            editMode={editMode}
-          >
-            <DashboardComponent
-              id={topLevelTabs?.id}
-              parentId={DASHBOARD_ROOT_ID}
-              depth={DASHBOARD_ROOT_DEPTH + 1}
-              index={0}
-              renderTabContent={false}
-              renderHoverMenu={false}
-              onChangeTab={handleChangeTab}
-            />
-          </WithPopoverMenu>
-        )}
+        {!isReport &&
+          topLevelTabs &&
+          !uiConfig.hideTab &&
+          !uiConfig.hideNav && (
+            <WithPopoverMenu
+              shouldFocus={shouldFocusTabs}
+              menuItems={[
+                <IconButton
+                  key="collapse-tabs"
+                  icon={<Icons.FallOutlined iconSize="xl" />}
+                  label={t('Collapse tab content')}
+                  onClick={handleDeleteTopLevelTabs}
+                />,
+              ]}
+              editMode={editMode}
+            >
+              <DashboardComponent
+                id={topLevelTabs?.id}
+                parentId={DASHBOARD_ROOT_ID}
+                depth={DASHBOARD_ROOT_DEPTH + 1}
+                index={0}
+                renderTabContent={false}
+                renderHoverMenu={false}
+                onChangeTab={handleChangeTab}
+              />
+            </WithPopoverMenu>
+          )}
       </div>
     ),
     [
@@ -555,6 +558,7 @@ const DashboardBuilder = () => {
       handleDeleteTopLevelTabs,
       isReport,
       topLevelTabs,
+      uiConfig.hideTab,
       uiConfig.hideNav,
     ],
   );
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/state.test.ts b/superset-frontend/src/dashboard/components/nativeFilters/state.test.ts
index 782e0fff6bf..88d551c8dd4 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/state.test.ts
+++ b/superset-frontend/src/dashboard/components/nativeFilters/state.test.ts
@@ -31,11 +31,21 @@ jest.mock('react-redux', () => {
 });
 
 beforeEach(() => {
-  (useSelector as jest.Mock).mockImplementation(selector => {
-    if (selector.name === 'useActiveDashboardTabs') {
-      return ['TAB_1'];
-    }
-    return [];
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: ['TAB_1'] },
+      dashboardLayout: {
+        present: {
+          'CHART-123': {
+            type: 'CHART',
+            meta: { chartId: 123 },
+            parents: ['ROOT_ID', 'TAB_1'],
+          },
+          TAB_1: { type: 'TAB', id: 'TAB_1' },
+        },
+      },
+    };
+    return selector(mockState);
   });
 });
 
@@ -89,6 +99,14 @@ test('useIsFilterInScope should return false for filters with inactive rootPath'
 });
 
 test('useSelectFiltersInScope should return all filters in scope when no tabs exist', () => {
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: [] },
+      dashboardLayout: { present: {} },
+    };
+    return selector(mockState);
+  });
+
   const filters: Filter[] = [
     {
       id: 'filter_1',
@@ -507,3 +525,479 @@ test('filter with mix of existing and non-existent charts in chartsInScope', ()
   const { result } = renderHook(() => useIsFilterInScope());
   expect(result.current(filter)).toBe(true);
 });
+
+// --- Embedded / hideTab: activeTabs is empty ---
+// When an embedded dashboard uses hideTab:true, the Tabs component never
+// mounts, so setActiveTab never fires and activeTabs stays []. The same
+// empty state occurs transiently on first render of any tabbed dashboard.
+//
+// useActiveDashboardTabs derives the default first tab from the layout when
+// Redux activeTabs is empty, so scope evaluation uses the correct default
+// tab instead of either "no tabs active" (blank filter bar) or "all tabs"
+// (showing out-of-scope filters).
+
+// Helper: build a layout with ROOT_ID → TABS container → TAB children
+function embeddedLayout(extras: Record<string, Record<string, unknown>> = {}) {
+  return {
+    ROOT_ID: {
+      type: 'ROOT',
+      id: 'ROOT_ID',
+      children: ['TABS-1'],
+    },
+    'TABS-1': {
+      type: 'TABS',
+      id: 'TABS-1',
+      children: ['TAB-Company', 'TAB-Desktop'],
+    },
+    'TAB-Company': {
+      type: 'TAB',
+      id: 'TAB-Company',
+      children: ['CHART-1', 'CHART-2'],
+    },
+    'TAB-Desktop': {
+      type: 'TAB',
+      id: 'TAB-Desktop',
+      children: ['CHART-3'],
+    },
+    'CHART-1': {
+      type: 'CHART',
+      meta: { chartId: 1 },
+      parents: ['ROOT_ID', 'TAB-Company'],
+    },
+    'CHART-2': {
+      type: 'CHART',
+      meta: { chartId: 2 },
+      parents: ['ROOT_ID', 'TAB-Company'],
+    },
+    'CHART-3': {
+      type: 'CHART',
+      meta: { chartId: 3 },
+      parents: ['ROOT_ID', 'TAB-Desktop'],
+    },
+    ...extras,
+  };
+}
+
+test('useIsFilterInScope: filter scoped to default tab is in-scope when activeTabs is empty', () => {
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: [] },
+      dashboardLayout: { present: embeddedLayout() },
+    };
+    return selector(mockState);
+  });
+
+  const filter: Filter = {
+    id: 'filter_default_tab',
+    name: 'Default Tab Filter',
+    filterType: 'filter_select',
+    type: NativeFilterType.NativeFilter,
+    chartsInScope: [1, 2],
+    scope: { rootPath: ['TAB-Company'], excluded: [] },
+    controlValues: {},
+    defaultDataMask: {},
+    cascadeParentIds: [],
+    targets: [{ column: { name: 'column_name' }, datasetId: 1 }],
+    description: 'Filter scoped to default (first) tab',
+  };
+
+  const { result } = renderHook(() => useIsFilterInScope());
+  expect(result.current(filter)).toBe(true);
+});
+
+test('useIsFilterInScope: filter scoped only to non-default tab is out-of-scope when activeTabs is empty', () => {
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: [] },
+      dashboardLayout: { present: embeddedLayout() },
+    };
+    return selector(mockState);
+  });
+
+  const filter: Filter = {
+    id: 'filter_other_tab',
+    name: 'Other Tab Filter',
+    filterType: 'filter_select',
+    type: NativeFilterType.NativeFilter,
+    chartsInScope: [3],
+    scope: { rootPath: ['TAB-Desktop'], excluded: [] },
+    controlValues: {},
+    defaultDataMask: {},
+    cascadeParentIds: [],
+    targets: [{ column: { name: 'column_name' }, datasetId: 1 }],
+    description: 'Filter scoped only to non-default tab',
+  };
+
+  const { result } = renderHook(() => useIsFilterInScope());
+  expect(result.current(filter)).toBe(false);
+});
+
+test('useIsFilterInScope: filter with rootPath to default tab is in-scope when activeTabs is empty', () => {
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: [] },
+      dashboardLayout: { present: embeddedLayout() },
+    };
+    return selector(mockState);
+  });
+
+  const filter: Filter = {
+    id: 'filter_rootpath_default',
+    name: 'RootPath Filter',
+    filterType: 'filter_select',
+    type: NativeFilterType.NativeFilter,
+    scope: { rootPath: ['TAB-Company'], excluded: [] },
+    controlValues: {},
+    defaultDataMask: {},
+    cascadeParentIds: [],
+    targets: [{ column: { name: 'column_name' }, datasetId: 1 }],
+    description: 'Filter using rootPath to default tab',
+  };
+
+  const { result } = renderHook(() => useIsFilterInScope());
+  expect(result.current(filter)).toBe(true);
+});
+
+test('useSelectFiltersInScope: only default-tab filters are in scope when activeTabs is empty (embedded hideTab)', () => {
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: [] },
+      dashboardLayout: { present: embeddedLayout() },
+    };
+    return selector(mockState);
+  });
+
+  const filters: Filter[] = [
+    {
+      id: 'filter_company',
+      name: 'Company Tab Filter',
+      filterType: 'filter_select',
+      type: NativeFilterType.NativeFilter,
+      chartsInScope: [1, 2],
+      scope: { rootPath: ['TAB-Company'], excluded: [] },
+      controlValues: {},
+      defaultDataMask: {},
+      cascadeParentIds: [],
+      targets: [{ column: { name: 'survey_rating' }, datasetId: 1 }],
+      description: 'Filter scoped to default tab',
+    },
+    {
+      id: 'filter_desktop_only',
+      name: 'Desktop Only Filter',
+      filterType: 'filter_select',
+      type: NativeFilterType.NativeFilter,
+      chartsInScope: [3],
+      scope: { rootPath: ['TAB-Desktop'], excluded: [] },
+      controlValues: {},
+      defaultDataMask: {},
+      cascadeParentIds: [],
+      targets: [{ column: { name: 'pool_name' }, datasetId: 2 }],
+      description: 'Filter scoped only to non-default tab',
+    },
+  ];
+
+  const { result } = renderHook(() => useSelectFiltersInScope(filters));
+  expect(result.current[0]).toHaveLength(1);
+  expect(result.current[0][0]).toEqual(
+    expect.objectContaining({ id: 'filter_company' }),
+  );
+  expect(result.current[1]).toHaveLength(1);
+  expect(result.current[1][0]).toEqual(
+    expect.objectContaining({ id: 'filter_desktop_only' }),
+  );
+});
+
+test('useSelectFiltersInScope: dividers are always in scope even when activeTabs is empty', () => {
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: [] },
+      dashboardLayout: { present: embeddedLayout() },
+    };
+    return selector(mockState);
+  });
+
+  const items: (Filter | Divider)[] = [
+    {
+      id: 'divider_embedded',
+      type: NativeFilterType.Divider,
+      title: 'Section',
+      description: 'Divider in embedded mode',
+    },
+    {
+      id: 'filter_default',
+      name: 'Default Tab Filter',
+      filterType: 'filter_select',
+      type: NativeFilterType.NativeFilter,
+      chartsInScope: [1],
+      scope: { rootPath: ['TAB-Company'], excluded: [] },
+      controlValues: {},
+      defaultDataMask: {},
+      cascadeParentIds: [],
+      targets: [{ column: { name: 'col' }, datasetId: 1 }],
+      description: 'Filter in default tab',
+    },
+  ];
+
+  const { result } = renderHook(() => useSelectFiltersInScope(items));
+  expect(result.current[0]).toHaveLength(2);
+  expect(result.current[1]).toHaveLength(0);
+});
+
+test('useSelectFiltersInScope: correctly scopes chartsInScope filters when activeTabs is populated', () => {
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: ['TAB-Company'] },
+      dashboardLayout: { present: embeddedLayout() },
+    };
+    return selector(mockState);
+  });
+
+  const filters: Filter[] = [
+    {
+      id: 'filter_active_tab',
+      name: 'Active Tab Filter',
+      filterType: 'filter_select',
+      type: NativeFilterType.NativeFilter,
+      chartsInScope: [1],
+      scope: { rootPath: ['TAB-Company'], excluded: [] },
+      controlValues: {},
+      defaultDataMask: {},
+      cascadeParentIds: [],
+      targets: [{ column: { name: 'col' }, datasetId: 1 }],
+      description: 'Filter scoped to active tab',
+    },
+    {
+      id: 'filter_inactive_tab',
+      name: 'Inactive Tab Filter',
+      filterType: 'filter_select',
+      type: NativeFilterType.NativeFilter,
+      chartsInScope: [3],
+      scope: { rootPath: ['TAB-Desktop'], excluded: [] },
+      controlValues: {},
+      defaultDataMask: {},
+      cascadeParentIds: [],
+      targets: [{ column: { name: 'col' }, datasetId: 2 }],
+      description: 'Filter scoped to inactive tab',
+    },
+  ];
+
+  const { result } = renderHook(() => useSelectFiltersInScope(filters));
+  expect(result.current[0]).toHaveLength(1);
+  expect(result.current[0][0]).toEqual(
+    expect.objectContaining({ id: 'filter_active_tab' }),
+  );
+  expect(result.current[1]).toHaveLength(1);
+  expect(result.current[1][0]).toEqual(
+    expect.objectContaining({ id: 'filter_inactive_tab' }),
+  );
+});
+
+// Layout-derived default-tab fallback edge cases. These pin behavior of
+// useActiveDashboardTabs when activeTabs is empty across structural variants
+// of dashboardLayout, so the fallback can't silently regress.
+
+test('useIsFilterInScope: dashboard with no top-level tabs (root child is GRID_ID) treats filters as in-scope', () => {
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: [] },
+      dashboardLayout: {
+        present: {
+          ROOT_ID: { type: 'ROOT', id: 'ROOT_ID', children: ['GRID_ID'] },
+          GRID_ID: { type: 'GRID', id: 'GRID_ID', children: ['CHART-1'] },
+          'CHART-1': {
+            type: 'CHART',
+            meta: { chartId: 1 },
+            parents: ['ROOT_ID', 'GRID_ID'],
+          },
+        },
+      },
+    };
+    return selector(mockState);
+  });
+
+  const filter: Filter = {
+    id: 'filter_no_tabs',
+    name: 'No-tabs filter',
+    filterType: 'filter_select',
+    type: NativeFilterType.NativeFilter,
+    chartsInScope: [1],
+    scope: { rootPath: ['ROOT_ID'], excluded: [] },
+    controlValues: {},
+    defaultDataMask: {},
+    cascadeParentIds: [],
+    targets: [{ column: { name: 'col' }, datasetId: 1 }],
+    description: 'Filter on a no-tabs dashboard',
+  };
+
+  const { result } = renderHook(() => useIsFilterInScope());
+  // Chart has no TAB ancestors → tabParents is empty → considered in-scope.
+  expect(result.current(filter)).toBe(true);
+});
+
+test('useIsFilterInScope: missing dashboardLayout falls back without crashing', () => {
+  (useSelector as jest.Mock).mockImplementation((selector: Function) => {
+    const mockState = {
+      dashboardState: { activeTabs: [] },
+      dashboardLayout: { present: undefined },
+    };
+    return selector(mockState);
+  });
+
+  const filter: Filter = {
+    id: 'filter_no_layout',
+    name: 'No layout',
+    filterType: 'filter_select',
+    type: NativeFilterType.NativeFilter,
+    chartsInScope: [1],
+    scope: { rootPath: ['TAB-A'], excluded: [] },
+    controlValues: {},
+    defaultDataMask: {},
+    cascadeParentIds: [],
+    targets: [{ column: { name: 'col' }, datasetId: 1 }],
+    description: 'Filter when layout is missing',
+  };
+
+  // The hook should not throw when layout is missing. Without the
+  // useActiveDashboardTabs guard, indexing dashboardLayout[ROOT_ID] would
+  // crash here.
+  const { result } = renderHook(() => useIsFilterInScope());
+  expect(() => result.current(filter)).not.toThrow();
+});
+
+// Shared fixture for the two nested-tabs tests below. Layout is identical;
+// only the redux activeTabs differs (empty for the default-path test,
+// inner-only for the hideTab ancestor-merge test).
+const nestedTabsLayout = () => ({
+  ROOT_ID: { type: 'ROOT', id: 'ROOT_ID', children: ['TABS-1'] },
+  'TABS-1': {
+    type: 'TABS',
+    id: 'TABS-1',
+    children: ['TAB-Outer1', 'TAB-Outer2'],
+  },
+  'TAB-Outer1': {
+    type: 'TAB',
+    id: 'TAB-Outer1',
+    children: ['TABS-2'],
+  },
+  'TAB-Outer2': {
+    type: 'TAB',
+    id: 'TAB-Outer2',
+    children: ['CHART-Outer2'],
+  },
+  'TABS-2': {
+    type: 'TABS',
+    id: 'TABS-2',
+    children: ['TAB-Inner1', 'TAB-Inner2'],
+  },
+  'TAB-Inner1': {
+    type: 'TAB',
+    id: 'TAB-Inner1',
+    children: ['CHART-Inner1'],
+  },
+  'TAB-Inner2': {
+    type: 'TAB',
+    id: 'TAB-Inner2',
+    children: ['CHART-Inner2'],
+  },
+  'CHART-Inner1': {
+    type: 'CHART',
+    meta: { chartId: 11 },
+    parents: ['ROOT_ID', 'TAB-Outer1', 'TABS-2', 'TAB-Inner1'],
+  },
+  'CHART-Inner2': {
+    type: 'CHART',
+    meta: { chartId: 12 },
+    parents: ['ROOT_ID', 'TAB-Outer1', 'TABS-2', 'TAB-Inner2'],
+  },
+  'CHART-Outer2': {
+    type: 'CHART',
+    meta: { chartId: 20 },
+    parents: ['ROOT_ID', 'TAB-Outer2'],
+  },
+});
+
+const mockNestedTabsState = (activeTabs: string[]) => ({
+  dashboardState: { activeTabs },
+  dashboardLayout: { present: nestedTabsLayout() },
+});
+
+test('useIsFilterInScope: deeply nested tabs — default path includes inner-tab default', () => {
+  // ROOT → TABS-1 → [TAB-Outer1, TAB-Outer2]
+  //                  └─ TAB-Outer1 → TABS-2 → [TAB-Inner1, TAB-Inner2]
+  // Default path should be ['TAB-Outer1', 'TAB-Inner1'].
+  (useSelector as jest.Mock).mockImplementation((selector: Function) =>
+    selector(mockNestedTabsState([])),
+  );
+
+  const innerDefaultFilter: Filter = {
+    id: 'filter_inner1',
+    name: 'Inner default-tab filter',
+    filterType: 'filter_select',
+    type: NativeFilterType.NativeFilter,
+    chartsInScope: [11],
+    scope: { rootPath: ['TAB-Inner1'], excluded: [] },
+    controlValues: {},
+    defaultDataMask: {},
+    cascadeParentIds: [],
+    targets: [{ column: { name: 'col' }, datasetId: 1 }],
+    description: 'Filter scoped to inner default tab',
+  };
+
+  const innerNonDefaultFilter: Filter = {
+    ...innerDefaultFilter,
+    id: 'filter_inner2',
+    chartsInScope: [12],
+    scope: { rootPath: ['TAB-Inner2'], excluded: [] },
+  };
+
+  const { result } = renderHook(() => useIsFilterInScope());
+  // CHART-Inner1's tab parents [TAB-Outer1, TAB-Inner1] are both in default
+  // path → in scope.
+  expect(result.current(innerDefaultFilter)).toBe(true);
+  // CHART-Inner2's tab parent TAB-Inner2 is not in default path → out of scope.
+  expect(result.current(innerNonDefaultFilter)).toBe(false);
+});
+
+test('useIsFilterInScope: nested Tabs mounted under hideTab:true — outer ancestor merged so outer-tab scoping is preserved', () => {
+  // hideTab:true skips the top-level Tabs but a nested Tabs can still mount
+  // and dispatch setActiveTab. activeTabs holds only the inner id; without
+  // ancestor merging, filters whose charts have tabParents=[outer, inner]
+  // would be marked out-of-scope because the outer id is missing.
+  (useSelector as jest.Mock).mockImplementation((selector: Function) =>
+    selector(mockNestedTabsState(['TAB-Inner1'])),
+  );
+
+  const innerActiveFilter: Filter = {
+    id: 'filter_inner1_active',
+    name: 'Filter scoped to active inner tab',
+    filterType: 'filter_select',
+    type: NativeFilterType.NativeFilter,
+    chartsInScope: [11],
+    scope: { rootPath: ['TAB-Inner1'], excluded: [] },
+    controlValues: {},
+    defaultDataMask: {},
+    cascadeParentIds: [],
+    targets: [{ column: { name: 'col' }, datasetId: 1 }],
+    description: 'Filter on the active inner tab',
+  };
+
+  const otherOuterFilter: Filter = {
+    id: 'filter_other_outer',
+    name: 'Filter scoped to non-default outer tab',
+    filterType: 'filter_select',
+    type: NativeFilterType.NativeFilter,
+    chartsInScope: [20],
+    scope: { rootPath: ['TAB-Outer2'], excluded: [] },
+    controlValues: {},
+    defaultDataMask: {},
+    cascadeParentIds: [],
+    targets: [{ column: { name: 'col' }, datasetId: 2 }],
+    description: 'Filter on the other outer tab — must stay out of scope',
+  };
+
+  const { result } = renderHook(() => useIsFilterInScope());
+  // Outer ancestor TAB-Outer1 is merged into the active path → in scope.
+  expect(result.current(innerActiveFilter)).toBe(true);
+  // TAB-Outer2 is not in the active path → out of scope, scoping preserved.
+  expect(result.current(otherOuterFilter)).toBe(false);
+});
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/state.ts b/superset-frontend/src/dashboard/components/nativeFilters/state.ts
index 11034ab1da0..fd7213a0d30 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/state.ts
+++ b/superset-frontend/src/dashboard/components/nativeFilters/state.ts
@@ -30,7 +30,8 @@ import {
 } from '@superset-ui/core';
 import { FilterElement } from './FilterBar/FilterControls/types';
 import { ActiveTabs, DashboardLayout, RootState } from '../../types';
-import { CHART_TYPE, TAB_TYPE } from '../../util/componentTypes';
+import { CHART_TYPE, TAB_TYPE, TABS_TYPE } from '../../util/componentTypes';
+import { DASHBOARD_ROOT_ID } from '../../util/constants';
 import { isChartCustomizationId } from './FiltersConfigModal/utils';
 import {
   migrateChartCustomizationArray,
@@ -38,6 +39,7 @@ import {
 } from '../../util/migrateChartCustomization';
 
 const EMPTY_ARRAY: ChartCustomizationConfiguration = [];
+const EMPTY_ACTIVE_TABS: ActiveTabs = [];
 const defaultFilterConfiguration: (Filter | Divider)[] = [];
 
 export const selectFilterConfiguration: (
@@ -173,22 +175,83 @@ export function useDashboardHasTabs() {
   const dashboardLayout = useDashboardLayout();
   return useMemo(
     () =>
-      Object.values(dashboardLayout).some(element => element.type === TAB_TYPE),
+      dashboardLayout
+        ? Object.values(dashboardLayout).some(
+            element => element.type === TAB_TYPE,
+          )
+        : false,
     [dashboardLayout],
   );
 }
 
-function useActiveDashboardTabs() {
-  return useSelector<RootState, ActiveTabs>(
+function useActiveDashboardTabs(): ActiveTabs {
+  const reduxTabs = useSelector<RootState, ActiveTabs>(
     state => state.dashboardState?.activeTabs,
   );
+  const dashboardLayout = useDashboardLayout();
+
+  return useMemo(() => {
+    const reduxList = reduxTabs ?? [];
+    const reduxFallback = reduxList.length ? reduxList : EMPTY_ACTIVE_TABS;
+    if (!dashboardLayout) return reduxFallback;
+
+    // Tabbed dashboards always nest the top-level TABS container as the first
+    // child of ROOT. If that invariant doesn't hold (no-tabs layout), no
+    // fallback applies and we use reduxTabs as-is.
+    const root = dashboardLayout[DASHBOARD_ROOT_ID];
+    if (!root?.children?.length) return reduxFallback;
+    const topContainer = dashboardLayout[root.children[0]];
+    if (topContainer?.type !== TABS_TYPE || !topContainer.children?.length) {
+      return reduxFallback;
+    }
+
+    // Walk every TABS container along the active path. For each container,
+    // pick the child Redux marked active; otherwise pick the first child (the
+    // default the live Tabs component would render). This handles:
+    //   - empty reduxTabs (hideTab:true, no permalink) → full default path
+    //   - reduxTabs missing an outer ancestor (hideTab:true skipped the
+    //     top-level Tabs, but a nested Tabs dispatched setActiveTab) → fill
+    //     in the missing ancestor so outer-tab scoping is preserved
+    //   - fully populated reduxTabs (normal hydration) → same result
+    const reduxSet = new Set(reduxList);
+    const result: ActiveTabs = [];
+    const queue: string[] = [
+      topContainer.children.find(c => reduxSet.has(c)) ??
+        topContainer.children[0],
+    ];
+    while (queue.length > 0) {
+      const tabId = queue.shift()!;
+      result.push(tabId);
+      const tab = dashboardLayout[tabId];
+      if (!tab?.children) continue;
+      for (const childId of tab.children) {
+        const child = dashboardLayout[childId];
+        if (child?.type !== TABS_TYPE || !child.children?.length) continue;
+        queue.push(
+          child.children.find(c => reduxSet.has(c)) ?? child.children[0],
+        );
+      }
+    }
+
+    // Preserve any reduxTabs entries that fell outside the traversed path so
+    // we never silently drop a redux-marked active tab id.
+    const resultSet = new Set(result);
+    for (const id of reduxList) {
+      if (!resultSet.has(id)) result.push(id);
+    }
+    return result;
+  }, [reduxTabs, dashboardLayout]);
 }
 
 function useSelectChartTabParents() {
   const dashboardLayout = useDashboardLayout();
   const layoutChartItems = useMemo(
     () =>
-      Object.values(dashboardLayout).filter(item => item.type === CHART_TYPE),
+      dashboardLayout
+        ? Object.values(dashboardLayout).filter(
+            item => item.type === CHART_TYPE,
+          )
+        : [],
     [dashboardLayout],
   );
   return useCallback(
@@ -197,7 +260,7 @@ function useSelectChartTabParents() {
         layoutItem => layoutItem.meta?.chartId === chartId,
       );
       return chartLayoutItem?.parents?.filter(
-        (parent: string) => dashboardLayout[parent]?.type === TAB_TYPE,
+        (parent: string) => dashboardLayout?.[parent]?.type === TAB_TYPE,
       );
     },
     [dashboardLayout, layoutChartItems],
@@ -330,6 +393,7 @@ export function useSelectCustomizationsInScope(
       | ChartCustomizationDivider
     )[] = [];
 
+    // we check customization scopes only on dashboards with tabs
     if (!dashboardHasTabs) {
       customizationsInScope = customizations;
     } else {


(superset) 05/07: feat(explore): add CSV/XLS download to drill-to-detail modal (backport #37109) (#42051)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michael-s-molina pushed a commit to branch 6.2
in repository https://gitbox.apache.org/repos/asf/superset.git

commit e0b8bbcb216ad7a45c6231b1efa5354dfde16bdf
Author: Luiz Otavio <45...@users.noreply.github.com>
AuthorDate: Thu Jul 16 13:45:13 2026 -0300

    feat(explore): add CSV/XLS download to drill-to-detail modal (backport #37109) (#42051)
    
    Co-authored-by: Claude Opus 4.8 <no...@anthropic.com>
---
 .../components/Chart/DrillBy/DrillByModal.test.tsx | 148 +++++++++++++++++++++
 .../src/components/Chart/DrillBy/DrillByModal.tsx  |  65 ++++++++-
 .../Chart/DrillBy/useResultsTableView.tsx          |   9 ++
 .../Chart/DrillDetail/DownloadDropdown.test.tsx    |  57 ++++++++
 .../Chart/DrillDetail/DownloadDropdown.tsx         |  89 +++++++++++++
 .../Chart/DrillDetail/DrillDetailPane.test.tsx     | 143 +++++++++++++++++++-
 .../Chart/DrillDetail/DrillDetailPane.tsx          |  75 +++++++++++
 .../DrillDetailTableControls.stories.tsx           |   6 +
 .../DrillDetail/DrillDetailTableControls.test.tsx  |  28 +++-
 .../Chart/DrillDetail/DrillDetailTableControls.tsx |  40 +++++-
 .../components/DataTableControls.test.tsx          | 133 ++++++++++++++++++
 .../components/DataTableControls.tsx               |  35 ++++-
 .../components/SingleQueryResultPane.tsx           |   6 +
 .../src/explore/components/DataTablesPane/types.ts |  11 +-
 superset/views/base.py                             |   1 +
 15 files changed, 825 insertions(+), 21 deletions(-)

diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.test.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.test.tsx
index 0f840d87430..d347ac919b0 100644
--- a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.test.tsx
+++ b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.test.tsx
@@ -40,6 +40,34 @@ jest.mock('src/dashboard/util/isEmbedded', () => ({
   isEmbedded: jest.fn(() => false),
 }));
 
+const mockAddDangerToast = jest.fn();
+jest.mock('src/components/MessageToasts/withToasts', () => {
+  const actual = jest.requireActual('src/components/MessageToasts/withToasts');
+  return {
+    __esModule: true,
+    ...actual,
+    useToasts: () => ({
+      addDangerToast: mockAddDangerToast,
+      addSuccessToast: jest.fn(),
+      addInfoToast: jest.fn(),
+      addWarningToast: jest.fn(),
+    }),
+  };
+});
+
+jest.mock('src/explore/exploreUtils', () => {
+  const actual = jest.requireActual('src/explore/exploreUtils');
+  return {
+    ...actual,
+    exportChart: jest.fn(),
+  };
+});
+
+// eslint-disable-next-line @typescript-eslint/no-var-requires
+const { exportChart: exportChartMock } = jest.requireMock(
+  'src/explore/exploreUtils',
+) as { exportChart: jest.Mock };
+
 const CHART_DATA_ENDPOINT = 'glob:*/api/v1/chart/data*';
 const FORM_DATA_KEY_ENDPOINT = 'glob:*/api/v1/explore/form_data';
 
@@ -553,4 +581,124 @@ describe('Table view with pagination', () => {
     // Table should still be rendered without crashes
     expect(screen.getByTestId('drill-by-results-table')).toBeInTheDocument();
   });
+
+  test('CSV download calls exportChart with drilledFormData', async () => {
+    exportChartMock.mockClear();
+    await renderModal({
+      column: { column_name: 'state', verbose_name: null },
+      drillByConfig: {
+        filters: [{ col: 'gender', op: '==', val: 'boy' }],
+        groupbyFieldName: 'groupby',
+      },
+    });
+
+    const tableRadio = await screen.findByRole('radio', { name: /table/i });
+    userEvent.click(tableRadio);
+    await waitFor(() =>
+      expect(screen.getByTestId('drill-by-results-table')).toBeInTheDocument(),
+    );
+
+    await userEvent.click(
+      await screen.findByRole('button', { name: 'Download' }),
+    );
+    await userEvent.click(await screen.findByText('Export to CSV'));
+
+    expect(exportChartMock).toHaveBeenCalledTimes(1);
+    expect(exportChartMock).toHaveBeenCalledWith(
+      expect.objectContaining({
+        resultFormat: 'csv',
+        resultType: 'full',
+        formData: expect.objectContaining({ slice_id: 0 }),
+      }),
+    );
+  });
+
+  test('XLSX download calls exportChart with xlsx format', async () => {
+    exportChartMock.mockClear();
+    await renderModal({
+      column: { column_name: 'state', verbose_name: null },
+      drillByConfig: {
+        filters: [{ col: 'gender', op: '==', val: 'boy' }],
+        groupbyFieldName: 'groupby',
+      },
+    });
+
+    const tableRadio = await screen.findByRole('radio', { name: /table/i });
+    userEvent.click(tableRadio);
+    await waitFor(() =>
+      expect(screen.getByTestId('drill-by-results-table')).toBeInTheDocument(),
+    );
+
+    await userEvent.click(
+      await screen.findByRole('button', { name: 'Download' }),
+    );
+    await userEvent.click(await screen.findByText('Export to Excel'));
+
+    expect(exportChartMock).toHaveBeenCalledTimes(1);
+    expect(exportChartMock).toHaveBeenCalledWith(
+      expect.objectContaining({
+        resultFormat: 'xlsx',
+        resultType: 'full',
+        formData: expect.objectContaining({ slice_id: 0 }),
+      }),
+    );
+  });
+
+  test('shows a danger toast when exportChart fails', async () => {
+    exportChartMock.mockClear();
+    mockAddDangerToast.mockClear();
+    exportChartMock.mockRejectedValueOnce(new Error('boom'));
+    await renderModal({
+      column: { column_name: 'state', verbose_name: null },
+      drillByConfig: {
+        filters: [{ col: 'gender', op: '==', val: 'boy' }],
+        groupbyFieldName: 'groupby',
+      },
+    });
+
+    const tableRadio = await screen.findByRole('radio', { name: /table/i });
+    userEvent.click(tableRadio);
+    await waitFor(() =>
+      expect(screen.getByTestId('drill-by-results-table')).toBeInTheDocument(),
+    );
+
+    await userEvent.click(
+      await screen.findByRole('button', { name: 'Download' }),
+    );
+    await userEvent.click(await screen.findByText('Export to CSV'));
+
+    await waitFor(() =>
+      expect(mockAddDangerToast).toHaveBeenCalledWith(
+        'Failed to generate download: boom',
+      ),
+    );
+  });
+
+  test('reload re-fetches chart data', async () => {
+    await renderModal({
+      column: { column_name: 'state', verbose_name: null },
+      drillByConfig: {
+        filters: [{ col: 'gender', op: '==', val: 'boy' }],
+        groupbyFieldName: 'groupby',
+      },
+    });
+
+    const tableRadio = await screen.findByRole('radio', { name: /table/i });
+    userEvent.click(tableRadio);
+    await waitFor(() =>
+      expect(screen.getByTestId('drill-by-results-table')).toBeInTheDocument(),
+    );
+
+    const callsBefore = fetchMock.callHistory.calls(CHART_DATA_ENDPOINT).length;
+
+    await userEvent.click(
+      await screen.findByRole('button', { name: 'Reload' }),
+    );
+
+    await waitFor(() =>
+      expect(
+        fetchMock.callHistory.calls(CHART_DATA_ENDPOINT).length,
+      ).toBeGreaterThan(callsBefore),
+    );
+  });
 });
diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx
index 1bb63d0d81e..57149ee55e0 100644
--- a/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx
+++ b/superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx
@@ -54,7 +54,7 @@ import {
   LOG_ACTIONS_FURTHER_DRILL_BY,
 } from 'src/logger/LogUtils';
 import { findPermission } from 'src/utils/findPermission';
-import { getQuerySettings } from 'src/explore/exploreUtils';
+import { getQuerySettings, exportChart } from 'src/explore/exploreUtils';
 import { isEmbedded } from 'src/dashboard/util/isEmbedded';
 import { Dataset, DrillByType } from '../types';
 import DrillByChart from './DrillByChart';
@@ -209,12 +209,6 @@ export default function DrillByModal({
   const { displayModeToggle, drillByDisplayMode } = useDisplayModeToggle();
   const [chartDataResult, setChartDataResult] = useState<QueryData[]>();
 
-  const resultsTable = useResultsTableView(
-    chartDataResult,
-    formData.datasource,
-    canDownload,
-  );
-
   const [currentFormData, setCurrentFormData] = useState(formData);
   const [usedGroupbyColumns, setUsedGroupbyColumns] = useState<Column[]>(
     [...initialGroupbyColumns, column].filter(isDefined),
@@ -377,6 +371,63 @@ export default function DrillByModal({
     formData,
   ]);
 
+  const handleDownload = useCallback(
+    (exportType: 'csv' | 'xlsx') => {
+      Promise.resolve(
+        exportChart({
+          formData: drilledFormData,
+          resultFormat: exportType,
+          resultType: 'full',
+        }),
+      ).catch(error => {
+        addDangerToast(
+          t('Failed to generate download: %s', error?.message || error),
+        );
+      });
+    },
+    [drilledFormData, addDangerToast],
+  );
+
+  const handleDownloadCSV = useCallback(
+    () => handleDownload('csv'),
+    [handleDownload],
+  );
+
+  const handleDownloadXLSX = useCallback(
+    () => handleDownload('xlsx'),
+    [handleDownload],
+  );
+
+  const handleReload = useCallback(() => {
+    setChartDataResult(undefined);
+    setIsChartDataLoading(true);
+    const [useLegacyApi] = getQuerySettings(drilledFormData);
+    getChartDataRequest({
+      formData: drilledFormData,
+    })
+      .then(({ response, json }) =>
+        handleChartDataResponse(response, json, useLegacyApi),
+      )
+      .then(queriesResponse => {
+        setChartDataResult(queriesResponse);
+      })
+      .catch(() => {
+        addDangerToast(t('Failed to load chart data.'));
+      })
+      .finally(() => {
+        setIsChartDataLoading(false);
+      });
+  }, [addDangerToast, drilledFormData]);
+
+  const resultsTable = useResultsTableView(
+    chartDataResult,
+    formData.datasource,
+    canDownload,
+    handleDownloadCSV,
+    handleDownloadXLSX,
+    handleReload,
+  );
+
   useEffect(() => {
     setUsedGroupbyColumns(usedCols =>
       !currentColumn ||
diff --git a/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx b/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx
index 4664e372f32..b36ef4a992c 100644
--- a/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx
+++ b/superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx
@@ -35,6 +35,9 @@ export const useResultsTableView = (
   chartDataResult: QueryData[] | undefined,
   datasourceId: string,
   canDownload: boolean,
+  onDownloadCSV?: () => void,
+  onDownloadXLSX?: () => void,
+  onReload?: () => void,
 ) => {
   if (!isDefined(chartDataResult)) {
     return <div />;
@@ -50,6 +53,9 @@ export const useResultsTableView = (
           datasourceId={datasourceId}
           isVisible
           canDownload={canDownload}
+          onDownloadCSV={onDownloadCSV}
+          onDownloadXLSX={onDownloadXLSX}
+          onReload={onReload}
         />
       </ResultContainer>
     );
@@ -70,6 +76,9 @@ export const useResultsTableView = (
               datasourceId={datasourceId}
               isVisible
               canDownload={canDownload}
+              onDownloadCSV={onDownloadCSV}
+              onDownloadXLSX={onDownloadXLSX}
+              onReload={onReload}
             />
           </ResultContainer>
         ),
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DownloadDropdown.test.tsx b/superset-frontend/src/components/Chart/DrillDetail/DownloadDropdown.test.tsx
new file mode 100644
index 00000000000..f09c364dcbc
--- /dev/null
+++ b/superset-frontend/src/components/Chart/DrillDetail/DownloadDropdown.test.tsx
@@ -0,0 +1,57 @@
+/**
+ * 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.
+ */
+import { render, screen, userEvent } from 'spec/helpers/testing-library';
+import DownloadDropdown from './DownloadDropdown';
+
+const onDownloadCSV = jest.fn();
+const onDownloadXLSX = jest.fn();
+
+beforeEach(() => {
+  onDownloadCSV.mockClear();
+  onDownloadXLSX.mockClear();
+});
+
+const setup = () =>
+  render(
+    <DownloadDropdown
+      onDownloadCSV={onDownloadCSV}
+      onDownloadXLSX={onDownloadXLSX}
+    />,
+  );
+
+test('renders a download trigger with accessible label', () => {
+  setup();
+  expect(screen.getByRole('button', { name: 'Download' })).toBeInTheDocument();
+});
+
+test('fires onDownloadCSV when CSV menu item is selected', async () => {
+  setup();
+  await userEvent.click(screen.getByRole('button', { name: 'Download' }));
+  await userEvent.click(await screen.findByText('Export to CSV'));
+  expect(onDownloadCSV).toHaveBeenCalledTimes(1);
+  expect(onDownloadXLSX).not.toHaveBeenCalled();
+});
+
+test('fires onDownloadXLSX when Excel menu item is selected', async () => {
+  setup();
+  await userEvent.click(screen.getByRole('button', { name: 'Download' }));
+  await userEvent.click(await screen.findByText('Export to Excel'));
+  expect(onDownloadXLSX).toHaveBeenCalledTimes(1);
+  expect(onDownloadCSV).not.toHaveBeenCalled();
+});
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DownloadDropdown.tsx b/superset-frontend/src/components/Chart/DrillDetail/DownloadDropdown.tsx
new file mode 100644
index 00000000000..673a9749431
--- /dev/null
+++ b/superset-frontend/src/components/Chart/DrillDetail/DownloadDropdown.tsx
@@ -0,0 +1,89 @@
+/**
+ * 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.
+ */
+
+import { t } from '@apache-superset/core/translation';
+import { css, useTheme } from '@apache-superset/core/theme';
+import { Dropdown, Tooltip } from '@superset-ui/core/components';
+import { Icons } from '@superset-ui/core/components/Icons';
+
+interface DownloadDropdownProps {
+  onDownloadCSV: () => void;
+  onDownloadXLSX: () => void;
+}
+
+const DownloadDropdown = ({
+  onDownloadCSV,
+  onDownloadXLSX,
+}: DownloadDropdownProps) => {
+  const theme = useTheme();
+  return (
+    <Dropdown
+      trigger={['click']}
+      menu={{
+        onClick: ({ key }) => {
+          if (key === 'csv') {
+            onDownloadCSV();
+          } else {
+            onDownloadXLSX();
+          }
+        },
+        items: [
+          {
+            key: 'csv',
+            label: t('Export to CSV'),
+            icon: <Icons.FileOutlined />,
+          },
+          {
+            key: 'xlsx',
+            label: t('Export to Excel'),
+            icon: <Icons.FileOutlined />,
+          },
+        ],
+      }}
+    >
+      <Tooltip title={t('Download')}>
+        <button
+          type="button"
+          aria-label={t('Download')}
+          data-test="drill-detail-download-btn"
+          css={css`
+            display: inline-flex;
+            align-items: center;
+            padding: 0;
+            border: none;
+            background: none;
+            cursor: pointer;
+          `}
+        >
+          <Icons.DownloadOutlined
+            iconColor={theme.colorIcon}
+            iconSize="l"
+            css={css`
+              &.anticon > * {
+                line-height: 0;
+              }
+            `}
+          />
+        </button>
+      </Tooltip>
+    </Dropdown>
+  );
+};
+
+export default DownloadDropdown;
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.test.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.test.tsx
index 030552823ec..5b10d6bbe90 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.test.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.test.tsx
@@ -18,12 +18,33 @@
  */
 import fetchMock from 'fetch-mock';
 import { QueryFormData, SupersetClient } from '@superset-ui/core';
-import { render, screen, waitFor } from 'spec/helpers/testing-library';
+import {
+  render,
+  screen,
+  userEvent,
+  waitFor,
+} from 'spec/helpers/testing-library';
 import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
 import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
 import { supersetGetCache } from 'src/utils/cachedSupersetGet';
+import * as drillUtils from './utils';
 import DrillDetailPane from './DrillDetailPane';
 
+const mockAddDangerToast = jest.fn();
+jest.mock('src/components/MessageToasts/withToasts', () => {
+  const actual = jest.requireActual('src/components/MessageToasts/withToasts');
+  return {
+    __esModule: true,
+    ...actual,
+    useToasts: () => ({
+      addDangerToast: mockAddDangerToast,
+      addSuccessToast: jest.fn(),
+      addInfoToast: jest.fn(),
+      addWarningToast: jest.fn(),
+    }),
+  };
+});
+
 const chart = chartQueries[sliceId];
 const setup = (overrides: Record<string, any> = {}) => {
   const store = getMockStoreWithNativeFilters();
@@ -189,6 +210,126 @@ test('should render the error', async () => {
   expect(screen.getByText('Error: Something went wrong')).toBeInTheDocument();
 });
 
+describe('download actions', () => {
+  const renderWithDownloadPermission = () =>
+    render(
+      <DrillDetailPane
+        initialFilters={[]}
+        formData={chart.form_data as unknown as QueryFormData}
+      />,
+      {
+        useRedux: true,
+        initialState: {
+          user: { roles: { Admin: [['can_csv', 'Superset']] } },
+          common: { conf: { SAMPLES_ROW_LIMIT: 10, ROW_LIMIT: 50000 } },
+          dashboardInfo: { id: 123 },
+        },
+      },
+    );
+
+  const clickDownloadItem = async (label: string) => {
+    await userEvent.click(
+      await screen.findByRole('button', { name: 'Download' }),
+    );
+    await userEvent.click(await screen.findByText(label));
+  };
+
+  test('CSV export posts drill_detail payload with ROW_LIMIT', async () => {
+    fetchWithData();
+    const postFormSpy = jest
+      .spyOn(SupersetClient, 'postForm')
+      .mockImplementation(() => Promise.resolve());
+    renderWithDownloadPermission();
+
+    await clickDownloadItem('Export to CSV');
+
+    expect(postFormSpy).toHaveBeenCalledTimes(1);
+    const body = postFormSpy.mock.calls[0][1] as { form_data: string };
+    const payload = JSON.parse(body.form_data);
+    expect(payload.result_type).toBe('drill_detail');
+    expect(payload.result_format).toBe('csv');
+    expect(payload.queries[0].row_limit).toBe(50000);
+    expect(payload.form_data.dashboardId).toBe(123);
+    postFormSpy.mockRestore();
+  });
+
+  test('XLSX export uses xlsx result_format', async () => {
+    fetchWithData();
+    const postFormSpy = jest
+      .spyOn(SupersetClient, 'postForm')
+      .mockImplementation(() => Promise.resolve());
+    renderWithDownloadPermission();
+
+    await clickDownloadItem('Export to Excel');
+
+    expect(postFormSpy).toHaveBeenCalledTimes(1);
+    const body = postFormSpy.mock.calls[0][1] as { form_data: string };
+    const payload = JSON.parse(body.form_data);
+    expect(payload.result_format).toBe('xlsx');
+    postFormSpy.mockRestore();
+  });
+
+  test('shows a danger toast when the download request fails', async () => {
+    mockAddDangerToast.mockClear();
+    fetchWithData();
+    const postFormSpy = jest
+      .spyOn(SupersetClient, 'postForm')
+      .mockImplementation(() => Promise.reject(new Error('boom')));
+    renderWithDownloadPermission();
+
+    await clickDownloadItem('Export to CSV');
+
+    await waitFor(() =>
+      expect(mockAddDangerToast).toHaveBeenCalledWith(
+        'Failed to generate download: boom',
+      ),
+    );
+    postFormSpy.mockRestore();
+  });
+
+  test('shows a danger toast when the download rejects with a non-Error value', async () => {
+    mockAddDangerToast.mockClear();
+    fetchWithData();
+    const postFormSpy = jest
+      .spyOn(SupersetClient, 'postForm')
+      // eslint-disable-next-line prefer-promise-reject-errors
+      .mockImplementation(() => Promise.reject('kaboom'));
+    renderWithDownloadPermission();
+
+    await clickDownloadItem('Export to CSV');
+
+    await waitFor(() =>
+      expect(mockAddDangerToast).toHaveBeenCalledWith(
+        'Failed to generate download: kaboom',
+      ),
+    );
+    postFormSpy.mockRestore();
+  });
+
+  test('shows a danger toast when the drill payload cannot be generated', async () => {
+    mockAddDangerToast.mockClear();
+    fetchWithData();
+    const getDrillPayloadSpy = jest
+      .spyOn(drillUtils, 'getDrillPayload')
+      .mockReturnValue(undefined);
+    const postFormSpy = jest
+      .spyOn(SupersetClient, 'postForm')
+      .mockImplementation(() => Promise.resolve());
+    renderWithDownloadPermission();
+
+    await clickDownloadItem('Export to CSV');
+
+    await waitFor(() =>
+      expect(mockAddDangerToast).toHaveBeenCalledWith(
+        'Unable to generate download payload',
+      ),
+    );
+    expect(postFormSpy).not.toHaveBeenCalled();
+    getDrillPayloadSpy.mockRestore();
+    postFormSpy.mockRestore();
+  });
+});
+
 test('should use verbose_map for column headers when available', async () => {
   jest.restoreAllMocks();
 
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
index 747c17d80bf..748abe35e06 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
@@ -33,6 +33,7 @@ import {
   ensureIsArray,
   JsonObject,
   QueryFormData,
+  SupersetClient,
 } from '@superset-ui/core';
 import { css, useTheme } from '@apache-superset/core/theme';
 import { GenericDataType } from '@apache-superset/core/common';
@@ -47,6 +48,10 @@ import Table, {
   TableSize,
 } from '@superset-ui/core/components/Table';
 import { RootState } from 'src/dashboard/types';
+import { usePermissions } from 'src/hooks/usePermissions';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { ensureAppRoot } from 'src/utils/pathUtils';
+import { safeStringify } from 'src/utils/safeStringify';
 import HeaderWithRadioGroup from '@superset-ui/core/components/Table/header-renderers/HeaderWithRadioGroup';
 import { useDatasetMetadataBar } from 'src/features/datasets/metadataBar/useDatasetMetadataBar';
 import { Dataset } from '../types';
@@ -108,6 +113,13 @@ export default function DrillDetailPane({
       state.common.conf.SAMPLES_ROW_LIMIT,
   );
 
+  const ROW_LIMIT = useSelector(
+    (state: { common: { conf: JsonObject } }) => state.common.conf.ROW_LIMIT,
+  );
+
+  const { canDownload } = usePermissions();
+  const { addDangerToast } = useToasts();
+
   // Extract datasource ID/type from string ID
   const [datasourceId, datasourceType] = useMemo(
     () => formData.datasource.split('__'),
@@ -207,6 +219,64 @@ export default function DrillDetailPane({
     setPageIndex(0);
   }, []);
 
+  const handleDownload = useCallback(
+    (exportType: 'csv' | 'xlsx') => {
+      const drillPayload = getDrillPayload(formData, filters);
+      if (!drillPayload) {
+        addDangerToast(t('Unable to generate download payload'));
+        return;
+      }
+      const payload: JsonObject = {
+        datasource: {
+          id: parseInt(datasourceId, 10),
+          type: datasourceType,
+        },
+        queries: [
+          {
+            ...drillPayload,
+            columns: [],
+            metrics: [],
+            orderby: [],
+            row_limit: ROW_LIMIT,
+            row_offset: 0,
+          },
+        ],
+        result_type: 'drill_detail',
+        result_format: exportType,
+        force: false,
+      };
+      if (dashboardId) {
+        payload.form_data = { dashboardId };
+      }
+      SupersetClient.postForm(ensureAppRoot('/api/v1/chart/data'), {
+        form_data: safeStringify(payload),
+      }).catch(error => {
+        addDangerToast(
+          t('Failed to generate download: %s', error?.message ?? String(error)),
+        );
+      });
+    },
+    [
+      formData,
+      filters,
+      datasourceId,
+      datasourceType,
+      ROW_LIMIT,
+      dashboardId,
+      addDangerToast,
+    ],
+  );
+
+  const handleDownloadCSV = useCallback(
+    () => handleDownload('csv'),
+    [handleDownload],
+  );
+
+  const handleDownloadXLSX = useCallback(
+    () => handleDownload('xlsx'),
+    [handleDownload],
+  );
+
   // Clear cache and reset page index if filters change
   useEffect(() => {
     setResponseError('');
@@ -338,6 +408,11 @@ export default function DrillDetailPane({
           totalCount={resultsPage?.total}
           loading={isLoading}
           onReload={handleReload}
+          canDownload={canDownload}
+          onDownloadCSV={handleDownloadCSV}
+          onDownloadXLSX={handleDownloadXLSX}
+          data={data}
+          columnNames={resultsPage?.colNames}
         />
       )}
       {tableContent}
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.stories.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.stories.tsx
index 2af6c354f4a..99efcfa3f0a 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.stories.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.stories.tsx
@@ -33,4 +33,10 @@ InteractiveTableControls.args = {
     { op: '>', col: 'tz_offset', val: 200 },
     { op: '==', col: 'platform', val: 'GB' },
   ],
+  setFilters: () => {},
+  canDownload: true,
+  onDownloadCSV: () => {},
+  onDownloadXLSX: () => {},
+  onReload: () => {},
+  loading: false,
 };
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.test.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.test.tsx
index 91ac078ed8e..8b5017d6fbc 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.test.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.test.tsx
@@ -17,20 +17,27 @@
  * under the License.
  */
 import { render, screen, userEvent } from 'spec/helpers/testing-library';
-import TableControls from './DrillDetailTableControls';
+import TableControls, { TableControlsProps } from './DrillDetailTableControls';
 
 const setFilters = jest.fn();
 const onReload = jest.fn();
-const setup = (overrides: Record<string, any> = {}) => {
+const onDownloadCSV = jest.fn();
+const onDownloadXLSX = jest.fn();
+const setup = (overrides: Partial<TableControlsProps> = {}) => {
   const props = {
     filters: [],
     setFilters,
     onReload,
     loading: false,
     totalCount: 0,
+    canDownload: true,
+    onDownloadCSV,
+    onDownloadXLSX,
+    data: [],
+    columnNames: [],
     ...overrides,
   };
-  return render(<TableControls {...props} />);
+  return render(<TableControls {...props} />, { useRedux: true });
 };
 test('should render', () => {
   const { container } = setup();
@@ -54,6 +61,21 @@ test('should render the reload button', () => {
   expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument();
 });
 
+test('should render the download button when canDownload is true', () => {
+  setup();
+  expect(screen.getByRole('button', { name: 'Download' })).toBeInTheDocument();
+});
+
+test('should hide download and copy buttons when canDownload is false', () => {
+  setup({ canDownload: false });
+  expect(
+    screen.queryByRole('button', { name: 'Download' }),
+  ).not.toBeInTheDocument();
+  expect(
+    screen.queryByRole('button', { name: 'Copy' }),
+  ).not.toBeInTheDocument();
+});
+
 test('should show the loading indicator', () => {
   setup({
     loading: true,
diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx
index f1c7e23af39..c81f215d4cc 100644
--- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx
+++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx
@@ -27,6 +27,10 @@ import {
 import { css, useTheme } from '@apache-superset/core/theme';
 import RowCountLabel from 'src/components/RowCountLabel';
 import { Icons } from '@superset-ui/core/components/Icons';
+import { Tooltip } from '@superset-ui/core/components';
+import { CopyToClipboardButton } from 'src/explore/components/DataTableControl';
+import { TabularDataRow } from 'src/utils/common';
+import DownloadDropdown from './DownloadDropdown';
 
 export type TableControlsProps = {
   filters: BinaryQueryObjectFilterClause[];
@@ -34,6 +38,11 @@ export type TableControlsProps = {
   totalCount?: number;
   loading: boolean;
   onReload: () => void;
+  canDownload: boolean;
+  onDownloadCSV: () => void;
+  onDownloadXLSX: () => void;
+  data?: TabularDataRow[];
+  columnNames?: string[];
 };
 
 export default function TableControls({
@@ -42,6 +51,11 @@ export default function TableControls({
   totalCount,
   loading,
   onReload,
+  canDownload,
+  onDownloadCSV,
+  onDownloadXLSX,
+  data,
+  columnNames,
 }: TableControlsProps) {
   const theme = useTheme();
   const filterMap: Record<string, BinaryQueryObjectFilterClause> = useMemo(
@@ -118,16 +132,28 @@ export default function TableControls({
           display: flex;
           align-items: center;
           height: min-content;
+          gap: ${theme.sizeUnit * 3}px;
         `}
       >
         <RowCountLabel loading={loading && !totalCount} rowcount={totalCount} />
-        <Icons.ReloadOutlined
-          iconColor={theme.colorIcon}
-          iconSize="l"
-          aria-label={t('Reload')}
-          role="button"
-          onClick={onReload}
-        />
+        {canDownload && (
+          <DownloadDropdown
+            onDownloadCSV={onDownloadCSV}
+            onDownloadXLSX={onDownloadXLSX}
+          />
+        )}
+        {canDownload && (
+          <CopyToClipboardButton data={data} columns={columnNames} />
+        )}
+        <Tooltip title={t('Reload')}>
+          <Icons.ReloadOutlined
+            iconColor={theme.colorIcon}
+            iconSize="l"
+            aria-label={t('Reload')}
+            role="button"
+            onClick={onReload}
+          />
+        </Tooltip>
       </div>
     </div>
   );
diff --git a/superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.test.tsx b/superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.test.tsx
new file mode 100644
index 00000000000..ce9ea7a7c0f
--- /dev/null
+++ b/superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.test.tsx
@@ -0,0 +1,133 @@
+/**
+ * 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.
+ */
+import { GenericDataType } from '@apache-superset/core/common';
+import { render, screen, userEvent } from 'spec/helpers/testing-library';
+import { TableControls, ROW_LIMIT_OPTIONS } from './DataTableControls';
+import { TableControlsProps } from '../types';
+
+const onInputChange = jest.fn();
+const onRowLimitChange = jest.fn();
+const onDownloadCSV = jest.fn();
+const onDownloadXLSX = jest.fn();
+const onReload = jest.fn();
+
+beforeEach(() => {
+  jest.clearAllMocks();
+});
+
+const setup = (overrides: Partial<TableControlsProps> = {}) => {
+  const props: TableControlsProps = {
+    data: [],
+    datasourceId: '1__table',
+    onInputChange,
+    columnNames: [],
+    columnTypes: [],
+    isLoading: false,
+    rowcount: 0,
+    canDownload: true,
+    rowLimit: 1000,
+    rowLimitOptions: ROW_LIMIT_OPTIONS,
+    onRowLimitChange,
+    onDownloadCSV,
+    onDownloadXLSX,
+    onReload,
+    ...overrides,
+  };
+  return render(<TableControls {...props} />, { useRedux: true });
+};
+
+test('renders the reload button as a native, keyboard-focusable button', () => {
+  setup();
+  const reloadButton = screen.getByRole('button', { name: 'Reload' });
+  expect(reloadButton).toBeInTheDocument();
+  // A native <button> is focusable and activates on Enter/Space for free,
+  // unlike a <span role="button"> which keyboard users cannot trigger.
+  expect(reloadButton).toHaveProperty('tagName', 'BUTTON');
+  reloadButton.focus();
+  expect(reloadButton).toHaveFocus();
+});
+
+test('calls onReload when the reload button is clicked', async () => {
+  setup();
+  await userEvent.click(screen.getByRole('button', { name: 'Reload' }));
+  expect(onReload).toHaveBeenCalledTimes(1);
+});
+
+test('does not render the reload button when onReload is omitted', () => {
+  setup({ onReload: undefined });
+  expect(
+    screen.queryByRole('button', { name: 'Reload' }),
+  ).not.toBeInTheDocument();
+});
+
+test('renders the download dropdown when downloads are enabled', () => {
+  setup();
+  expect(screen.getByRole('button', { name: 'Download' })).toBeInTheDocument();
+});
+
+test('hides the download dropdown when canDownload is false', () => {
+  setup({ canDownload: false });
+  expect(
+    screen.queryByRole('button', { name: 'Download' }),
+  ).not.toBeInTheDocument();
+});
+
+test('hides the download dropdown when download callbacks are missing', () => {
+  setup({ onDownloadCSV: undefined, onDownloadXLSX: undefined });
+  expect(
+    screen.queryByRole('button', { name: 'Download' }),
+  ).not.toBeInTheDocument();
+});
+
+test('renders the row limit select and reacts to changes', async () => {
+  setup();
+  const select = screen.getByRole('combobox');
+  await userEvent.click(select);
+  await userEvent.click(await screen.findByText('5k rows'));
+  expect(onRowLimitChange).toHaveBeenCalledWith(
+    5000,
+    expect.objectContaining({ value: 5000 }),
+  );
+});
+
+test('renders the row count label when the row limit select is absent', () => {
+  setup({ onRowLimitChange: undefined, rowcount: 42 });
+  expect(screen.queryByRole('combobox')).not.toBeInTheDocument();
+  expect(screen.getByText('42 rows')).toBeInTheDocument();
+});
+
+test('hides the row count label when rowcount reaches the row limit', () => {
+  setup({ rowcount: 1000, rowLimit: 1000 });
+  expect(screen.queryByText('1000 rows')).not.toBeInTheDocument();
+});
+
+test('shows the row count label when a row limit select exists without a limit', () => {
+  setup({ rowLimit: undefined, rowcount: 7 });
+  expect(screen.getByRole('combobox')).toBeInTheDocument();
+  expect(screen.getByText('7 rows')).toBeInTheDocument();
+});
+
+test('applies time formatting to temporal columns', () => {
+  setup({
+    data: [{ ts: 1000000000000 }],
+    columnNames: ['ts'],
+    columnTypes: [GenericDataType.Temporal],
+  });
+  expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument();
+});
diff --git a/superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx b/superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx
index 205e04938c3..bb4346dabdb 100644
--- a/superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx
+++ b/superset-frontend/src/explore/components/DataTablesPane/components/DataTableControls.tsx
@@ -16,11 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { styled, css } from '@apache-superset/core/theme';
+import { styled, css, useTheme } from '@apache-superset/core/theme';
+import { t } from '@apache-superset/core/translation';
 import { GenericDataType } from '@apache-superset/core/common';
 import { useMemo } from 'react';
 import { zip } from 'lodash';
 import { Select } from 'antd';
+import { Tooltip } from '@superset-ui/core/components';
+import { Icons } from '@superset-ui/core/components/Icons';
 import {
   CopyToClipboardButton,
   FilterInput,
@@ -28,6 +31,7 @@ import {
 import { applyFormattingToTabularData } from 'src/utils/common';
 import { getTimeColumns } from 'src/explore/components/DataTableControl/utils';
 import RowCountLabel from 'src/components/RowCountLabel';
+import DownloadDropdown from 'src/components/Chart/DrillDetail/DownloadDropdown';
 import { TableControlsProps } from '../types';
 
 export const ROW_LIMIT_OPTIONS = [
@@ -64,7 +68,11 @@ export const TableControls = ({
   rowLimit,
   rowLimitOptions,
   onRowLimitChange,
+  onDownloadCSV,
+  onDownloadXLSX,
+  onReload,
 }: TableControlsProps) => {
+  const theme = useTheme();
   const originalTimeColumns = getTimeColumns(datasourceId);
   const formattedTimeColumns = zip<string, GenericDataType>(
     columnNames,
@@ -106,9 +114,34 @@ export const TableControls = ({
         {(!onRowLimitChange || rowcount < (rowLimit ?? Infinity)) && (
           <RowCountLabel rowcount={rowcount} loading={isLoading} />
         )}
+        {canDownload && onDownloadCSV && onDownloadXLSX && (
+          <DownloadDropdown
+            onDownloadCSV={onDownloadCSV}
+            onDownloadXLSX={onDownloadXLSX}
+          />
+        )}
         {canDownload && (
           <CopyToClipboardButton data={formattedData} columns={columnNames} />
         )}
+        {onReload && (
+          <Tooltip title={t('Reload')}>
+            <button
+              type="button"
+              aria-label={t('Reload')}
+              onClick={onReload}
+              css={css`
+                display: inline-flex;
+                align-items: center;
+                padding: 0;
+                border: none;
+                background: none;
+                cursor: pointer;
+              `}
+            >
+              <Icons.ReloadOutlined iconColor={theme.colorIcon} iconSize="l" />
+            </button>
+          </Tooltip>
+        )}
       </div>
     </TableControlsWrapper>
   );
diff --git a/superset-frontend/src/explore/components/DataTablesPane/components/SingleQueryResultPane.tsx b/superset-frontend/src/explore/components/DataTablesPane/components/SingleQueryResultPane.tsx
index 2b27f515a2c..8cd279f4164 100644
--- a/superset-frontend/src/explore/components/DataTablesPane/components/SingleQueryResultPane.tsx
+++ b/superset-frontend/src/explore/components/DataTablesPane/components/SingleQueryResultPane.tsx
@@ -57,6 +57,9 @@ export const SingleQueryResultPane = ({
   rowLimit,
   rowLimitOptions,
   onRowLimitChange,
+  onDownloadCSV,
+  onDownloadXLSX,
+  onReload,
 }: SingleQueryResultPaneProp) => {
   const [filterText, setFilterText] = useState('');
   const { gridHeight, measuredRef } = useGridHeight();
@@ -83,6 +86,9 @@ export const SingleQueryResultPane = ({
         rowLimit={rowLimit}
         rowLimitOptions={rowLimitOptions}
         onRowLimitChange={onRowLimitChange}
+        onDownloadCSV={onDownloadCSV}
+        onDownloadXLSX={onDownloadXLSX}
+        onReload={onReload}
       />
       <GridContainer>
         <GridSizer ref={measuredRef}>
diff --git a/superset-frontend/src/explore/components/DataTablesPane/types.ts b/superset-frontend/src/explore/components/DataTablesPane/types.ts
index b01523f4d62..6135bb6fe38 100644
--- a/superset-frontend/src/explore/components/DataTablesPane/types.ts
+++ b/superset-frontend/src/explore/components/DataTablesPane/types.ts
@@ -63,7 +63,13 @@ export interface SamplesPaneProps {
   canDownload: boolean;
 }
 
-export interface TableControlsProps {
+export interface DrillControlsProps {
+  onDownloadCSV?: () => void;
+  onDownloadXLSX?: () => void;
+  onReload?: () => void;
+}
+
+export interface TableControlsProps extends DrillControlsProps {
   data: Record<string, any>[];
   // {datasource.id}__{datasource.type}, eg: 1__table
   datasourceId?: string;
@@ -85,7 +91,8 @@ export interface QueryResultInterface {
   data: Record<string, any>[][];
 }
 
-export interface SingleQueryResultPaneProp extends QueryResultInterface {
+export interface SingleQueryResultPaneProp
+  extends QueryResultInterface, DrillControlsProps {
   // {datasource.id}__{datasource.type}, eg: 1__table
   datasourceId?: string;
   isVisible: boolean;
diff --git a/superset/views/base.py b/superset/views/base.py
index 6e3f44c9aa7..bc39d037c07 100644
--- a/superset/views/base.py
+++ b/superset/views/base.py
@@ -101,6 +101,7 @@ FRONTEND_CONF_KEYS = (
     "COLUMNAR_EXTENSIONS",
     "ALLOWED_EXTENSIONS",
     "SAMPLES_ROW_LIMIT",
+    "ROW_LIMIT",
     "DEFAULT_TIME_FILTER",
     "HTML_SANITIZATION",
     "HTML_SANITIZATION_SCHEMA_EXTENSIONS",


(superset) 04/07: fix(dashboard): restore top-level tab drop target for dashboards with content (#39423)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michael-s-molina pushed a commit to branch 6.2
in repository https://gitbox.apache.org/repos/asf/superset.git

commit a11250a49aeed6bda47982c14d4be2b71955e447
Author: Joe Li <jo...@preset.io>
AuthorDate: Wed May 13 15:31:29 2026 -0700

    fix(dashboard): restore top-level tab drop target for dashboards with content (#39423)
    
    Co-authored-by: Claude Opus 4.6 (1M context) <no...@anthropic.com>
    (cherry picked from commit d7fa9301cca945e21c75ca2b7a6414dce8692dc5)
---
 .../DashboardBuilder/DashboardBuilder.test.tsx     | 43 ++++++++++++++++++++++
 .../DashboardBuilder/DashboardBuilder.tsx          |  4 ++
 superset-frontend/src/types/emotion-jest.d.ts      | 20 ++++++++++
 3 files changed, 67 insertions(+)

diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx
index 6fb5c0e790b..27377305bc9 100644
--- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx
+++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx
@@ -24,6 +24,7 @@ import {
   screen,
 } from 'spec/helpers/testing-library';
 import { FeatureFlag } from '@superset-ui/core';
+import { supersetTheme } from '@apache-superset/core/theme';
 import {
   OPEN_FILTER_BAR_WIDTH,
   CLOSED_FILTER_BAR_WIDTH,
@@ -487,6 +488,48 @@ test('should render ParentSize wrapper with height 100% for tabs', async () => {
   expect(tabPanels.length).toBeGreaterThan(0);
 });
 
+test('should apply min-height to the top-level tab drop target so tabs can be dropped on dashboards with content', () => {
+  (useStoredSidebarWidth as jest.Mock).mockImplementation(() => [
+    100,
+    jest.fn(),
+  ]);
+  (fetchFaveStar as jest.Mock).mockReturnValue({ type: 'mock-action' });
+  (setActiveTab as jest.Mock).mockReturnValue({ type: 'mock-action' });
+
+  const { getByTestId } = render(<DashboardBuilder />, {
+    useRedux: true,
+    store: storeWithState({
+      ...mockState,
+      dashboardLayout: undoableDashboardLayout,
+      dashboardState: { ...mockState.dashboardState, editMode: true },
+    }),
+    useDnd: true,
+    useTheme: true,
+    useRouter: true,
+  });
+
+  const headerWrapper = getByTestId('dashboard-header-wrapper');
+
+  // The Droppable inside the header should have the empty-droptarget class
+  // when there are no top-level tabs and edit mode is active. Without this
+  // class (and its associated min-height CSS rule), the drop target has zero
+  // height and users cannot drag tabs onto dashboards that already have
+  // content.
+  const droptarget = headerWrapper.querySelector('.empty-droptarget');
+  expect(droptarget).toBeInTheDocument();
+
+  // Verify the StyledHeader CSS defines a non-zero min-height for
+  // .empty-droptarget, derived from theme.sizeUnit * 4 to stay in sync
+  // with the source rule in DashboardBuilder.tsx.
+  expect(headerWrapper).toHaveStyleRule(
+    'min-height',
+    `${supersetTheme.sizeUnit * 4}px`,
+    {
+      target: '.empty-droptarget',
+    },
+  );
+});
+
 test('should maintain layout when switching between tabs', async () => {
   (useStoredSidebarWidth as jest.Mock).mockImplementation(() => [
     100,
diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
index a507c65318d..685467bfdd7 100644
--- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
+++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx
@@ -99,6 +99,10 @@ const StyledHeader = styled.div<{ filterBarWidth: number }>`
     z-index: 99;
     max-width: calc(100vw - ${filterBarWidth}px);
 
+    .empty-droptarget {
+      min-height: ${theme.sizeUnit * 4}px;
+    }
+
     .empty-droptarget:before {
       position: absolute;
       content: '';
diff --git a/superset-frontend/src/types/emotion-jest.d.ts b/superset-frontend/src/types/emotion-jest.d.ts
new file mode 100644
index 00000000000..c6d15cfb2dd
--- /dev/null
+++ b/superset-frontend/src/types/emotion-jest.d.ts
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+
+/// <reference types="@emotion/jest" />


(superset) 06/07: feat(ci): install helm-docs directly instead of using whole brew setup (backport #41629) (#42113)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michael-s-molina pushed a commit to branch 6.2
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 36accb034c067e526e5d82e362093fc6b5ca2223
Author: Luiz Otavio <45...@users.noreply.github.com>
AuthorDate: Thu Jul 16 15:18:04 2026 -0300

    feat(ci): install helm-docs directly instead of using whole brew setup (backport #41629) (#42113)
    
    Co-authored-by: Claude Opus 4.8 <no...@anthropic.com>
---
 .github/workflows/pre-commit.yml | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
index 86d9cba9384..23a28a72e56 100644
--- a/.github/workflows/pre-commit.yml
+++ b/.github/workflows/pre-commit.yml
@@ -28,19 +28,18 @@ jobs:
         with:
           persist-credentials: false
           submodules: recursive
+
       - name: Setup Python
         uses: ./.github/actions/setup-backend/
         with:
           python-version: ${{ matrix.python-version }}
-      - name: Enable brew and helm-docs
-        # Add brew to the path - see https://github.com/actions/runner-images/issues/6283
-        run: |
-          echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
-          eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
-          echo "HOMEBREW_PREFIX=$HOMEBREW_PREFIX" >>"${GITHUB_ENV}"
-          echo "HOMEBREW_CELLAR=$HOMEBREW_CELLAR" >>"${GITHUB_ENV}"
-          echo "HOMEBREW_REPOSITORY=$HOMEBREW_REPOSITORY" >>"${GITHUB_ENV}"
-          brew install norwoodj/tap/helm-docs
+
+      - name: Setup Go
+        uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
+
+      - name: Install helm-docs
+        run: go install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.14.2
+
       - name: Setup Node.js
         uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
         with:


(superset) 01/07: fix(event-log): add event logging for embedded Superset (#41938)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michael-s-molina pushed a commit to branch 6.2
in repository https://gitbox.apache.org/repos/asf/superset.git

commit e54c93df05beff92a009ebb1468d1c4501d147ed
Author: Luiz Otavio <45...@users.noreply.github.com>
AuthorDate: Mon Jul 13 15:23:05 2026 -0300

    fix(event-log): add event logging for embedded Superset (#41938)
    
    Co-authored-by: Claude Opus 4.8 <no...@anthropic.com>
---
 superset-frontend/src/middleware/logger.test.ts    | 32 ++++++++++++++++++++++
 .../src/middleware/loggerMiddleware.ts             | 23 +++++++++++++---
 2 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/middleware/logger.test.ts b/superset-frontend/src/middleware/logger.test.ts
index 5b989e21713..9b23587530b 100644
--- a/superset-frontend/src/middleware/logger.test.ts
+++ b/superset-frontend/src/middleware/logger.test.ts
@@ -142,6 +142,38 @@ describe('logger middleware', () => {
     }
   });
 
+  const getSourceForPath = (href: string): string | undefined => {
+    const originalHref = window.location.href;
+    Object.defineProperty(window, 'location', {
+      value: { href },
+      writable: true,
+    });
+    try {
+      (logger as Function)(mockStore)(next)(action);
+      jest.advanceTimersByTime(2000);
+      const { events } = postStub.mock.calls[0][0].postPayload;
+      return events[0].source;
+    } finally {
+      Object.defineProperty(window, 'location', {
+        value: { href: originalHref },
+        writable: true,
+      });
+    }
+  };
+
+  test.each([
+    ['/dashboard/123/embedded/', 'embedded_dashboard'],
+    ['/embedded/abc-def-uuid/', 'embedded_dashboard'],
+    // React Router also matches these routes without a trailing slash
+    ['/dashboard/123/embedded', 'embedded_dashboard'],
+    ['/embedded/abc-def-uuid', 'embedded_dashboard'],
+    ['/dashboard/123/', 'dashboard'],
+    // slug is literally "embedded" - must not be treated as embedded
+    ['/dashboard/embedded/', 'dashboard'],
+  ])('classifies %s as source "%s"', (path, expectedSource) => {
+    expect(getSourceForPath(`http://localhost${path}`)).toBe(expectedSource);
+  });
+
   test('should debounce a few log requests to one', () => {
     (logger as Function)(mockStore)(next)(action);
     (logger as Function)(mockStore)(next)(action);
diff --git a/superset-frontend/src/middleware/loggerMiddleware.ts b/superset-frontend/src/middleware/loggerMiddleware.ts
index 55c476f9bc2..af67db08d2b 100644
--- a/superset-frontend/src/middleware/loggerMiddleware.ts
+++ b/superset-frontend/src/middleware/loggerMiddleware.ts
@@ -33,7 +33,12 @@ import { ensureAppRoot } from '../utils/pathUtils';
 import type { DashboardInfo, DashboardLayoutState } from '../dashboard/types';
 import type { QueryEditor } from '../SqlLab/types';
 
-type LogEventSource = 'dashboard' | 'explore' | 'sqlLab' | 'slice';
+type LogEventSource =
+  | 'dashboard'
+  | 'embedded_dashboard'
+  | 'explore'
+  | 'sqlLab'
+  | 'slice';
 
 interface LogEventData {
   source?: LogEventSource;
@@ -99,7 +104,7 @@ const sendBeacon = (events: LogEventData[]): void => {
   const [firstEvent] = events;
   const { source, source_id } = firstEvent;
   // backend logs treat these request params as first-class citizens
-  if (source === 'dashboard') {
+  if (source === 'dashboard' || source === 'embedded_dashboard') {
     endpoint += `&dashboard_id=${source_id}`;
   } else if (source === 'slice') {
     endpoint += `&slice_id=${source_id}`;
@@ -131,6 +136,12 @@ const logMessageQueue = new DebouncedMessageQueue<LogEventData>({
   delayThreshold: 1000,
 });
 
+// Embedded dashboards are served from `/dashboard/:idOrSlug/embedded/` and
+// `/embedded/:uuid/`. Matching these specific shapes avoids false positives
+// for regular dashboards (e.g. a dashboard whose slug is "embedded").
+const EMBEDDED_ROUTE_REGEX =
+  /\/dashboard\/[^/]+\/embedded\/?|\/embedded\/[^/]+\/?/;
+
 let lastEventId: string | number = 0;
 
 const loggerMiddleware: Middleware<
@@ -162,9 +173,13 @@ const loggerMiddleware: Middleware<
     }
     const path = navPath || window?.location?.href;
 
-    if (dashboardInfo?.id && path?.includes('/dashboard/')) {
+    // Match the actual embedded route patterns (`/dashboard/:idOrSlug/embedded/`
+    // and `/embedded/:uuid/`) rather than any URL containing "/embedded/", which
+    // would misclassify a regular dashboard whose slug is "embedded".
+    const isEmbedded = EMBEDDED_ROUTE_REGEX.test(path ?? '');
+    if (dashboardInfo?.id && (path?.includes('/dashboard/') || isEmbedded)) {
       logMetadata = {
-        source: 'dashboard',
+        source: isEmbedded ? 'embedded_dashboard' : 'dashboard',
         source_id: dashboardInfo.id,
         dashboard_id: dashboardInfo.id,
         ...logMetadata,


(superset) 03/07: fix(event-log): backport stricter embedded-route regex to 6.1 (#42048)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michael-s-molina pushed a commit to branch 6.2
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 1e1241e9e3d82b584d8c2bd4ac05cbc917f0d57c
Author: Luiz Otavio <45...@users.noreply.github.com>
AuthorDate: Tue Jul 14 15:05:06 2026 -0300

    fix(event-log): backport stricter embedded-route regex to 6.1 (#42048)
    
    Co-authored-by: Claude Opus 4.8 <no...@anthropic.com>
---
 superset-frontend/src/middleware/logger.test.ts      | 2 ++
 superset-frontend/src/middleware/loggerMiddleware.ts | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/src/middleware/logger.test.ts b/superset-frontend/src/middleware/logger.test.ts
index 9b23587530b..83c3a58f169 100644
--- a/superset-frontend/src/middleware/logger.test.ts
+++ b/superset-frontend/src/middleware/logger.test.ts
@@ -170,6 +170,8 @@ describe('logger middleware', () => {
     ['/dashboard/123/', 'dashboard'],
     // slug is literally "embedded" - must not be treated as embedded
     ['/dashboard/embedded/', 'dashboard'],
+    // "embedded" must be a full path segment, not a prefix
+    ['/dashboard/123/embeddedXYZ/', 'dashboard'],
   ])('classifies %s as source "%s"', (path, expectedSource) => {
     expect(getSourceForPath(`http://localhost${path}`)).toBe(expectedSource);
   });
diff --git a/superset-frontend/src/middleware/loggerMiddleware.ts b/superset-frontend/src/middleware/loggerMiddleware.ts
index af67db08d2b..f3c9d55cd6b 100644
--- a/superset-frontend/src/middleware/loggerMiddleware.ts
+++ b/superset-frontend/src/middleware/loggerMiddleware.ts
@@ -140,7 +140,7 @@ const logMessageQueue = new DebouncedMessageQueue<LogEventData>({
 // `/embedded/:uuid/`. Matching these specific shapes avoids false positives
 // for regular dashboards (e.g. a dashboard whose slug is "embedded").
 const EMBEDDED_ROUTE_REGEX =
-  /\/dashboard\/[^/]+\/embedded\/?|\/embedded\/[^/]+\/?/;
+  /\/dashboard\/[^/]+\/embedded(?:[/?#]|$)|\/embedded\/[^/]+\/?/;
 
 let lastEventId: string | number = 0;