<commit_before>const React = require('react')
const {
  Dialog, RaisedButton, Checkbox, Toggle,
  Table, TableBody, TableRow, TableRowColumn
} = require('material-ui')
const { mailboxWizardStore, mailboxWizardActions } = require('../../stores/mailboxWizard')
const { Mailbox } = require('shared/Models/Mailbox')

const styles = {
  introduction: {
    textAlign: 'center',
    padding: 12,
    fontSize: '110%',
    fontWeight: 'bold'
  },
  actionCell: {
    width: 48,
    paddingLeft: 0,
    paddingRight: 0,
    textAlign: 'center'
  },
  titleCell: {
    paddingLeft: 0,
    paddingRight: 0
  },
  avatar: {
    height: 22,
    width: 22,
    top: 2
  }
}

module.exports = React.createClass({
  /* **************************************************************************/
  // Class
  /* **************************************************************************/

  displayName: 'ConfigureMailboxServicesDialog',

  /* **************************************************************************/
  // Component Lifecycle
  /* **************************************************************************/

  componentDidMount () {
    mailboxWizardStore.listen(this.mailboxWizardChanged)
  },

  componentWillUnmount () {
    mailboxWizardStore.unlisten(this.mailboxWizardChanged)
  },

  /* **************************************************************************/
  // Data lifecycle
  /* **************************************************************************/

  getInitialState (wizardState = mailboxWizardStore.getState()) {
    return {
      isOpen: wizardState.configureServicesOpen,
      mailboxType: wizardState.provisonaMailboxType(),
      availableServices: wizardState.provisionalMailboxSupportedServices(),
      enabledServices: new Set(wizardState.provisionalDefaultMailboxServices()),
      compactServices: false
    }
  },

  mailboxWizardChanged (wizardState) {
    this.setState((prevState) => {
      if (!prevState.isOpen && wizardState.configureServicesOpen) {
        return this.getInitialState(wizardState)
      } else {
        return { isOpen: wizardState.configureServicesOpen }
      }
    })
  },

  /* **************************************************************************/
  // UI Events
  /* **************************************************************************/

  /**
  * Toggles a service
  * @param service: the service type
  * @param toggled: true if its enabled, false otherwise
  */
  handleToggleService (service, toggled) {
    this.setState((prevState) => {
      const enabledServices = new Set(Array.from(prevState.enabledServices))
      enabledServices[toggled ? 'add' : 'delete'](service)
      return { enabledServices: enabledServices }
    })
  },

  /* **************************************************************************/
  // Rendering
  /* **************************************************************************/

  /**
  * Renders the service name
  * @param mailboxType: the type of mailbox
  * @param service: the service type
  * @return the human name for the service
  */
  getServiceName (mailboxType, service) {
    if (mailboxType === Mailbox.TYPE_GMAIL || mailboxType === Mailbox.TYPE_GINBOX) {
      switch (service) {
        case Mailbox.SERVICES.STORAGE: return 'Google Drive'
        case Mailbox.SERVICES.CONTACTS: return 'Google Contacts'
        case Mailbox.SERVICES.NOTES: return 'Google Keep'
        case Mailbox.SERVICES.CALENDAR: return 'Google Calendar'
      }
    }

    return ''
  },

  /**
  * @param mailboxType: the type of mailbox
  * @param service: the service type
  * @return the url of the service icon
  */
  getServiceIconUrl (mailboxType, service) {
    if (mailboxType === Mailbox.TYPE_GMAIL || mailboxType === Mailbox.TYPE_GINBOX) {
      switch (service) {
        case Mailbox.SERVICES.STORAGE: return '../../images/google_services/logo_drive_128px.png'
        case Mailbox.SERVICES.CONTACTS: return '../../images/google_services/logo_contacts_128px.png'
        case Mailbox.SERVICES.NOTES: return '../../images/google_services/logo_keep_128px.png'
        case Mailbox.SERVICES.CALENDAR: return '../../images/google_services/logo_calendar_128px.png'
      }
    }

    return ''
  },

  render () {
    const { isOpen, enabledServices, mailboxType, availableServices, compactServices } = this.state
    const actions = (
      <RaisedButton
        label='Next'
        primary
        onClick={() => {
          mailboxWizardActions.configureMailboxServices(Array.from(enabledServices), compactServices)
        }} />
    )<commit_msg>Added hangouts to the account wizard<commit_after>const React = require('react')
const {
  Dialog, RaisedButton, Checkbox, Toggle,
  Table, TableBody, TableRow, TableRowColumn
} = require('material-ui')
const { mailboxWizardStore, mailboxWizardActions } = require('../../stores/mailboxWizard')
const { Mailbox } = require('shared/Models/Mailbox')

const styles = {
  introduction: {
    textAlign: 'center',
    padding: 12,
    fontSize: '110%',
    fontWeight: 'bold'
  },
  actionCell: {
    width: 48,
    paddingLeft: 0,
    paddingRight: 0,
    textAlign: 'center'
  },
  titleCell: {
    paddingLeft: 0,
    paddingRight: 0
  },
  avatar: {
    height: 22,
    width: 22,
    top: 2
  }
}

module.exports = React.createClass({
  /* **************************************************************************/
  // Class
  /* **************************************************************************/

  displayName: 'ConfigureMailboxServicesDialog',

  /* **************************************************************************/
  // Component Lifecycle
  /* **************************************************************************/

  componentDidMount () {
    mailboxWizardStore.listen(this.mailboxWizardChanged)
  },

  componentWillUnmount () {
    mailboxWizardStore.unlisten(this.mailboxWizardChanged)
  },

  /* **************************************************************************/
  // Data lifecycle
  /* **************************************************************************/

  getInitialState (wizardState = mailboxWizardStore.getState()) {
    return {
      isOpen: wizardState.configureServicesOpen,
      mailboxType: wizardState.provisonaMailboxType(),
      availableServices: wizardState.provisionalMailboxSupportedServices(),
      enabledServices: new Set(wizardState.provisionalDefaultMailboxServices()),
      compactServices: false
    }
  },

  mailboxWizardChanged (wizardState) {
    this.setState((prevState) => {
      if (!prevState.isOpen && wizardState.configureServicesOpen) {
        return this.getInitialState(wizardState)
      } else {
        return { isOpen: wizardState.configureServicesOpen }
      }
    })
  },

  /* **************************************************************************/
  // UI Events
  /* **************************************************************************/

  /**
  * Toggles a service
  * @param service: the service type
  * @param toggled: true if its enabled, false otherwise
  */
  handleToggleService (service, toggled) {
    this.setState((prevState) => {
      const enabledServices = new Set(Array.from(prevState.enabledServices))
      enabledServices[toggled ? 'add' : 'delete'](service)
      return { enabledServices: enabledServices }
    })
  },

  /* **************************************************************************/
  // Rendering
  /* **************************************************************************/

  /**
  * Renders the service name
  * @param mailboxType: the type of mailbox
  * @param service: the service type
  * @return the human name for the service
  */
  getServiceName (mailboxType, service) {
    if (mailboxType === Mailbox.TYPE_GMAIL || mailboxType === Mailbox.TYPE_GINBOX) {
      switch (service) {
        case Mailbox.SERVICES.STORAGE: return 'Google Drive'
        case Mailbox.SERVICES.CONTACTS: return 'Google Contacts'
        case Mailbox.SERVICES.NOTES: return 'Google Keep'
        case Mailbox.SERVICES.CALENDAR: return 'Google Calendar'
        case Mailbox.SERVICES.COMMUNICATION: return 'Google Hangouts'
      }
    }

    return ''
  },

  /**
  * @param mailboxType: the type of mailbox
  * @param service: the service type
  * @return the url of the service icon
  */
  getServiceIconUrl (mailboxType, service) {
    if (mailboxType === Mailbox.TYPE_GMAIL || mailboxType === Mailbox.TYPE_GINBOX) {
      switch (service) {
        case Mailbox.SERVICES.STORAGE: return '../../images/google_services/logo_drive_128px.png'
        case Mailbox.SERVICES.CONTACTS: return '../../images/google_services/logo_contacts_128px.png'
        case Mailbox.SERVICES.NOTES: return '../../images/google_services/logo_keep_128px.png'
        case Mailbox.SERVICES.CALENDAR: return '../../images/google_services/logo_calendar_128px.png'
        case Mailbox.SERVICES.COMMUNICATION: return '../../images/google_services/logo_hangouts_128px.png'
      }
    }

    return ''
  },

  render () {
    const { isOpen, enabledServices, mailboxType, availableServices, compactServices } = this.state
    const actions = (
      <RaisedButton
        label='Next'
        primary
        onClick={() => {
          mailboxWizardActions.configureMailboxServices(Array.from(enabledServices), compactServices)
        }} />
    )
{'fraction_non_alphanumeric': 0.2600556268720582, 'fraction_numerical': 0.006311510483525888, 'mean_word_length': 3.760183299389002, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5454078', 'n_tokens_mistral': 2637, 'n_tokens_neox': 2474, 'n_words': 492}