<commit_before>import * as React from 'react'
import * as Types from '../../../constants/types/chat2'
import * as Styles from '../../../styles'
import * as Kb from '../../../common-adapters'
import * as RPCChatTypes from '../../../constants/types/rpc-chat-gen'
// @ts-ignore
import {Props as HeaderHocProps} from '../../../common-adapters/header-hoc/types'
import {AdhocHeader, TeamHeader} from './header'
import {SettingsPanel} from './panels'
import Participant from './participant'
import {AttachmentTypeSelector, DocView, LinkView, MediaView} from './attachments'

export type Panel = 'settings' | 'members' | 'attachments'
export type ParticipantTyp = {
  username: string
  fullname: string
  isAdmin: boolean
  isOwner: boolean
}
export type EntityType = 'adhoc' | 'small team' | 'channel'
export type Section = {
  data: Array<any>
  renderItem: ({item: any, index: number}) => void
  renderSectionHeader: (any) => void
}

type Thumb = {
  ctime: number
  height: number
  isVideo: boolean
  onClick: () => void
  previewURL: string
  width: number
}

type MediaProps = {
  onLoadMore: null | (() => void)
  thumbs: Array<Thumb>
  status: Types.AttachmentViewStatus
}

type Doc = {
  author: string
  ctime: number
  downloading: boolean
  name: string
  progress: number
  onDownload: null | (() => void)
  onShowInFinder: null | (() => void)
}

type DocProps = {
  docs: Array<Doc>
  onLoadMore: null | (() => void)
  status: Types.AttachmentViewStatus
}

type Link = {
  author: string
  ctime: number
  snippet: string
  title: string
  url: string
}

type LinkProps = {
  links: Array<Link>
  onLoadMore: null | (() => void)
  status: Types.AttachmentViewStatus
}

export type InfoPanelProps = {
  selectedConversationIDKey: Types.ConversationIDKey
  participants: Array<ParticipantTyp>
  isPreview: boolean
  teamname: string | null
  channelname: string | null
  smallTeam: boolean
  admin: boolean
  ignored: boolean
  spinnerForHide: boolean
  selectedAttachmentView: RPCChatTypes.GalleryItemTyp
  selectedTab: Panel

  // Attachment stuff
  docs: DocProps
  links: LinkProps
  media: MediaProps
  onAttachmentViewChange: (typ: RPCChatTypes.GalleryItemTyp) => void

  // Used by HeaderHoc.
  onBack: () => void

  // Used by Participant.
  onShowProfile: (username: string) => void

  // Used for conversations.
  onShowBlockConversationDialog: () => void
  onShowClearConversationDialog: () => void
  onShowNewTeamDialog: () => void
  onHideConv: () => void
  onUnhideConv: () => void
  onSelectTab: (p: Panel) => void

  // Used for small and big teams.
  canSetMinWriterRole: boolean
  canSetRetention: boolean

  // Used for big teams.
  canEditChannel: boolean
  canDeleteHistory: boolean
  description: string | null
  onEditChannel: () => void
  onLeaveConversation: () => void
  onJoinChannel: () => void
} & HeaderHocProps

const TabText = ({selected, text}: {selected: boolean; text: string}) => (
  <Kb.Text type="BodySmallSemibold" style={selected ? styles.tabTextSelected : undefined}>
    {text}
  </Kb.Text>
)

class _InfoPanel extends React.Component<InfoPanelProps> {
  componentDidMount() {
    this._retryLoad()
  }

  _retryLoad = () => {
    this.props.onAttachmentViewChange(this.props.selectedAttachmentView)
  }

  _getEntityType = (): EntityType => {
    if (this.props.teamname && this.props.channelname) {
      return this.props.smallTeam ? 'small team' : 'channel'
    }
    return 'adhoc'
  }

  _isSelected = (s: Panel) => {
    return s === this.props.selectedTab
  }

  _getTabs = (entityType: EntityType) => {
    const res = []
    if (entityType !== 'adhoc') {
      res.push(
        <Kb.Box2 key="members" style={styles.tabTextContainer} direction="horizontal">
          <TabText selected={this._isSelected('members')} text="Members" />
        </Kb.Box2>
      )
    }
    res.push(
      <Kb.Box2 key="attachments" style={styles.tabTextContainer} direction="horizontal">
        <TabText selected={this._isSelected('attachments')} text="Attachments" />
      </Kb.Box2>
    )
    if (!this.props.isPreview) {
      res.push(<commit_msg>participant count on members tab<commit_after>import * as React from 'react'
import * as Types from '../../../constants/types/chat2'
import * as Styles from '../../../styles'
import * as Kb from '../../../common-adapters'
import * as RPCChatTypes from '../../../constants/types/rpc-chat-gen'
// @ts-ignore
import {Props as HeaderHocProps} from '../../../common-adapters/header-hoc/types'
import {AdhocHeader, TeamHeader} from './header'
import {SettingsPanel} from './panels'
import Participant from './participant'
import {AttachmentTypeSelector, DocView, LinkView, MediaView} from './attachments'

export type Panel = 'settings' | 'members' | 'attachments'
export type ParticipantTyp = {
  username: string
  fullname: string
  isAdmin: boolean
  isOwner: boolean
}
export type EntityType = 'adhoc' | 'small team' | 'channel'
export type Section = {
  data: Array<any>
  renderItem: ({item: any, index: number}) => void
  renderSectionHeader: (any) => void
}

type Thumb = {
  ctime: number
  height: number
  isVideo: boolean
  onClick: () => void
  previewURL: string
  width: number
}

type MediaProps = {
  onLoadMore: null | (() => void)
  thumbs: Array<Thumb>
  status: Types.AttachmentViewStatus
}

type Doc = {
  author: string
  ctime: number
  downloading: boolean
  name: string
  progress: number
  onDownload: null | (() => void)
  onShowInFinder: null | (() => void)
}

type DocProps = {
  docs: Array<Doc>
  onLoadMore: null | (() => void)
  status: Types.AttachmentViewStatus
}

type Link = {
  author: string
  ctime: number
  snippet: string
  title: string
  url: string
}

type LinkProps = {
  links: Array<Link>
  onLoadMore: null | (() => void)
  status: Types.AttachmentViewStatus
}

export type InfoPanelProps = {
  selectedConversationIDKey: Types.ConversationIDKey
  participants: Array<ParticipantTyp>
  isPreview: boolean
  teamname: string | null
  channelname: string | null
  smallTeam: boolean
  admin: boolean
  ignored: boolean
  spinnerForHide: boolean
  selectedAttachmentView: RPCChatTypes.GalleryItemTyp
  selectedTab: Panel

  // Attachment stuff
  docs: DocProps
  links: LinkProps
  media: MediaProps
  onAttachmentViewChange: (typ: RPCChatTypes.GalleryItemTyp) => void

  // Used by HeaderHoc.
  onBack: () => void

  // Used by Participant.
  onShowProfile: (username: string) => void

  // Used for conversations.
  onShowBlockConversationDialog: () => void
  onShowClearConversationDialog: () => void
  onShowNewTeamDialog: () => void
  onHideConv: () => void
  onUnhideConv: () => void
  onSelectTab: (p: Panel) => void

  // Used for small and big teams.
  canSetMinWriterRole: boolean
  canSetRetention: boolean

  // Used for big teams.
  canEditChannel: boolean
  canDeleteHistory: boolean
  description: string | null
  onEditChannel: () => void
  onLeaveConversation: () => void
  onJoinChannel: () => void
} & HeaderHocProps

const TabText = ({selected, text}: {selected: boolean; text: string}) => (
  <Kb.Text type="BodySmallSemibold" style={selected ? styles.tabTextSelected : undefined}>
    {text}
  </Kb.Text>
)

class _InfoPanel extends React.Component<InfoPanelProps> {
  componentDidMount() {
    this._retryLoad()
  }

  _retryLoad = () => {
    this.props.onAttachmentViewChange(this.props.selectedAttachmentView)
  }

  _getEntityType = (): EntityType => {
    if (this.props.teamname && this.props.channelname) {
      return this.props.smallTeam ? 'small team' : 'channel'
    }
    return 'adhoc'
  }

  _isSelected = (s: Panel) => {
    return s === this.props.selectedTab
  }

  _getTabs = (entityType: EntityType) => {
    const res = []
    if (entityType !== 'adhoc') {
      res.push(
        <Kb.Box2 key="members" style={styles.tabTextContainer} direction="horizontal">
          <TabText
            selected={this._isSelected('members')}
            text={`Members (${this.props.participants.length})`}
          />
        </Kb.Box2>
      )
    }
    res.push(
      <Kb.Box2 key="attachments" style={styles.tabTextContainer} direction="horizontal">
        <TabText selected={this._isSelected('attachments')} text="Attachments" />
      </Kb.Box2>
    )
    if (!this.props.isPreview) {
      res.push(
{'fraction_non_alphanumeric': 0.1345573136852277, 'fraction_numerical': 0.0012078753472641623, 'mean_word_length': 3.5519516217702036, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6977958', 'n_tokens_mistral': 2637, 'n_tokens_neox': 2633, 'n_words': 658}