11import Column from "antd/es/table/Column" ;
22import OrgApi from "api/orgApi" ;
33import { GroupUser , MEMBER_ROLE , OrgUser } from "constants/orgConstants" ;
4- import { CheckBox , CustomModal } from "lowcoder-design" ;
5- import { CSSProperties , ReactNode , useEffect , useRef , useState } from "react" ;
4+ import { CheckBox , CustomModal , Search } from "lowcoder-design" ;
5+ import { CSSProperties , ReactNode , useEffect , useRef , useState , useCallback } from "react" ;
66import { connect , useDispatch } from "react-redux" ;
77import { AppState } from "redux/reducers" ;
8- import { fetchGroupUsersAction , fetchOrgUsersAction } from "redux/reduxActions/orgActions" ;
8+ import { fetchGroupUsersAction ,
9+ fetchOrgUsersAction ,
10+ fetchGroupPotentialMembersAction
11+ } from "redux/reduxActions/orgActions" ;
912import styled from "styled-components" ;
1013import { StyledTable , UserTableCellWrapper } from "./styledComponents" ;
1114import { formatTimestamp } from "util/dateTimeUtils" ;
@@ -14,6 +17,7 @@ import { isGroupAdmin } from "util/permissionUtils";
1417import { SuperUserIcon } from "lowcoder-design" ;
1518import { EmptyContent } from "pages/common/styledComponent" ;
1619import { trans } from "i18n" ;
20+ import { debounce } from "lodash" ;
1721
1822const TableWrapper = styled . div `
1923 margin-right: -16px;
@@ -40,7 +44,25 @@ function AddGroupUserDialog(props: {
4044 const addableUsers = orgUsers . filter ( ( user ) => ! groupUserIdMap . has ( user . userId ) ) ;
4145 const toAddUserIdRecord = useRef < Record < string , boolean > > ( { } ) ;
4246 const [ confirmLoading , setConfirmLoading ] = useState ( false ) ;
47+ const [ searchValue , setSearchValue ] = useState ( "" )
4348 const dispatch = useDispatch ( ) ;
49+
50+ const debouncedFetchPotentialMembers = useCallback (
51+ debounce ( ( searchVal : string ) => {
52+ dispatch ( fetchGroupPotentialMembersAction ( searchVal , groupId ) ) ;
53+ } , 500 ) ,
54+ [ dispatch , groupId ]
55+ ) ;
56+
57+ useEffect ( ( ) => {
58+ if ( searchValue . length > 2 || searchValue === "" ) {
59+ debouncedFetchPotentialMembers ( searchValue ) ;
60+ }
61+ return ( ) => {
62+ debouncedFetchPotentialMembers . cancel ( ) ;
63+ } ;
64+ } , [ searchValue , debouncedFetchPotentialMembers ] ) ;
65+
4466 useEffect ( ( ) => {
4567 if ( dialogVisible ) {
4668 dispatch ( fetchOrgUsersAction ( orgId ) ) ;
@@ -92,7 +114,18 @@ function AddGroupUserDialog(props: {
92114 setDialogVisible ( false ) ;
93115 } }
94116 >
95- { ! addableUsers || addableUsers . length === 0 ? (
117+ < Search
118+ placeholder = { trans ( "memberSettings.searchMember" ) }
119+ value = { searchValue }
120+ onChange = { ( e ) => setSearchValue ( e . target . value ) }
121+ style = { {
122+ width : "100%" ,
123+ height : "32px" ,
124+ paddingRight : "20px" ,
125+ marginBottom : "10px"
126+ } }
127+ />
128+ { ( ! addableUsers || addableUsers . length === 0 ) ? (
96129 < EmptyContent />
97130 ) : (
98131 < TableWrapper >
@@ -106,7 +139,7 @@ function AddGroupUserDialog(props: {
106139 scroll = { { y : 309 } }
107140 >
108141 < Column
109- width = "170px "
142+ width = "200px "
110143 title = { trans ( "memberSettings.nameColumn" ) }
111144 dataIndex = "name"
112145 key = "name"
0 commit comments