mirror of
https://github.com/flarum/core.git
synced 2025-07-10 03:16:22 +02:00
Extract ModalManagerState from ModalManager (#2162)
This commit is contained in:
committed by
GitHub
parent
4f181c84fc
commit
44376cef61
js/src
admin
common
forum
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user