1- import * as React from 'react'
2- import * as Types from '../../../constants/types/chat2'
31import * as Constants from '../../../constants/chat2'
2+ import * as Kb from '../../../common-adapters'
3+ import * as React from 'react'
4+ import * as RouteTreeGen from '../../../actions/route-tree-gen'
45import * as Styles from '../../../styles'
5- import * as TeamTypes from '../../../constants/types/teams'
66import * as TeamsGen from '../../../actions/teams-gen'
7- import * as Kb from '../../../common-adapters'
7+ import type * as TeamTypes from '../../../constants/types/teams'
8+ import type * as Types from '../../../constants/types/chat2'
89import { connect } from '../../../util/container'
9- import * as RouteTreeGen from '../../../actions/route-tree-gen'
1010
1111type Props = {
1212 isAdmin : boolean
1313 isGeneralChannel : boolean
1414 onAddPeople : ( ) => void
1515 onAddToChannel : ( ) => void
16- } & Kb . OverlayParentProps
16+ }
1717
1818const _AddPeople = ( props : Props ) => {
19- let menu : React . ReactNode = null
2019 let directAction : null | ( ( ) => void ) = null
2120 let directLabel : string | null = null
2221 if ( ! props . isGeneralChannel ) {
23- // general channel & small teams don't need a menu
24- const items : Kb . MenuItems = [
25- { icon : 'iconfont-people' , onClick : props . onAddPeople , title : 'To team' } ,
26- { icon : 'iconfont-hash' , onClick : props . onAddToChannel , title : 'To channel' } ,
27- ]
28- menu = (
29- < Kb . FloatingMenu
30- attachTo = { props . getAttachmentRef }
31- visible = { props . showingMenu }
32- items = { items }
33- onHidden = { props . toggleShowingMenu }
34- position = "bottom left"
35- closeOnSelect = { true }
36- />
37- )
3822 } else {
3923 directAction = props . onAddPeople
4024 directLabel = 'Add people to team'
@@ -43,15 +27,36 @@ const _AddPeople = (props: Props) => {
4327 directAction = props . onAddToChannel
4428 directLabel = 'Add members to channel'
4529 }
30+
31+ const { toggleShowingPopup, showingPopup, popup, popupAnchor} = Kb . usePopup ( attachTo => {
32+ if ( ! props . isGeneralChannel ) {
33+ // general channel & small teams don't need a menu
34+ const items : Kb . MenuItems = [
35+ { icon : 'iconfont-people' , onClick : props . onAddPeople , title : 'To team' } ,
36+ { icon : 'iconfont-hash' , onClick : props . onAddToChannel , title : 'To channel' } ,
37+ ]
38+ return (
39+ < Kb . FloatingMenu
40+ attachTo = { attachTo }
41+ visible = { showingPopup }
42+ items = { items }
43+ onHidden = { toggleShowingPopup }
44+ position = "bottom left"
45+ closeOnSelect = { true }
46+ />
47+ )
48+ } else return null
49+ } )
50+
4651 return (
4752 < Kb . Box2 direction = "vertical" fullWidth = { true } >
48- { menu }
53+ { popup }
4954 < Kb . Button
5055 mode = "Primary"
5156 type = "Default"
52- onClick = { directAction || props . toggleShowingMenu }
57+ onClick = { directAction || toggleShowingPopup }
5358 label = { directLabel || 'Add people...' }
54- ref = { props . setAttachmentRef }
59+ ref = { popupAnchor }
5560 style = { styles . addButtonContainer }
5661 />
5762 </ Kb . Box2 >
@@ -88,7 +93,7 @@ const AddPeople = connect(
8893 onAddPeople : ( ) => d . _onAddPeople ( s . teamID ) ,
8994 onAddToChannel : ( ) => d . _onAddToChannel ( o . conversationIDKey , s . teamID ) ,
9095 } )
91- ) ( Kb . OverlayParentHOC ( _AddPeople ) )
96+ ) ( _AddPeople )
9297
9398const styles = Styles . styleSheetCreate (
9499 ( ) =>
0 commit comments