CustomAlertingDialogContextDecoratorComponent
Home > @gooddata/sdk-ui-dashboard > CustomAlertingDialogContextDecoratorComponent
CustomAlertingDialogContextDecoratorComponent type
This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Decorates the data the alerting create/edit dialog reads.
The dashboard mounts this component between the connector-provided dialog context and the dialog's state model, so the value it re-provides is what both the default dialog and the state seeding read — a wholesale AlertingDialogComponent replacement sees it too. Read the current value with useAlertingDialogContext(), decorate the members to adjust, and re-provide via AlertingDialogContextProvider:
Signature:
export type CustomAlertingDialogContextDecoratorComponent = ComponentType<{
children?: ReactNode;
}>;
Example
function InsightDecorator({ children }: { children?: ReactNode }) {
const ctx = useAlertingDialogContext();
const insight = useMyDecoratedInsight(ctx.insight);
const decorated = useMemo(() => ({ ...ctx, insight }), [ctx, insight]);
return <AlertingDialogContextProvider value={decorated}>{children}</AlertingDialogContextProvider>;
}
// <Dashboard AlertingDialogContextDecoratorComponent={InsightDecorator} />
Pass isLoading through untouched: the dialog's state model defers seeding until it is false, and a decorator that overrides it corrupts the draft seed. Define the decorator outside render, or the dialog remounts (and reseeds) on every parent render.