alert-config.md 3.6 KB


title: "AlertConfig" isDefaultIndex: false

generated: true

import MemberInfo from '@site/src/components/MemberInfo'; import GenerationInfo from '@site/src/components/GenerationInfo'; import MemberDescription from '@site/src/components/MemberDescription';

AlertConfig

A configuration object for an Admin UI alert.

interface AlertConfig<T = any> {
    id: string;
    check: (context: AlertContext) => T | Promise<T> | Observable<T>;
    recheck?: (context: AlertContext) => Observable<any>;
    isAlert: (data: T, context: AlertContext) => boolean;
    action: (data: T, context: AlertContext) => void;
    label: (
        data: T,
        context: AlertContext,
    ) => { text: string; translationVars?: { [key: string]: string | number } };
    requiredPermissions?: Permission[];
}
### id A unique identifier for the alert. ### check AlertContext) => T | Promise<T> | Observable<T>`} /> A function which is gets the data used to determine whether the alert should be shown. Typically, this function will query the server or some other remote data source. This function will be called once when the Admin UI app bootstraps, and can be also set to run at regular intervals by setting the `recheckIntervalMs` property. ### recheck AlertContext) => Observable<any>`} default="undefined" /> A function which returns an Observable which is used to determine when to re-run the `check` function. Whenever the observable emits, the `check` function will be called again. A basic time-interval-based recheck can be achieved by using the `interval` function from RxJS. *Example* ```ts import { interval } from 'rxjs'; // ... recheck: () => interval(60_000) ``` If this is not set, the `check` function will only be called once when the Admin UI app bootstraps. ### isAlert AlertContext) => boolean`} /> A function which determines whether the alert should be shown based on the data returned by the `check` function. ### action AlertContext) => void`} /> A function which is called when the alert is clicked in the Admin UI. ### label AlertContext, ) => { text: string; translationVars?: { [key: string]: string | number } }`} /> A function which returns the text used in the UI to describe the alert. ### requiredPermissions Permission[]`} /> A list of permissions which the current Administrator must have in order. If the current Administrator does not have these permissions, none of the other alert functions will be called.