<commit_before>import React, {PropTypes} from 'react'
import {Link, withRouter} from 'react-router'

import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized'

import Dropdown from 'shared/components/Dropdown'
import QuestionMarkTooltip from 'shared/components/QuestionMarkTooltip'

const kapacitorDropdown = (
  kapacitors,
  source,
  router,
  setActiveKapacitor,
  handleDeleteKapacitor
) => {
  if (!kapacitors || kapacitors.length === 0) {
    return (
      <Link
        to={`/sources/${source.id}/kapacitors/new`}
        className="btn btn-xs btn-default"
      >
        <span className="icon plus" /> Add Config
      </Link>
    )
  }
  const kapacitorItems = kapacitors.map(k => {
    return {
      text: k.name,
      resource: `/sources/${source.id}/kapacitors/${k.id}`,
      kapacitor: k,
    }
  })

  const activeKapacitor = kapacitors.find(k => k.active)

  let selected = ''
  if (activeKapacitor) {
    selected = activeKapacitor.name
  } else {
    selected = kapacitorItems[0].text
  }

  return (
    <Authorized
      requiredRole={EDITOR_ROLE}
      propsOverride={{addNew: null, actions: null}}
    ><commit_msg>Render Add Config button in sources table based on user authorization<commit_after>import React, {PropTypes} from 'react'
import {Link, withRouter} from 'react-router'

import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized'

import Dropdown from 'shared/components/Dropdown'
import QuestionMarkTooltip from 'shared/components/QuestionMarkTooltip'

const kapacitorDropdown = (
  kapacitors,
  source,
  router,
  setActiveKapacitor,
  handleDeleteKapacitor
) => {
  if (!kapacitors || kapacitors.length === 0) {
    return (
      <Authorized requiredRole={EDITOR_ROLE}>
        <Link
          to={`/sources/${source.id}/kapacitors/new`}
          className="btn btn-xs btn-default"
        >
          <span className="icon plus" /> Add Config
        </Link>
      </Authorized>
    )
  }
  const kapacitorItems = kapacitors.map(k => {
    return {
      text: k.name,
      resource: `/sources/${source.id}/kapacitors/${k.id}`,
      kapacitor: k,
    }
  })

  const activeKapacitor = kapacitors.find(k => k.active)

  let selected = ''
  if (activeKapacitor) {
    selected = activeKapacitor.name
  } else {
    selected = kapacitorItems[0].text
  }

  return (
    <Authorized
      requiredRole={EDITOR_ROLE}
      propsOverride={{addNew: null, actions: null}}
    >
{'fraction_non_alphanumeric': 0.1255161023947151, 'fraction_numerical': 0.0016515276630883566, 'mean_word_length': 3.1137521222410864, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, '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': '3420490', 'n_tokens_mistral': 802, 'n_tokens_neox': 803, 'n_words': 165}