
define(
  [
    'react',
    'backbone',
    'components/projects/common/StatusLight.react',
    './StatusBar.react'
  ],
  function (React, Backbone, StatusLight, StatusBar) {

    return React.createClass({
      displayName: "Status",

      propTypes: {
        instance: React.PropTypes.instanceOf(Backbone.Model).isRequired
      },

      render: function () {
        var instanceState = this.props.instance.get('state');
        var status = instanceState.get('status');
        var activity = instanceState.get('activity');
        var lightStatus = "transition";

        if (status === "active" && !activity) {
          lightStatus = "active";
        } else if (status === "suspended" && !activity) {
          lightStatus = "inactive";
        } else if (status === "shutoff" && !activity) {
          lightStatus = "inactive";
        }

        var rawStatus = instanceState.get('status_raw');

        var style = {};
        var capitalizedStatus = rawStatus.charAt(0).toUpperCase() + rawStatus.slice(1);

        if (instanceState.isDeployError()) {
          return (
            <span>
              <div>
                <span style={{color: "#d44950"}}>{"Launch failed. Atmosphere at capacity."}</span>
              </div>
            </span>
          );
        }

        return (
          <span>
            <div>
              <StatusLight status={lightStatus}/>
              <span style={style}>{capitalizedStatus}</span>
            </div>
            <StatusBar state={instanceState} activity={activity}/>
          </span>
        );
      }

    });

  });

@@ -540,16 +540,79 @@
     var 
+lightStatus;%0A%0A        if (activity != undefined) %7B%0A            
 lightSta
@@ -631,25 +631,24 @@
 ition%22;%0A
-%0A
         
 if (stat
@@ -635,24 +635,31 @@
 n%22;%0A        
+%7D else 
 if (status =
@@ -659,17 +659,16 @@
 tatus ==
-=
  %22active
@@ -668,33 +668,22 @@
 %22active%22
- && !activity
 ) %7B%0A
+  
         
@@ -736,17 +736,16 @@
 tatus ==
-=
  %22suspen
@@ -749,32 +749,44 @@
 pended%22 
-&& !activity
+%7C%7C status == %22shutoff%22
 ) %7B%0A
+  
         
@@ -832,49 +832,12 @@
 lse 
-if (status === %22shutoff%22 && !activity) 
 %7B%0A
+  
     
@@ -853,32 +853,29 @@
 htStatus = %22
-inactive
+error
 %22;%0A        %7D

Refactor Status