<commit_before>React = require 'react'
PropTypes = require 'prop-types'
createReactClass = require 'create-react-class'
uniq = require 'lodash/uniq'

zooniverseTeamRole = (role) ->
  role.section is 'zooniverse' and [ 'admin', 'team' ].indexOf(role.name) isnt -1

researcherRole = (role) ->
  userIsResearcher = ['admin', 'scientist', 'owner'].indexOf(role.name) isnt -1
  role.section isnt 'zooniverse' and userIsResearcher

roleDisplayName = (role) ->
  if zooniverseTeamRole(role) # show zooniverse admins everywhere as 'team'
    "Zooniverse Team"
  else if researcherRole(role) # project admins, scientists, owners
    "Researcher"
  else
    role.name

DisplayRoles = createReactClass
  displayName: 'TalkDisplayRoles'

  propTypes:
    roles: PropTypes.array # roles resources

  role: (role, i) ->
    zooTeamName = if zooniverseTeamRole(role) then 'zoo-team'
    <p key={role.id} className="project-role #{zooTeamName ? role.name}">
      {roleDisplayName(role)}
    </p>

  render: ->
    <div className="talk-display-roles">
      {uniq(@props.roles, roleDisplayName).map(@role)}
    </div>

module.exports = DisplayRoles<commit_msg>Replace uniq with uniqBy for Talk roles (#4364)<commit_after>React = require 'react'
PropTypes = require 'prop-types'
createReactClass = require 'create-react-class'
uniqBy = require 'lodash/uniqBy'

zooniverseTeamRole = (role) ->
  role.section is 'zooniverse' and [ 'admin', 'team' ].indexOf(role.name) isnt -1

researcherRole = (role) ->
  userIsResearcher = ['admin', 'scientist', 'owner'].indexOf(role.name) isnt -1
  role.section isnt 'zooniverse' and userIsResearcher

roleDisplayName = (role) ->
  if zooniverseTeamRole(role) # show zooniverse admins everywhere as 'team'
    "Zooniverse Team"
  else if researcherRole(role) # project admins, scientists, owners
    "Researcher"
  else
    role.name

DisplayRoles = createReactClass
  displayName: 'TalkDisplayRoles'

  propTypes:
    roles: PropTypes.array # roles resources

  role: (role, i) ->
    zooTeamName = if zooniverseTeamRole(role) then 'zoo-team'
    <p key={role.id} className="project-role #{zooTeamName ? role.name}">
      {roleDisplayName(role)}
    </p>

  render: ->
    <div className="talk-display-roles">
      {uniqBy(@props.roles, roleDisplayName).map(@role)}
    </div>

module.exports = DisplayRoles
{'fraction_non_alphanumeric': 0.13101374570446736, 'fraction_numerical': 0.003436426116838488, 'mean_word_length': 4.293181818181818, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '947639', 'n_tokens_mistral': 796, 'n_tokens_neox': 787, 'n_words': 186}