You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ju...@apache.org on 2025/08/13 21:40:48 UTC
(superset) branch master updated: feat(extension): Add extension for chart header (#34678)
This is an automated email from the ASF dual-hosted git repository.
justinpark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new bce476c4a2 feat(extension): Add extension for chart header (#34678)
bce476c4a2 is described below
commit bce476c4a23c29fcda23c8d3763e2585ec3e8ebd
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Wed Aug 13 14:40:42 2025 -0700
feat(extension): Add extension for chart header (#34678)
---
.../superset-ui-core/src/ui-overrides/types.ts | 23 +++++++++++--
.../explore/components/ExploreChartPanel/index.tsx | 38 +++++++++++++++++-----
2 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-core/src/ui-overrides/types.ts b/superset-frontend/packages/superset-ui-core/src/ui-overrides/types.ts
index cdc9ed399a..cca2aed880 100644
--- a/superset-frontend/packages/superset-ui-core/src/ui-overrides/types.ts
+++ b/superset-frontend/packages/superset-ui-core/src/ui-overrides/types.ts
@@ -23,8 +23,13 @@ import {
ComponentType,
} from 'react';
import type { Editor } from 'brace';
-import { BaseFormData } from '../query';
-import { JsonResponse } from '../connection';
+import type { QueryData } from '../chart/types/QueryResponse';
+import type {
+ BaseFormData,
+ LatestQueryFormData,
+ QueryFormData,
+} from '../query';
+import type { JsonResponse } from '../connection';
/**
* A function which returns text (or marked-up text)
@@ -219,6 +224,19 @@ export interface DateFilterControlProps {
isOverflowingFilterBar?: boolean;
}
+export interface ExploreChartHeaderProps {
+ chartId: number;
+ queriesResponse: QueryData[] | null;
+ sliceFormData: QueryFormData | null;
+ queryFormData: QueryFormData;
+ lastRendered: number;
+ latestQueryFormData: LatestQueryFormData;
+ chartUpdateEndTime: number | null;
+ chartUpdateStartTime: number;
+ queryController: AbortController | null;
+ triggerQuery: boolean;
+}
+
export type Extensions = Partial<{
'alertsreports.header.icon': ComponentType;
'load.drillby.options': LoadDrillByOptions;
@@ -251,4 +269,5 @@ export type Extensions = Partial<{
ComponentType<SQLTablePreviewExtensionProps>,
][];
'filter.dateFilterControl': ComponentType<DateFilterControlProps>;
+ 'explore.chart.header': ComponentType<ExploreChartHeaderProps>;
}>;
diff --git a/superset-frontend/src/explore/components/ExploreChartPanel/index.tsx b/superset-frontend/src/explore/components/ExploreChartPanel/index.tsx
index 09de98577f..a9fa4a11a4 100644
--- a/superset-frontend/src/explore/components/ExploreChartPanel/index.tsx
+++ b/superset-frontend/src/explore/components/ExploreChartPanel/index.tsx
@@ -31,6 +31,7 @@ import {
useTheme,
QueryFormData,
JsonObject,
+ getExtensionsRegistry,
} from '@superset-ui/core';
import ChartContainer from 'src/components/Chart/ChartContainer';
import {
@@ -50,6 +51,9 @@ import { ChartPills } from '../ChartPills';
import { ExploreAlert } from '../ExploreAlert';
import useResizeDetectorByObserver from './useResizeDetectorByObserver';
+const extensionsRegistry = getExtensionsRegistry();
+const DefaultHeader: React.FC = ({ children }) => <>{children}</>;
+
export interface ExploreChartPanelProps {
actions: {
setForceQuery: (force: boolean) => void;
@@ -149,6 +153,9 @@ const ExploreChartPanel = ({
width: chartPanelWidth,
height: chartPanelHeight,
} = useResizeDetectorByObserver();
+
+ const ChartHeaderExtension =
+ extensionsRegistry.get('explore.chart.header') ?? DefaultHeader;
const [splitSizes, setSplitSizes] = useState<PanelSizes>(
isFeatureEnabled(FeatureFlag.DatapanelClosedByDefault)
? INITIAL_SIZES
@@ -367,16 +374,29 @@ const ExploreChartPanel = ({
`}
/>
)}
- <ChartPills
+ <ChartHeaderExtension
+ chartId={chart.id}
+ queriesResponse={chart.queriesResponse}
+ sliceFormData={slice?.form_data ?? null}
+ queryFormData={formData}
+ lastRendered={chart.lastRendered}
+ latestQueryFormData={chart.latestQueryFormData}
+ chartUpdateEndTime={chart.chartUpdateEndTime ?? 0}
chartUpdateStartTime={chart.chartUpdateStartTime}
- chartUpdateEndTime={chart.chartUpdateEndTime ?? undefined}
- refreshCachedQuery={refreshCachedQuery}
- rowLimit={formData?.row_limit ?? undefined}
- {...(chart.queriesResponse && {
- queriesResponse: chart.queriesResponse,
- })}
- {...(chart.chartStatus && { chartStatus: chart.chartStatus })}
- />
+ queryController={chart.queryController}
+ triggerQuery={chart.triggerQuery}
+ >
+ <ChartPills
+ chartUpdateStartTime={chart.chartUpdateStartTime}
+ chartUpdateEndTime={chart.chartUpdateEndTime ?? 0}
+ refreshCachedQuery={refreshCachedQuery}
+ rowLimit={formData?.row_limit ?? 0}
+ {...(chart.queriesResponse && {
+ queriesResponse: chart.queriesResponse,
+ })}
+ {...(chart.chartStatus && { chartStatus: chart.chartStatus })}
+ />
+ </ChartHeaderExtension>
{renderChart()}
</div>
),