/*
This file is part of the Juju GUI, which lets users view and manage Juju
environments within a graphical interface (https://launchpad.net/juju-gui).
Copyright (C) 2015 Canonical Ltd.

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

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
SATISFACTORY QUALITY, 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/>.
*/

'use strict';

YUI.add('env-list', function() {

  juju.components.EnvList = React.createClass({

    propTypes: {
      envs: React.PropTypes.array,
      handleEnvClick: React.PropTypes.func,
      createNewEnv: React.PropTypes.func
    },

    getInitialState: function() {
        return {
          envs: this.props.envs
        };
    },

    generateEnvList: function() {
      var envs = [];
      this.state.envs.forEach(function(env) {
        // below the env.name is for JES response object and env.path is for
        // the JEM response object.
        envs.push(
          <li className="env-list__environment"
            data-id={env.uuid}
            onClick={this.props.handleEnvClick}
            key={env.uuid}>
            {env.name || env.path}
          </li>);
      }, this);
      return envs;
    },

    render: function() {
      var actionButtons = [{
        title: 'New',
        type: 'confirm',
        action: this.props.createNewEnv
      }];

      return (
        <juju.components.Panel
          instanceName="env-list-panel"
          visible={true}>
          <ul className="env-list">
            {this.generateEnvList()}
            <juju.components.ButtonRow buttons={actionButtons} />
          </ul>
        </juju.components.Panel>
      );
    }
  });

}, '0.1.0', { requires: [
  'button-row',
  'panel-component'
]});

@@ -878,17 +878,16 @@
 Class(%7B%0A
-%0A
     prop
@@ -1121,24 +1121,130 @@
  %7D;%0A    %7D,%0A%0A
+    componentWillReceiveProps: function(nextProps) %7B%0A      this.setState(%7Benvs: nextProps.envs%7D);%0A    %7D,%0A%0A
     generate
@@ -1445,16 +1445,60 @@
 object.%0A
+        var envName = env.name %7C%7C env.path;%0A
         
@@ -1679,33 +1679,20 @@
     %7Benv
-.n
+N
 ame
- %7C%7C env.path
 %7D%0A      
@@ -2081,24 +2081,38 @@
 nvList()%7D%0A  
+        %3C/ul%3E%0A
           %3Cj
@@ -2163,32 +2163,16 @@
 ons%7D /%3E%0A
-          %3C/ul%3E%0A
         

Move the env name generation outside of the jsx