CustomAutomationsContextDecoratorComponent
Beta API. Mostly stable, but details may change in a minor release, outside SemVer.
Decorates the data the automation dialogs’ shared context carries.
The dashboard mounts this component directly inside each connector-provided automations context — once in the alerting tree and once in the scheduled-email tree — so the value it re-provides is what everything in both trees reads: the default dialogs, wholesale replacements, exported blocks and hooks, and the dialogs’ state seeding. A decorator must therefore be tree-agnostic. Read the current value with useAutomationsContext(), decorate the members to adjust, and re-provide via AutomationsContextProvider:
export type CustomAutomationsContextDecoratorComponent = ComponentType<{
children?: ReactNode;
}>;
Example
function GranularityDecorator({ children }: { children?: ReactNode }) {
const ctx = useAutomationsContext();
const decorated = useMemo(
() => ({
...ctx,
dateFilterConfig: {
...ctx.dateFilterConfig,
availableGranularities: ctx.dateFilterConfig.availableGranularities.filter(
(g) => g !== "GDC.time.hour",
),
getGranularitiesForTab: (tabId: string) =>
ctx.dateFilterConfig
.getGranularitiesForTab(tabId)
.filter((g) => g !== "GDC.time.hour"),
},
}),
[ctx],
);
return <AutomationsContextProvider value={decorated}>{children}</AutomationsContextProvider>;
}
// <Dashboard AutomationsContextDecoratorComponent={GranularityDecorator} />
To constrain the date-filter granularities the dialogs offer, override dateFilterConfig.availableGranularities and dateFilterConfig.getGranularitiesForTab together, as above — the date filter falls back per tab. Components that build this context themselves (the standalone connected dialogs, the widget-panel alerts list) are not decorated. Define the decorator outside render, or both dialog trees remount on every parent render. Both instances mount with the dashboard, not only while a dialog is open — a decorator that fetches data runs on every dashboard.
The contract: change the data, not what it means — every member keeps its documented meaning. The dialog does not check the decorated value; when you override a member, everything that reads it is your responsibility. Spread the value you read ({ ...ctx, member }) so the other members pass through. Wrap functions instead of replacing them. Do not touch members marked as internal machinery.