<commit_before>'use strict';
import React, { PropTypes as T } from 'react';
import ReactTooltip from 'react-tooltip';
import c from 'classnames';

import { t } from '../../utils/i18n';
import boundsToMapLocation from '../../utils/zoom-to-bbox';
import config from '../../config';
import { showGlobalLoading, hideGlobalLoading } from '../global-loading';

import { Modal, ModalHeader, ModalBody, ModalFooter } from '../modal';

const ScenarioIDModal = React.createClass({

  propTypes: {
    revealed: T.bool,
    onCloseClick: T.func,

    scenarioData: T.object,
    projectBbox: T.array
  },

  notifier: null,

  setupNotifier: function () {
    this.notifier = notifier('rra-frontend', this.refs.editor.contentWindow);

    this.notifier.on('loaded', () => {
      this.notifier.send('settings', {
        projectId: this.props.scenarioData.project_id,
        scenarioId: this.props.scenarioData.id
      });
    });

    this.notifier.on('ready', () => {
      hideGlobalLoading();
      this.setState({editorLoaded: true});
    });

    this.notifier.on('save:status', data => {
      this.setState({saveEnabled: data.enabled});
    });
  },

  getInitialState: function () {
    return {
      editorLoaded: false,
      saveEnabled: false
    };
  },

  componentDidUpdate: function (prevProps) {
    if (!prevProps.revealed && this.props.revealed) {
      showGlobalLoading();
      this.setupNotifier();
    }
  },

  componentWillReceiveProps: function (nextProps) {
    // When the modal gets closed set the editor and not loaded.
    if (this.props.revealed && !nextProps.revealed) {
      this.setState({editorLoaded: false});
    }
  },

  componentWillUnmount: function () {
  },

  onClose: function () {
    this.props.onCloseClick();
  },

  onSaveClick: function () {
    this.notifier.send('save:click');
  },

  render: function () {
    const mapLocation = boundsToMapLocation(this.props.projectBbox);
    return (
      <Modal
        id='modal-scenario-metadata'
        className='modal--large'
        onCloseClick={this.onClose}
        revealed={this.props.revealed} >

        <ModalHeader>
          <div className='modal__headline'>
            <h1 className='modal__title'>{t('Edit road network')}</h1>
            <div className='modal__description'>
            </div><commit_msg>Use width and height values provided by iD to calc the initial position<commit_after>'use strict';
import React, { PropTypes as T } from 'react';
import ReactTooltip from 'react-tooltip';
import c from 'classnames';

import { t } from '../../utils/i18n';
import { boundsToMapLocation } from '../../utils/geo';
import config from '../../config';
import { showGlobalLoading, hideGlobalLoading } from '../global-loading';

import { Modal, ModalHeader, ModalBody, ModalFooter } from '../modal';

const ScenarioIDModal = React.createClass({

  propTypes: {
    revealed: T.bool,
    onCloseClick: T.func,

    scenarioData: T.object,
    projectBbox: T.array
  },

  notifier: null,

  setupNotifier: function () {
    this.notifier = notifier('rra-frontend', this.refs.editor.contentWindow);

    this.notifier.on('loaded', () => {
      this.notifier.send('settings', {
        projectId: this.props.scenarioData.project_id,
        scenarioId: this.props.scenarioData.id
      });
    });

    this.notifier.on('ready', (data) => {
      hideGlobalLoading();
      this.setState({
        editorLoaded: true,
        editorWidth: data.mapWidth,
        editorHeight: data.mapHeight
      });
    });

    this.notifier.on('save:status', data => {
      this.setState({saveEnabled: data.enabled});
    });
  },

  getInitialState: function () {
    return {
      editorLoaded: false,
      saveEnabled: false,
      editorWidth: 0,
      editorHeight: 0
    };
  },

  componentDidUpdate: function (prevProps) {
    if (!prevProps.revealed && this.props.revealed) {
      showGlobalLoading();
      this.setupNotifier();
    }
  },

  componentWillReceiveProps: function (nextProps) {
    // When the modal gets closed set the editor and not loaded.
    if (this.props.revealed && !nextProps.revealed) {
      this.setState({editorLoaded: false});
    }
  },

  componentWillUnmount: function () {
  },

  onClose: function () {
    this.props.onCloseClick();
  },

  onSaveClick: function () {
    this.notifier.send('save:click');
  },

  render: function () {
    const mapLocation = boundsToMapLocation(this.props.projectBbox, this.state.editorWidth, this.state.editorHeight);

    return (
      <Modal
        id='modal-scenario-metadata'
        className='modal--large'
        onCloseClick={this.onClose}
        revealed={this.props.revealed} >

        <ModalHeader>
          <div className='modal__headline'>
            <h1 className='modal__title'>{t('Edit road network')}</h1>
            <div className='modal__description'>
            </div>
{'fraction_non_alphanumeric': 0.1440295445219532, 'fraction_numerical': 0.002051702913418137, 'mean_word_length': 2.90625, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5155675', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1463, 'n_words': 297}