<commit_before>define(function(require) {

  var React = require('react/addons'),
    Backbone = require('backbone'),
    Glyphicon = require('components/common/Glyphicon.react'),
    actions = require('actions'),
    modals = require('modals');

  return React.createClass({

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

    onStart: function() {
      modals.InstanceModals.start(this.props.instance);
    },

    onSuspend: function() {
      modals.InstanceModals.suspend(this.props.instance);
    },

    onStop: function() {
      modals.InstanceModals.stop(this.props.instance);
    },

    onResume: function() {
      modals.InstanceModals.resume(this.props.instance);
    },

    onReport: function() {
      modals.InstanceModals.report({
        instance: this.props.instance
      });
    },

    onImageRequest: function() {
      modals.InstanceModals.requestImage({
        instance: this.props.instance
      });
    },

    onDelete: function() {
      var project = this.props.project,
        instance = this.props.instance;

      modals.InstanceModals.destroy({
        instance: instance,
        project: project,
        linksTo: "project-resources",
        params: {projectId: project.id}
      });
    },

    onRedeploy: function(){
      modals.InstanceModals.redeploy(this.props.instance);
    },

    onReboot: function(){
      modals.InstanceModals.reboot(this.props.instance);
    },

    render: function() {
      var webShellUrl = this.props.instance.get('shell_url'),
          remoteDesktopUrl = this.props.instance.get('vnc_url'),
          status = this.props.instance.get('state').get('status'),
          activity = this.props.instance.get('state').get('activity'),
          ip_address = this.props.instance.get('ip_address'),
          webLinksDisabled = !ip_address || ip_address === "0.0.0.0";

      // todo: Add back and implement reboot and resize once it's understood how to
      // I'm hiding from the display for now so as not to show users functionality
      // that doesn't exist.
      var linksArray = [
        {label: 'Actions', icon: null},
        {label: 'Report', icon: 'inbox', onClick: this.onReport}
        //{label: 'Reboot', icon: 'repeat', onClick: this.onReboot},
        //{label: 'Resize', icon: 'resize-full', onClick: this.onResize},
      ];

      if (status !== "suspended") {
        linksArray.push({label: 'Image', icon: 'camera', onClick: this.onImageRequest});
      }

      // Add in the conditional links based on current machine state
      if (this.props.instance.get('state').isInFinalState()) {
        if (status === "active") {
          linksArray.push({label: 'Suspend', icon: 'pause', onClick: this.onSuspend});
          linksArray.push({label: 'Stop', icon: 'stop', onClick: this.onStop});
          linksArray.push({label: 'Reboot', icon: 'repeat', onClick: this.onReboot});
          linksArray.push({label: 'Redeploy', icon: 'repeat', onClick: this.onRedeploy});
        } else if (status === "suspended") {
          linksArray.push({label: 'Resume', icon: 'play', onClick: this.onResume});
        } else if (status === "shutoff") {
          linksArray.push({label: 'Start', icon: 'play', onClick: this.onStart});
        }
      }

      if ( activity === "deploying" || status === "deploying"
        || activity === "deploy_error"|| status === "deploy_error"
        || activity === "boot_script_error") {
        linksArray.push({label: 'Redeploy', icon: 'repeat', onClick: this.onRedeploy});
      }

      linksArray = linksArray.concat([
        {label: 'Delete', icon: 'remove', onClick: this.onDelete, isDangerLink: true},
        {label: 'Links', icon: null},
        {
          label: 'Open Web Shell',
          icon: 'credit-card',
          href: webShellUrl,
          openInNewWindow: true,<commit_msg>Instances that are in 'initalizing' should be allowed to redeploy<commit_after>define(function(require) {

  var React = require('react/addons'),
    Backbone = require('backbone'),
    Glyphicon = require('components/common/Glyphicon.react'),
    actions = require('actions'),
    modals = require('modals');

  return React.createClass({

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

    onStart: function() {
      modals.InstanceModals.start(this.props.instance);
    },

    onSuspend: function() {
      modals.InstanceModals.suspend(this.props.instance);
    },

    onStop: function() {
      modals.InstanceModals.stop(this.props.instance);
    },

    onResume: function() {
      modals.InstanceModals.resume(this.props.instance);
    },

    onReport: function() {
      modals.InstanceModals.report({
        instance: this.props.instance
      });
    },

    onImageRequest: function() {
      modals.InstanceModals.requestImage({
        instance: this.props.instance
      });
    },

    onDelete: function() {
      var project = this.props.project,
        instance = this.props.instance;

      modals.InstanceModals.destroy({
        instance: instance,
        project: project,
        linksTo: "project-resources",
        params: {projectId: project.id}
      });
    },

    onRedeploy: function(){
      modals.InstanceModals.redeploy(this.props.instance);
    },

    onReboot: function(){
      modals.InstanceModals.reboot(this.props.instance);
    },

    render: function() {
      var webShellUrl = this.props.instance.get('shell_url'),
          remoteDesktopUrl = this.props.instance.get('vnc_url'),
          status = this.props.instance.get('state').get('status'),
          activity = this.props.instance.get('state').get('activity'),
          ip_address = this.props.instance.get('ip_address'),
          webLinksDisabled = !ip_address || ip_address === "0.0.0.0";

      // todo: Add back and implement reboot and resize once it's understood how to
      // I'm hiding from the display for now so as not to show users functionality
      // that doesn't exist.
      var linksArray = [
        {label: 'Actions', icon: null},
        {label: 'Report', icon: 'inbox', onClick: this.onReport}
        //{label: 'Reboot', icon: 'repeat', onClick: this.onReboot},
        //{label: 'Resize', icon: 'resize-full', onClick: this.onResize},
      ];

      if (status !== "suspended") {
        linksArray.push({label: 'Image', icon: 'camera', onClick: this.onImageRequest});
      }

      // Add in the conditional links based on current machine state
      if (this.props.instance.get('state').isInFinalState()) {
        if (status === "active") {
          linksArray.push({label: 'Suspend', icon: 'pause', onClick: this.onSuspend});
          linksArray.push({label: 'Stop', icon: 'stop', onClick: this.onStop});
          linksArray.push({label: 'Reboot', icon: 'repeat', onClick: this.onReboot});
          linksArray.push({label: 'Redeploy', icon: 'repeat', onClick: this.onRedeploy});
        } else if (status === "suspended") {
          linksArray.push({label: 'Resume', icon: 'play', onClick: this.onResume});
        } else if (status === "shutoff") {
          linksArray.push({label: 'Start', icon: 'play', onClick: this.onStart});
        }
      }

      if ( activity === "deploying" || status === "deploying"
        || activity === "deploy_error"|| status === "deploy_error"
        || activity === "initializing" || activity === "boot_script_error") {
        linksArray.push({label: 'Redeploy', icon: 'repeat', onClick: this.onRedeploy});
      }

      linksArray = linksArray.concat([
        {label: 'Delete', icon: 'remove', onClick: this.onDelete, isDangerLink: true},
        {label: 'Links', icon: null},
        {
          label: 'Open Web Shell',
          icon: 'credit-card',
          href: webShellUrl,
          openInNewWindow: true,
{'fraction_non_alphanumeric': 0.15264016054182866, 'fraction_numerical': 0.0010033864291985452, 'mean_word_length': 2.768431001890359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1470305', 'n_tokens_mistral': 2373, 'n_tokens_neox': 2320, 'n_words': 498}