mirror of
https://github.com/flarum/core.git
synced 2025-08-08 09:26:34 +02:00
update: common/components/AlertManager
This commit is contained in:
committed by
Franz Liedke
parent
41d6e91318
commit
479f655bb3
@@ -6,8 +6,10 @@ import Alert from './Alert';
|
|||||||
* be shown and dismissed.
|
* be shown and dismissed.
|
||||||
*/
|
*/
|
||||||
export default class AlertManager extends Component {
|
export default class AlertManager extends Component {
|
||||||
init() {
|
oninit(vnode) {
|
||||||
this.state = this.props.state;
|
super.oninit(vnode);
|
||||||
|
|
||||||
|
this.state = this.attrs.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
@@ -15,17 +17,12 @@ export default class AlertManager extends Component {
|
|||||||
<div className="AlertManager">
|
<div className="AlertManager">
|
||||||
{Object.entries(this.state.getActiveAlerts()).map(([key, alert]) => (
|
{Object.entries(this.state.getActiveAlerts()).map(([key, alert]) => (
|
||||||
<div className="AlertManager-alert">
|
<div className="AlertManager-alert">
|
||||||
{(alert.componentClass || Alert).component({ ...alert.attrs, ondismiss: this.state.dismiss.bind(this.state, key) })}
|
<alert.componentClass {...alert.attrs} ondismiss={this.state.dismiss.bind(this.state, key)}>
|
||||||
|
{alert.children}
|
||||||
|
</alert.componentClass>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
config(isInitialized, context) {
|
|
||||||
// Since this component is 'above' the content of the page (that is, it is a
|
|
||||||
// part of the global UI that persists between routes), we will flag the DOM
|
|
||||||
// to be retained across route changes.
|
|
||||||
context.retain = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user