<commit_before>kd                   = require 'kd'
React                = require 'kd-react'
ChatList             = require 'activity/components/chatlist'
ActivityFlux         = require 'activity/flux'
Scroller             = require 'app/components/scroller'
ScrollerMixin        = require 'app/components/scroller/scrollermixin'
Link                 = require 'app/components/common/link'
dateFormat           = require 'dateformat'
remote               = require('app/remote').getInstance()
ProfileText          = require 'app/components/profile/profiletext'
ProfileLinkContainer = require 'app/components/profile/profilelinkcontainer'

module.exports = class ChatPane extends React.Component

  @defaultProps =
    title         : null
    messages      : null
    isDataLoading : no
    onLoadMore    : kd.noop
    showItemMenu  : yes
    createdBy     : null


  componentWillUpdate: (nextProps, nextState) ->

    return  unless nextProps?.thread

    { thread } = nextProps
    isMessageBeingSubmitted = thread.getIn ['flags', 'isMessageBeingSubmitted']
    @shouldScrollToBottom   = yes  if isMessageBeingSubmitted


  onTopThresholdReached: -> @props.onLoadMore()


  channel: (key) -> @props.thread.getIn ['channel', key]


  getChannelCreationDate: (givenDate) ->

    timeFormat     = 'h:MM TT'

    relativeDates  = ["Today", "Yesterday"]
    today          = new Date
    givenDate      = new Date givenDate
    dateDifference = today.getDate() - givenDate.getDate()
    dateString     = relativeDates[dateDifference] or dateFormat givenDate, "mmmm d"
    if relativeDates[dateDifference]
      dateString     = "#{dateString} at #{dateFormat givenDate, timeFormat}"
    else
      dateString     = "#{dateString}th."


  getChannelCreatorProfile: (accountId) ->

    remote.cacheable "JAccount", accountId, (err, account)=>
      return @props.createdBy = account  if account


  renderProfileLink: ->

    createdAt = @getChannelCreationDate @channel 'createdAt'
    <span>, created by&nbsp;
      <ProfileLinkContainer origin={@props.createdBy}>
        <ProfileText />
      </ProfileLinkContainer> on {createdAt}. <br/>
    </span>


  renderChannelInfoContainer: ->

    return null  unless @props.thread
    @getChannelCreatorProfile @channel 'accountOldId'

    if @props.thread.getIn(['flags', 'reachedFirstMessage']) and @props.createdBy
      channelName = @channel 'name'
      <div className='ChatPane-infoContainer'>
        <div className='ChatPane-channelName'>#{channelName}</div>
        <div className='ChatPane-channelDescription'>
          This is the <Link onClick=kd.noop>#{channelName}</Link> channel
          {@renderProfileLink()}
          You can start a collaboration session, or drag and drop  VMs and workspaces here from the sidebar to let anyone in this channel access them.
          (<Link onClick ={ @props.startCollaboration }>Show me how?</Link>)
        </div>
        <div className='ChatPane-actionContainer'>
          <Link className='ChatPane-startCollaborationAction' onClick ={ @props.startCollaboration }>Start Collaboration</Link>
          <Link className='ChatPane-addIntegrationAction' onClick ={ @props.addIntegration }>Add integration</Link>
          <Link className='ChatPane-inviteOthersAction' onClick ={ @props.inviteOthers }>Invite others</Link>
        </div>
      </div>
<commit_msg>Client: Activity: Added tooltips for integration and collaboration links<commit_after>kd                   = require 'kd'
React                = require 'kd-react'
ChatList             = require 'activity/components/chatlist'
ActivityFlux         = require 'activity/flux'
Scroller             = require 'app/components/scroller'
ScrollerMixin        = require 'app/components/scroller/scrollermixin'
Link                 = require 'app/components/common/link'
dateFormat           = require 'dateformat'
remote               = require('app/remote').getInstance()
ProfileText          = require 'app/components/profile/profiletext'
ProfileLinkContainer = require 'app/components/profile/profilelinkcontainer'

module.exports = class ChatPane extends React.Component

  @defaultProps =
    title         : null
    messages      : null
    isDataLoading : no
    onLoadMore    : kd.noop
    showItemMenu  : yes
    createdBy     : null


  componentWillUpdate: (nextProps, nextState) ->

    return  unless nextProps?.thread

    { thread } = nextProps
    isMessageBeingSubmitted = thread.getIn ['flags', 'isMessageBeingSubmitted']
    @shouldScrollToBottom   = yes  if isMessageBeingSubmitted


  onTopThresholdReached: -> @props.onLoadMore()


  channel: (key) -> @props.thread.getIn ['channel', key]


  getChannelCreationDate: (givenDate) ->

    timeFormat     = 'h:MM TT'

    relativeDates  = ["Today", "Yesterday"]
    today          = new Date
    givenDate      = new Date givenDate
    dateDifference = today.getDate() - givenDate.getDate()
    dateString     = relativeDates[dateDifference] or dateFormat givenDate, "mmmm d"
    if relativeDates[dateDifference]
      dateString     = "#{dateString} at #{dateFormat givenDate, timeFormat}"
    else
      dateString     = "#{dateString}th."


  getChannelCreatorProfile: (accountId) ->

    remote.cacheable "JAccount", accountId, (err, account)=>
      return @props.createdBy = account  if account


  renderProfileLink: ->

    createdAt = @getChannelCreationDate @channel 'createdAt'
    <span>, created by&nbsp;
      <ProfileLinkContainer origin={@props.createdBy}>
        <ProfileText />
      </ProfileLinkContainer> on {createdAt}. <br/>
    </span>


  renderChannelInfoContainer: ->

    return null  unless @props.thread
    @getChannelCreatorProfile @channel 'accountOldId'

    if @props.thread.getIn(['flags', 'reachedFirstMessage']) and @props.createdBy
      channelName = @channel 'name'
      <div className='ChatPane-infoContainer'>
        <div className='ChatPane-channelName'>#{channelName}</div>
        <div className='ChatPane-channelDescription'>
          This is the <Link onClick=kd.noop>#{channelName}</Link> channel
          {@renderProfileLink()}
          You can start a collaboration session, or drag and drop  VMs and workspaces here from the sidebar to let anyone in this channel access them.
          (<Link onClick ={ @props.startCollaboration }>Show me how?</Link>)
        </div>
        <div className='ChatPane-actionContainer'>
          <Link className='ChatPane-startCollaborationAction' onClick ={ @props.startCollaboration }>
            Start Collaboration
            <div className="Tooltip-wrapper"><span>Coming soon</span></div>
          </Link>
          <Link className='ChatPane-addIntegrationAction' onClick ={ @props.addIntegration }>
            Add integration
            <div className="Tooltip-wrapper"><span>Coming soon</span></div>
          </Link>
          <Link className='ChatPane-inviteOthersAction' onClick ={ @props.inviteOthers }>Invite others</Link>
        </div>
      </div>

{'fraction_non_alphanumeric': 0.1065749892565535, 'fraction_numerical': 0.0, 'mean_word_length': 2.9965655409273038, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 75, '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': '3744274', 'n_tokens_mistral': 1956, 'n_tokens_neox': 1874, 'n_words': 456}