Mailspring/internal_packages/inbox-contact-elements/lib/Participants.cjsx
Ben Gotow 1dc7c03ebd fix(contact-chips): Contact chips are editable and have much better style
Summary:
The TokenizingTextField has several new optional props, including onEdit, which enables
editing of the tokens and tokenIsInvalid, which allows you to make tokens red, while still
accepting them as tokens.

When you go to send a message with invalid recipients it won't let you until you remove/
edit them.

Hotloading

Edit chips, keymappings not through command registry, 7 new tests for editing chips

Test Plan: Run 7 new tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1825
2015-08-03 13:06:28 -07:00

44 lines
1 KiB
CoffeeScript

React = require "react"
_ = require "underscore"
ContactChip = require './ContactChip'
{NamespaceStore} = require "nylas-exports"
# Parameters
# clickable (optional) - is this currently clickable?
# thread (optional) - thread context for sorting
# passed into the ParticipantChip
# - 'primary'
# - 'list'
class Participants extends React.Component
@displayName: "Participants"
@containerRequired: false
render: =>
chips = @getParticipants().map (p) =>
<ContactChip key={p.toString()} clickable={@props.clickable} participant={p} />
<span>
{chips}
</span>
getParticipants: =>
myEmail = NamespaceStore.current().emailAddress
list = @props.participants
# Remove 'Me' if there is more than one participant
if list.length > 1
list = _.reject list, (p) -> p.email is myEmail
list.forEach (p) ->
p.id = p.name+p.email
list
shouldComponentUpdate: (newProps, newState) =>
!_.isEqual(newProps.participants, @props.participants)
module.exports = Participants