@@ -182,14 +182,33 @@ const REDIRECT_ROUTES = [
182182 {
183183 label : "Group Tournament" ,
184184 value : "group_tournaments" ,
185+ placeholder : "ID" ,
185186 build : ( id ) => `/group_tournaments/${ id } ` ,
186187 } ,
188+ {
189+ label : "Game" ,
190+ value : "games" ,
191+ placeholder : "Game ID" ,
192+ build : ( id ) => `/games/${ id } ` ,
193+ } ,
194+ {
195+ label : "Tournament" ,
196+ value : "tournaments" ,
197+ placeholder : "Tournament ID" ,
198+ build : ( id ) => `/tournaments/${ id } ` ,
199+ } ,
200+ {
201+ label : "Event" ,
202+ value : "events" ,
203+ placeholder : "Event slug" ,
204+ build : ( slug ) => `/e/${ slug } ` ,
205+ } ,
187206] ;
188207
189208const parseUserIds = ( raw ) =>
190209 [ ...new Set ( ( raw . match ( / \d + / g) || [ ] ) . map ( Number ) ) ] ;
191210
192- function RedirectPanel ( ) {
211+ function RedirectPanel ( { allUserIds } ) {
193212 const dispatch = useDispatch ( ) ;
194213 const [ route , setRoute ] = useState ( REDIRECT_ROUTES [ 0 ] . value ) ;
195214 const [ id , setId ] = useState ( "" ) ;
@@ -199,6 +218,11 @@ function RedirectPanel() {
199218
200219 const userIds = useMemo ( ( ) => parseUserIds ( userIdsRaw ) , [ userIdsRaw ] ) ;
201220
221+ const selectedRoute = useMemo (
222+ ( ) => REDIRECT_ROUTES . find ( ( item ) => item . value === route ) || REDIRECT_ROUTES [ 0 ] ,
223+ [ route ] ,
224+ ) ;
225+
202226 const handleFetch = ( event ) => {
203227 event . preventDefault ( ) ;
204228
@@ -218,6 +242,10 @@ function RedirectPanel() {
218242 ) ;
219243 } ;
220244
245+ const handleSelectAll = ( ) => {
246+ setUserIdsRaw ( ( prev ) => parseUserIds ( `${ prev } ${ allUserIds . join ( " " ) } ` ) . join ( ", " ) ) ;
247+ } ;
248+
221249 const handleSubmit = ( event ) => {
222250 event . preventDefault ( ) ;
223251
@@ -262,6 +290,14 @@ function RedirectPanel() {
262290 < button className = "btn btn-secondary" type = "submit" disabled = { ! tournamentId . trim ( ) } >
263291 Fetch player IDs
264292 </ button >
293+ < button
294+ className = "btn btn-secondary"
295+ type = "button"
296+ disabled = { allUserIds . length === 0 }
297+ onClick = { handleSelectAll }
298+ >
299+ All ({ allUserIds . length } )
300+ </ button >
265301 </ form >
266302
267303 < textarea
@@ -289,7 +325,7 @@ function RedirectPanel() {
289325 className = "form-control"
290326 style = { { maxWidth : "160px" } }
291327 type = "text"
292- placeholder = "ID"
328+ placeholder = { selectedRoute . placeholder }
293329 value = { id }
294330 onChange = { ( event ) => setId ( event . target . value ) }
295331 />
@@ -319,6 +355,11 @@ function AdminWidget() {
319355 [ presenceList ] ,
320356 ) ;
321357
358+ const allUserIds = useMemo (
359+ ( ) => [ ...new Set ( presenceList . map ( ( entry ) => entry . id ) ) ] ,
360+ [ presenceList ] ,
361+ ) ;
362+
322363 const groups = useMemo ( ( ) => {
323364 const map = new Map ( ) ;
324365
@@ -368,7 +409,7 @@ function AdminWidget() {
368409 { presenceList . length } users · { totalConnections } connections
369410 </ div >
370411 </ div >
371- < RedirectPanel />
412+ < RedirectPanel allUserIds = { allUserIds } />
372413 { groups . length === 0 ? (
373414 < div className = "text-center text-muted py-5" > No active connections</ div >
374415 ) : (
0 commit comments