Skip to content

feat: add onDataView callback to visualization components #6240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libs/sdk-ui-charts/src/charts/repeater/CoreRepeater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const CoreRepeaterImpl: React.FC<ICoreRepeaterChartProps> = (props) => {
pushData,
onError,
onColumnResized,
onDataView,
config = {},
drillableItems = [],
onDrill = noop,
Expand Down Expand Up @@ -76,6 +77,7 @@ export const CoreRepeaterImpl: React.FC<ICoreRepeaterChartProps> = (props) => {
onSuccess: (dataView) => {
onLoadingChanged?.({ isLoading: false });
pushData?.({ dataView: dataView.dataView });
onDataView?.(dataView);
},
onError: (error) => {
onLoadingChanged?.({ isLoading: false });
Expand Down
8 changes: 5 additions & 3 deletions libs/sdk-ui-ext/src/insightView/InsightRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,10 @@ class InsightRendererCore extends React.PureComponent<IInsightRendererProps & Wr
this.props.onError?.(error);
this.props.onLoadingChanged?.({ isLoading: false });
},
onLoadingChanged: ({ isLoading }) => {
this.props.onLoadingChanged?.({ isLoading });
},
onLoadingChanged: this.props.onLoadingChanged,
pushData: this.props.pushData,
onDrill: this.props.onDrill,
onDataView: this.props.onDataView,
onExportReady: this.onExportReadyDecorator,
afterRender: this.props.afterRender,
},
Expand Down Expand Up @@ -370,6 +369,7 @@ export const InsightRenderer: React.FC<IInsightRendererProps> = (props) => {
onError: onErrorCallBack,
onExportReady: onExportReadyCallback,
onLoadingChanged: onLoadingChangedCallback,
onDataView: onDataViewCallback,
...resProps
} = props;

Expand All @@ -378,6 +378,7 @@ export const InsightRenderer: React.FC<IInsightRendererProps> = (props) => {
const onError = useUpdatableCallback(onErrorCallBack);
const onExportReady = useUpdatableCallback(onExportReadyCallback);
const onLoadingChanged = useUpdatableCallback(onLoadingChangedCallback);
const onDataView = useUpdatableCallback(onDataViewCallback);

return (
<IntlWrapper locale={props.locale}>
Expand All @@ -387,6 +388,7 @@ export const InsightRenderer: React.FC<IInsightRendererProps> = (props) => {
onError={onError}
onExportReady={onExportReady}
onLoadingChanged={onLoadingChanged}
onDataView={onDataView}
{...resProps}
/>
</IntlWrapper>
Expand Down
2 changes: 2 additions & 0 deletions libs/sdk-ui-ext/src/insightView/InsightView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const InsightViewCore: React.FC<IInsightViewProps & WrappedComponentProps> = (pr
onLoadingChanged,
onExportReady,
onError,
onDataView,
onInsightLoaded,
pushData,

Expand Down Expand Up @@ -248,6 +249,7 @@ const InsightViewCore: React.FC<IInsightViewProps & WrappedComponentProps> = (pr
onError={handleError}
onExportReady={onExportReady}
onLoadingChanged={handleLoadingChanged}
onDataView={onDataView}
pushData={pushData}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export class BaseVisualization extends React.PureComponent<IBaseVisualizationPro
console.error(`Error: unsupported visualization type - ${visUri}`);
}

let visualizationId;
let visualizationId: string;
if (isInsight(insight)) {
visualizationId = insight.insight.identifier;
} else {
Expand Down Expand Up @@ -304,6 +304,7 @@ export class BaseVisualization extends React.PureComponent<IBaseVisualizationPro
onExportReady: props.onExportReady,
pushData: props.pushData,
onDrill: props.onDrill,
onDataView: props.onDataView,
},
featureFlags,
visualizationProperties: insightProperties(props.insight),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
UnexpectedSdkError,
isForecastNotReceived,
isClusteringNotReceived,
DataViewFacade,
} from "@gooddata/sdk-ui";
import { IntlShape } from "react-intl";
import { createInternalIntl } from "../../utils/internalIntlProvider.js";
Expand Down Expand Up @@ -292,6 +293,10 @@ export abstract class AbstractPluggableVisualization implements IVisualization {
return this.callbacks.onDrill ? this.callbacks.onDrill(event) : true;
};

protected onDataView = (dataView: DataViewFacade): void => {
this.callbacks.onDataView?.(dataView);
};

//
// Templated implementation of addNewDerivedBucketItems contract
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export class PluggableBaseChart extends AbstractPluggableVisualization {
onExportReady={this.onExportReady}
onLoadingChanged={this.onLoadingChanged}
pushData={this.handlePushData}
onDataView={this.onDataView}
height={resultingHeight}
type={this.type}
locale={locale}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export class PluggableGeoPushpinChart extends PluggableBaseChart {
onError: this.onError,
onExportReady: this.onExportReady,
onLoadingChanged: this.onLoadingChanged,
onDataView: this.onDataView,
LoadingComponent: null,
ErrorComponent: null,
theme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export class PluggableHeadline extends AbstractPluggableVisualization {
config={headlineConfig}
afterRender={this.afterRender}
onLoadingChanged={this.onLoadingChanged}
onDataView={this.onDataView}
pushData={this.pushData}
onError={this.onError}
LoadingComponent={null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ export class PluggablePivotTable extends AbstractPluggableVisualization {
pushData: this.handlePushData,
onError: this.onError,
onExportReady: this.onExportReady,
onDataView: this.onDataView,
onColumnResized,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ export class PluggableRepeater extends AbstractPluggableVisualization {
onLoadingChanged={this.onLoadingChanged}
pushData={this.handlePushData}
onError={this.onError}
onDataView={this.onDataView}
onColumnResized={this.onColumnResized}
intl={this.intl}
/>,
Expand Down
6 changes: 5 additions & 1 deletion libs/sdk-ui-pivot/src/CorePivotTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export class CorePivotTableAgImpl extends React.Component<ICorePivotTableProps,
| "onExportReady"
| "onLoadingChanged"
| "onError"
| "onDataView"
| "onDrill"
| "ErrorComponent"
| "LoadingComponent"
Expand All @@ -202,6 +203,7 @@ export class CorePivotTableAgImpl extends React.Component<ICorePivotTableProps,
onExportReady: noop,
onLoadingChanged: noop,
onError: noop,
onDataView: noop,
onDrill: () => true,
ErrorComponent,
LoadingComponent,
Expand Down Expand Up @@ -739,7 +741,9 @@ export class CorePivotTableAgImpl extends React.Component<ICorePivotTableProps,
this.internal.isAltKeyPressed = event.altKey;
};

private onPageLoaded = (_dv: DataViewFacade, newResult: boolean): void => {
private onPageLoaded = (dv: DataViewFacade, newResult: boolean): void => {
this.props.onDataView?.(dv);

if (!this.internal.table) {
return;
}
Expand Down
Loading
Loading