<commit_before>/**
 * Created by justin on 7/11/16.
 */
import * as React from 'react';
import * as _ from 'lodash';
import PageHeader from '../Projects/components/PageHeader';
import TabNavigation from '../Projects/components/TabNavigation';
import DeployedServices from '../Projects/components/DeployedServices';
import Packaging from './components/Packaging';
import UploadPreProcessingModal from './components/UploadPreProcessingModal';
import { connect } from 'react-redux';
import { uploadPackage } from './actions/deployment.actions';
import { bindActionCreators } from 'redux';
import './styles/deployment.scss';

interface Props {
  params: {
    projectid: string
  },
  packages: {
    packages: string[]
  }
}

interface DispatchProps {
  uploadPackage: Function
}

export class Deployment extends React.Component<Props & DispatchProps, any> {
  constructor() {
    super();
    this.state = {
      tabs: {
        deployedServices: {
          label: 'DEPLOYED SERVICES',
          isSelected: true,
          onClick: this.clickHandler.bind(this),
          component: <DeployedServices/>
        },
        packaging: {
          label: 'PACKAGING',
          isSelected: false,
          onClick: this.clickHandler.bind(this),
          component: <Packaging/>
        }
      },
      isSelected: 'deployedServices',
      uploadOpen: false,
      packages: [],
      projectId: null
    };
  }

  componentWillMount() {
    this.setState({
      tabs: {
        deployedServices: {
          label: 'DEPLOYED SERVICES',
          isSelected: true,
          onClick: this.clickHandler.bind(this),
          component: <DeployedServices/>
        },
        packaging: {
          label: 'PACKAGING',
          isSelected: false,
          onClick: this.clickHandler.bind(this),
          component: <Packaging projectId={this.props.params.projectid}/>
        }
      }
    });
  }

  clickHandler(tab) {
    let key = _.findKey(this.state.tabs, tab);
    let newState = _.cloneDeep(this.state);
    Object.keys(newState.tabs).map((tab) => {
      newState.tabs[tab].isSelected = false;
    });
    newState.tabs[key].isSelected = true;
    newState.isSelected = key;
    this.setState(newState);
  }

  openUpload() {
    this.setState({
      uploadOpen: true
    });
  }

  closeUpload() {
    this.setState({
      uploadOpen: false
    });
  }

  upload(event, uploadedPackage, formData) {
    event.preventDefault();
    this.props.uploadPackage(parseInt(this.props.params.projectid, 10), uploadedPackage.name, formData);
    this.closeUpload();
  }

  render(): React.ReactElement<HTMLDivElement> {
    console.log(this.props.params.projectid);
    return (
      <div className="services">
        <UploadPreProcessingModal open={this.state.uploadOpen} cancel={this.closeUpload.bind(this)}
                                  upload={this.upload.bind(this)}/>
        <PageHeader>
          <span>Deployment</span>
          <span><button className="default" onClick={this.openUpload.bind(this)}>Upload New Package</button></span>
        </PageHeader>
        <TabNavigation tabs={this.state.tabs}/>
        <main>
          {this.state.tabs.deployedServices.isSelected === true ? <DeployedServices projectId={this.props.params.projectid}/> : null}
          {this.state.tabs.packaging.isSelected === true ? <Packaging projectId={this.props.params.projectid}/> : null}
        </main>
      </div>
    );
  }
}

function mapStateToProps(state) {
  return {
    packages: state.packages
  };
}

function mapDispatchToProps(dispatch) {
  return {
    uploadPackage: bindActionCreators(uploadPackage, dispatch)
  };
}

export default connect<any, DispatchProps, any>(mapStateToProps, mapDispatchToProps)(Deployment);
<commit_msg>Clean up<commit_after>/**
 * Created by justin on 7/11/16.
 */
import * as React from 'react';
import * as _ from 'lodash';
import PageHeader from '../Projects/components/PageHeader';
import TabNavigation from '../Projects/components/TabNavigation';
import DeployedServices from '../Projects/components/DeployedServices';
import Packaging from './components/Packaging';
import UploadPreProcessingModal from './components/UploadPreProcessingModal';
import { connect } from 'react-redux';
import { uploadPackage } from './actions/deployment.actions';
import { bindActionCreators } from 'redux';
import './styles/deployment.scss';

interface Props {
  params: {
    projectid: string
  },
  packages: {
    packages: string[]
  }
}

interface DispatchProps {
  uploadPackage: Function
}

export class Deployment extends React.Component<Props & DispatchProps, any> {
  constructor() {
    super();
    this.state = {
      tabs: {
        deployedServices: {
          label: 'DEPLOYED SERVICES',
          isSelected: true,
          onClick: this.clickHandler.bind(this),
          component: <DeployedServices/>
        },
        packaging: {
          label: 'PACKAGING',
          isSelected: false,
          onClick: this.clickHandler.bind(this),
          component: <Packaging/>
        }
      },
      isSelected: 'deployedServices',
      uploadOpen: false,
      packages: [],
      projectId: null
    };
  }

  componentWillMount() {
    this.setState({
      tabs: {
        deployedServices: {
          label: 'DEPLOYED SERVICES',
          isSelected: true,
          onClick: this.clickHandler.bind(this),
          component: <DeployedServices/>
        },
        packaging: {
          label: 'PACKAGING',
          isSelected: false,
          onClick: this.clickHandler.bind(this),
          component: <Packaging projectId={this.props.params.projectid}/>
        }
      }
    });
  }

  clickHandler(tab) {
    let key = _.findKey(this.state.tabs, tab);
    let newState = _.cloneDeep(this.state);
    Object.keys(newState.tabs).map((tab) => {
      newState.tabs[tab].isSelected = false;
    });
    newState.tabs[key].isSelected = true;
    newState.isSelected = key;
    this.setState(newState);
  }

  openUpload() {
    this.setState({
      uploadOpen: true
    });
  }

  closeUpload() {
    this.setState({
      uploadOpen: false
    });
  }

  upload(event, uploadedPackage, formData) {
    event.preventDefault();
    this.props.uploadPackage(parseInt(this.props.params.projectid, 10), uploadedPackage.name, formData);
    this.closeUpload();
  }

  render(): React.ReactElement<HTMLDivElement> {
    return (
      <div className="services">
        <UploadPreProcessingModal open={this.state.uploadOpen} cancel={this.closeUpload.bind(this)}
                                  upload={this.upload.bind(this)}/>
        <PageHeader>
          <span>Deployment</span>
          <span><button className="default" onClick={this.openUpload.bind(this)}>Upload New Package</button></span>
        </PageHeader>
        <TabNavigation tabs={this.state.tabs}/>
        <main>
          {this.state.tabs.deployedServices.isSelected === true ? <DeployedServices projectId={this.props.params.projectid}/> : null}
          {this.state.tabs.packaging.isSelected === true ? <Packaging projectId={this.props.params.projectid}/> : null}
        </main>
      </div>
    );
  }
}

function mapStateToProps(state) {
  return {
    packages: state.packages
  };
}

function mapDispatchToProps(dispatch) {
  return {
    uploadPackage: bindActionCreators(uploadPackage, dispatch)
  };
}

export default connect<any, DispatchProps, any>(mapStateToProps, mapDispatchToProps)(Deployment);

{'fraction_non_alphanumeric': 0.13108815242184355, 'fraction_numerical': 0.0018784382128002146, 'mean_word_length': 2.785678009141696, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '798912', 'n_tokens_mistral': 2179, 'n_tokens_neox': 2170, 'n_words': 408}