1
0
mirror of https://github.com/flarum/core.git synced 2025-07-10 03:16:22 +02:00

Extract ModalManagerState from ModalManager ()

This commit is contained in:
Alexander Skvortsov
2020-06-30 19:59:16 -04:00
committed by GitHub
parent 4f181c84fc
commit 44376cef61
17 changed files with 130 additions and 111 deletions

@ -9,6 +9,11 @@ import Button from './Button';
* @abstract
*/
export default class Modal extends Component {
/**
* Determine whether or not the modal should be dismissible via an 'x' button.
*/
static isDismissible = true;
init() {
/**
* Attributes for an alert component to show below the header.
@ -18,6 +23,16 @@ export default class Modal extends Component {
this.alertAttrs = null;
}
config(isInitialized, context) {
if (isInitialized) return;
this.props.onshow(() => this.onready());
context.onunload = () => {
this.props.onhide();
};
}
view() {
if (this.alertAttrs) {
this.alertAttrs.dismissible = false;
@ -26,7 +41,7 @@ export default class Modal extends Component {
return (
<div className={'Modal modal-dialog ' + this.className()}>
<div className="Modal-content">
{this.isDismissible() ? (
{this.constructor.isDismissible ? (
<div className="Modal-close App-backControl">
{Button.component({
icon: 'fas fa-times',
@ -52,15 +67,6 @@ export default class Modal extends Component {
);
}
/**
* Determine whether or not the modal should be dismissible via an 'x' button.
*
* @return {Boolean}
*/
isDismissible() {
return true;
}
/**
* Get the class name to apply to the modal.
*
@ -105,7 +111,7 @@ export default class Modal extends Component {
* Hide the modal.
*/
hide() {
app.modal.close();
this.props.onhide();
}
/**