11import * as React from 'react'
22import * as Kb from '../../../../common-adapters'
33import * as Styles from '../../../../styles'
4- import * as Types from '../../../../constants/types/teams'
54import * as Container from '../../../../util/container'
65import * as TeamsGen from '../../../../actions/teams-gen'
6+ import type * as Types from '../../../../constants/types/teams'
77import { typeToLabel } from '../../../../constants/teams'
8- import { BoolTypeMap , MemberStatus , TeamRoleType } from '../../../../constants/types/teams'
8+ import type { BoolTypeMap , MemberStatus , TeamRoleType } from '../../../../constants/types/teams'
99import MenuHeader from '../menu-header.new'
1010
1111export type Props = {
@@ -44,20 +44,21 @@ const showCrown: BoolTypeMap = {
4444// you're changing one remember to change the other.
4545
4646export const TeamMemberRow = ( props : Props ) => {
47- let crown , fullNameLabel , resetLabel
47+ const { roleType , fullName } = props
4848 const active = props . status === 'active'
49- if ( active && props . roleType && showCrown [ props . roleType ] ) {
50- crown = (
51- < Kb . Icon type = { ( 'iconfont-crown-' + props . roleType ) as any } style = { styles . crownIcon } fontSize = { 10 } />
52- )
53- }
54- if ( props . fullName && active ) {
55- fullNameLabel = (
49+ const crown =
50+ active && roleType && showCrown [ roleType ] ? (
51+ < Kb . Icon type = { ( 'iconfont-crown-' + roleType ) as Kb . IconType } style = { styles . crownIcon } fontSize = { 10 } />
52+ ) : null
53+
54+ const fullNameLabel =
55+ fullName && active ? (
5656 < Kb . Text style = { styles . fullNameLabel } type = "BodySmall" lineClamp = { 1 } >
57- { props . fullName } •
57+ { fullName } •
5858 </ Kb . Text >
59- )
60- }
59+ ) : null
60+
61+ let resetLabel : string | undefined = undefined
6162 if ( ! active ) {
6263 resetLabel = props . youCanManageMembers
6364 ? 'Has reset their account'
@@ -69,7 +70,7 @@ export const TeamMemberRow = (props: Props) => {
6970 resetLabel = ' • Needs to update Keybase'
7071 }
7172
72- const roleLabel = ! ! active && ! ! props . roleType && typeToLabel [ props . roleType ]
73+ const roleLabel = ! ! active && ! ! roleType && typeToLabel [ roleType ]
7374 const isYou = props . you === props . username
7475 const teamID = props . teamID
7576
@@ -83,6 +84,9 @@ export const TeamMemberRow = (props: Props) => {
8384 dispatch ( TeamsGen . createTeamSetMemberSelected ( { selected, teamID, username : props . username } ) )
8485 }
8586
87+ const canEnterMemberPage = props . youCanManageMembers && active && ! props . needsPUK
88+ const onClick = anySelected ? ( ) => onSelect ( ! selected ) : canEnterMemberPage ? props . onClick : undefined
89+
8690 const checkCircle = (
8791 < Kb . CheckCircle
8892 checked = { selected }
@@ -97,7 +101,12 @@ export const TeamMemberRow = (props: Props) => {
97101 < Kb . Avatar username = { props . username } size = { 32 } />
98102 < Kb . Box2 direction = "vertical" style = { styles . nameContainer } >
99103 < Kb . Box style = { Styles . globalStyles . flexBoxRow } >
100- < Kb . ConnectedUsernames type = "BodyBold" usernames = { props . username } colorFollowing = { true } />
104+ < Kb . ConnectedUsernames
105+ type = "BodyBold"
106+ usernames = { props . username }
107+ colorFollowing = { true }
108+ onUsernameClicked = { onClick }
109+ />
101110 </ Kb . Box >
102111
103112 < Kb . Box2 direction = "horizontal" centerChildren = { true } alignSelf = "flex-start" >
@@ -111,7 +120,7 @@ export const TeamMemberRow = (props: Props) => {
111120 />
112121 ) }
113122 < Kb . Text type = "BodySmall" >
114- { ! ! active && ! ! props . roleType && typeToLabel [ props . roleType ] }
123+ { ! ! active && ! ! roleType && typeToLabel [ roleType ] }
115124 { resetLabel }
116125 </ Kb . Text >
117126 </ Kb . Box2 >
@@ -211,14 +220,14 @@ export const TeamMemberRow = (props: Props) => {
211220 </ Kb . Box2 >
212221 )
213222
214- const canEnterMemberPage = props . youCanManageMembers && active && ! props . needsPUK
215223 const massActionsProps = props . youCanManageMembers
216224 ? {
217225 containerStyleOverride : styles . listItemMargin ,
218226 icon : checkCircle ,
219227 iconStyleOverride : styles . checkCircle ,
220228 }
221229 : { }
230+
222231 return (
223232 < Kb . ListItem2
224233 { ...massActionsProps }
@@ -230,7 +239,7 @@ export const TeamMemberRow = (props: Props) => {
230239 firstItem = { props . firstItem }
231240 style = { selected ? styles . selected : styles . unselected }
232241 innerStyle = { selected ? styles . selected : styles . unselected }
233- onClick = { anySelected ? ( ) => onSelect ( ! selected ) : canEnterMemberPage ? props . onClick : undefined }
242+ onClick = { onClick }
234243 />
235244 )
236245}
0 commit comments