<commit_before>'use babel'

import React from 'react'
import TableView from './table-view'
import MachineRow from './machine-row'

export default class MachinesTable extends React.Component {
  constructor (props) {
    super(props)
    this.state = { powerProgress: {} }
  }

  getHeadings () {
    return [
      { label: 'Alias', accessor: 'alias' },
      { label: 'Team', accessor: 'team' },
      { label: 'Machine Label', accessor: 'label' },
      { label: 'Ip', accessor: 'ip' },
      { label: 'Owner', accessor: m => m.owner || m.username || '' },
      { label: 'Provider', accessor: 'provider' },
      { label: 'Created At', accessor: 'createdAt' },
      { label: 'Turn on/off' },
      { label: 'Terminal' },
      { label: 'Build Logs' },
      { label: 'Mount' },
      { label: 'Always On' },
    ]
  }

  setPowerProgress (machine) {
    this.setState({
      powerProgress: {
        ...this.state.powerProgress,
        [machine.id]: true,
      },
    })
  }

  onTurnOn (machine, index) {
    this.setPowerProgress(machine)
    this.props.onTurnOn(machine, index)
  }

  onTurnOff (machine, index) {
    this.setPowerProgress(machine)
    this.props.onTurnOff(machine, index)
  }

  renderRow (machine, index) {
    return (
      <MachineRow
        key={index}
        machine={machine}
        index={index}
        hasPowerProgress={this.state.powerProgress[machine.id]}
        onTurnOn={this.onTurnOn.bind(this)}
        onTurnOff={this.onTurnOff.bind(this)}
        onTerminal={this.props.onTerminal}<commit_msg>stop power progress on button after it's done<commit_after>'use babel'

import React from 'react'
import TableView from './table-view'
import MachineRow from './machine-row'

export default class MachinesTable extends React.Component {
  constructor (props) {
    super(props)
    this.state = { powerProgress: {} }
  }

  getHeadings () {
    return [
      { label: 'Alias', accessor: 'alias' },
      { label: 'Team', accessor: 'team' },
      { label: 'Machine Label', accessor: 'label' },
      { label: 'Ip', accessor: 'ip' },
      { label: 'Owner', accessor: m => m.owner || m.username || '' },
      { label: 'Provider', accessor: 'provider' },
      { label: 'Created At', accessor: 'createdAt' },
      { label: 'Turn on/off' },
      { label: 'Terminal' },
      { label: 'Build Logs' },
      { label: 'Mount' },
      { label: 'Always On' },
    ]
  }

  setPowerProgress (machine, state) {
    this.setState({
      powerProgress: {
        ...this.state.powerProgress,
        [machine.id]: state,
      },
    })
  }

  onTurnOn (machine, index) {
    this.setPowerProgress(machine, true)
    this.props.onTurnOn(machine, index)
      .then(() => {
        this.setPowerProgress(machine, false)
      })
      .catch(() => {
        this.setPowerProgress(machine, false)
      })
  }

  onTurnOff (machine, index) {
    this.setPowerProgress(machine, true)
    this.props.onTurnOff(machine, index)
      .then(() => {
        this.setPowerProgress(machine, false)
      })
      .catch(() => {
        this.setPowerProgress(machine, false)
      })
  }

  renderRow (machine, index) {
    return (
      <MachineRow
        key={index}
        machine={machine}
        index={index}
        hasPowerProgress={this.state.powerProgress[machine.id]}
        onTurnOn={this.onTurnOn.bind(this)}
        onTurnOff={this.onTurnOff.bind(this)}
        onTerminal={this.props.onTerminal}
{'fraction_non_alphanumeric': 0.15523255813953488, 'fraction_numerical': 0.0, 'mean_word_length': 2.56580310880829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6409010', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1085, 'n_words': 227}