/*
Copyright (C) 2017  Cloudbase Solutions SRL

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

import React, { PropTypes } from 'react';
import Reflux from 'reflux';
import MigrationStore from '../../stores/MigrationStore';

const title = "Coriolis: View Replica"

class Replica extends Reflux.Component {

  static propTypes = {
    replicaId: PropTypes.string
  }

  static contextTypes = {
    onSetTitle: PropTypes.func.isRequired,
  };

  constructor(props) {
    super(props)
    this.store = MigrationStore
  }

  componentWillMount() {
    super.componentWillMount.call(this)
  }

  componentDidMount() {
    this.context.onSetTitle(title);
  }

  render() {
    return (
      <div>
        {React.cloneElement(this.props.children, { replicas: this.state.replicas, replicaId: this.props.replicaId })}
      </div>
    )
  }

}

export default Replica;
