2021-08-19 09:13:22 +00:00
|
|
|
import type Mithril from 'mithril';
|
2021-05-12 23:29:46 +00:00
|
|
|
import Alert, { AlertAttrs } from '../components/Alert';
|
|
|
|
/**
|
|
|
|
* Returned by `AlertManagerState.show`. Used to dismiss alerts.
|
|
|
|
*/
|
|
|
|
export declare type AlertIdentifier = number;
|
|
|
|
export interface AlertState {
|
|
|
|
componentClass: typeof Alert;
|
|
|
|
attrs: AlertAttrs;
|
|
|
|
children: Mithril.Children;
|
|
|
|
}
|
|
|
|
export default class AlertManagerState {
|
|
|
|
protected activeAlerts: {
|
|
|
|
[id: number]: AlertState;
|
|
|
|
};
|
|
|
|
protected alertId: number;
|
|
|
|
getActiveAlerts(): {
|
|
|
|
[id: number]: AlertState;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Show an Alert in the alerts area.
|
|
|
|
*
|
2021-12-27 19:02:33 +00:00
|
|
|
* @return The alert's ID, which can be used to dismiss the alert.
|
2021-05-12 23:29:46 +00:00
|
|
|
*/
|
|
|
|
show(children: Mithril.Children): AlertIdentifier;
|
|
|
|
show(attrs: AlertAttrs, children: Mithril.Children): AlertIdentifier;
|
2021-12-14 03:11:57 +00:00
|
|
|
show(componentClass: typeof Alert, attrs: AlertAttrs, children: Mithril.Children): AlertIdentifier;
|
2021-05-12 23:29:46 +00:00
|
|
|
/**
|
|
|
|
* Dismiss an alert.
|
|
|
|
*/
|
2021-11-23 22:58:48 +00:00
|
|
|
dismiss(key: AlertIdentifier | null): void;
|
2021-05-12 23:29:46 +00:00
|
|
|
/**
|
|
|
|
* Clear all alerts.
|
|
|
|
*/
|
|
|
|
clear(): void;
|
|
|
|
}
|