fix(attachment): fix message attachment & rename to AttachmentComponent

This commit is contained in:
Evan Morikawa 2015-02-06 18:47:31 -05:00
parent 59b7155357
commit 9b15858bf2
5 changed files with 14 additions and 12 deletions

View file

@ -90,5 +90,6 @@
# Temporarily disabled
"sidebar-fullcontact",
"message-templates",
"calendar-bar"
"calendar-bar",
"salesforce"
]

View file

@ -8,8 +8,8 @@ React = require 'react'
# @props.file is a File object
module.exports =
MessageAttachment = React.createClass
displayName: 'MessageAttachment'
AttachmentComponent = React.createClass
displayName: 'AttachmentComponent'
propTypes:
file: React.PropTypes.object.isRequired,

View file

@ -2,14 +2,14 @@
module.exports =
activate: (@state={}) ->
MessageAttachment = require "./message-attachment.cjsx"
AttachmentComponent = require "./attachment-component.cjsx"
ComponentRegistry.register
name: 'MessageAttachment'
view: MessageAttachment
name: 'AttachmentComponent'
view: AttachmentComponent
role: 'Attachment'
deactivate: ->
ComponentRegistry.unregister "MessageAttachment"
ComponentRegistry.unregister "AttachmentComponent"
serialize: -> @state

View file

@ -35,7 +35,7 @@ ComposerView = React.createClass
getComponentRegistryState: ->
ResizableComponent: ComponentRegistry.findViewByName 'ResizableComponent'
MessageAttachment: ComponentRegistry.findViewByName 'MessageAttachment'
AttachmentComponent: ComponentRegistry.findViewByName 'AttachmentComponent'
FooterComponents: ComponentRegistry.findAllViewsByRole 'Composer:Footer'
componentWillMount: ->
@ -174,9 +174,9 @@ ComposerView = React.createClass
<Component draftLocalId={@props.localId} />
_fileComponents: ->
MessageAttachment = @state.MessageAttachment
AttachmentComponent = @state.AttachmentComponent
(@state.files ? []).map (file) =>
<MessageAttachment file={file}
<AttachmentComponent file={file}
removable={true}
messageLocalId={@props.localId} />

View file

@ -15,7 +15,7 @@ MessageItem = React.createClass
thread_participants: React.PropTypes.arrayOf(React.PropTypes.object),
mixins: [ComponentRegistry.Mixin]
components: ['MessageAttachment']
components: ['AttachmentComponent']
getInitialState: ->
# Holds the downloadData (if any) for all of our files. It's a hash
@ -102,9 +102,10 @@ MessageItem = React.createClass
_formatContacts: (contacts=[]) ->
_attachmentComponents: ->
AttachmentComponent = @state.AttachmentComponent
attachments = _.filter @props.message.files, (f) -> not f.contentId?
attachments.map (file) =>
<MessageAttachment file={file} download={@state.downloads[file.id]}/>
<AttachmentComponent file={file} download={@state.downloads[file.id]}/>
_messageTime: ->
moment(@props.message.date).format(@_timeFormat())