Home Reference Source

application/components/content/content-media-editor.js

import React, { Component } from 'react';
import _ from 'lodash';
import Immutable from 'immutable';
import {connect} from 'react-redux';

import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';

import DarkroomEditor from './darkroom-editor';

class ContentMediaEditor extends Component {
    constructor(props) {
        super(props);
    }

    handleClose() {
        if (this.props.onRequestClose) {
            this.props.onRequestClose.call();
        }
    }

    handleSave(data = false) {
        if (this.props.onSave) {
            this.props.onSave(data)
                .then(() => this.handleClose.call(this));
        } else {
            this.handleClose.call(this);
        }
    }

    render() {
        if (!this.props.open) {
            return <span />;
        }

        return (
            <DarkroomEditor src={this.props.src} onClose={this.handleClose.bind(this)} onSave={this.handleSave.bind(this)} />
        );
    }
}


export default connect()(ContentMediaEditor);