// @flow import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { ModalActions } from '../../components/modal'; import Button from '../../components/button'; import { Link } from '../../components/link'; import CollaborationBadge from '../../icons/badges/CollaborationBadge'; import type { collaboratorListTrackingType, item as ItemType, collaboratorType, } from '../unified-share-modal/flowTypes'; import commonMessages from '../../common/messages'; import CollaboratorListItem from './CollaboratorListItem'; import messages from './messages'; import './CollaboratorList.scss'; const MAX_COLLABORATOR_LIST_SIZE = 90; type Props = { collaborators: Array, doneButtonProps?: Object, item: ItemType, maxCollaboratorListSize: number, onDoneClick: Function, trackingProps: collaboratorListTrackingType, }; class CollaboratorList extends React.Component { static defaultProps = { maxCollaboratorListSize: MAX_COLLABORATOR_LIST_SIZE, }; createCollaboratorPageLink(children: React.Node, trackingProp: ?Object) { const { item } = this.props; const { type, id } = item; const collaboratorsPageLink = `/${type}/${id}/collaborators/`; return ( {children} ); } render() { const { collaborators, onDoneClick, maxCollaboratorListSize, trackingProps } = this.props; const { usernameProps, emailProps, manageLinkProps, viewAdditionalProps, doneButtonProps } = trackingProps; const manageAllBtn = ( ); const maxListSizeToRender = Math.min(maxCollaboratorListSize, MAX_COLLABORATOR_LIST_SIZE); return (
{this.createCollaboratorPageLink(manageAllBtn, manageLinkProps)}
    {collaborators.slice(0, maxListSizeToRender).map((collaborator, index) => { const { collabID, type } = collaborator; return ( ); })} {collaborators.length > maxListSizeToRender && (
  • {this.createCollaboratorPageLink( , viewAdditionalProps, )}
  • )}
); } } export default CollaboratorList;