mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-02 20:23:32 +08:00
feature (editor): save before quit - #81
This commit is contained in:
@ -2,53 +2,38 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import { Input, Button, Modal, NgIf } from './';
|
||||
import { alert } from '../helpers/'
|
||||
import "./alert.scss";
|
||||
import { alert } from '../helpers/';
|
||||
import { Popup } from './popup';
|
||||
|
||||
export class AlertModal extends React.Component {
|
||||
export class ModalAlert extends Popup {
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state = {
|
||||
appear: false,
|
||||
value: null,
|
||||
fns: {}
|
||||
};
|
||||
this.onSubmit = this.onSubmit.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
alert.subscribe((Component, okCallback) => {
|
||||
this.setState({
|
||||
appear: true,
|
||||
value: Component,
|
||||
fns: {ok: okCallback || function(){}}
|
||||
value: Component
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit(e){
|
||||
e && e.preventDefault && e.preventDefault();
|
||||
this.state.fns.ok();
|
||||
this.setState({appear: false});
|
||||
}
|
||||
|
||||
onEscapeKeyPress(e){
|
||||
if(e.keyCode === 27 && this.state.fns){ this.onSubmit(); }
|
||||
modalContentBody(){
|
||||
return (
|
||||
<div className="modal-message">
|
||||
{this.state.value}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
modalContentFooter(){
|
||||
return (
|
||||
<Modal isActive={this.state.appear} onQuit={this.onSubmit.bind(this)}>
|
||||
<div className="component_alert">
|
||||
<div className="modal-message">
|
||||
{this.state.value}
|
||||
</div>
|
||||
<div className="buttons">
|
||||
<Button type="submit" theme="secondary" onClick={this.onSubmit}>OK</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
<Button type="submit" theme="secondary" onClick={this.onSubmit.bind(this)}>OK</Button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user