@@ -5,14 +5,15 @@ import Box from "@mui/material/Box";
55import TextField from "@mui/material/TextField" ;
66import Button from "@mui/lab/LoadingButton" ;
77import SearchIcon from "@mui/icons-material/Search" ;
8+ import Typography from "@mui/material/Typography" ;
89import ArrowRightIcon from "@mui/icons-material/ArrowForwardIos" ;
910import { useSelectedTeam } from "~/layouts/TopMenu/Teams/actions" ;
1011import { AuthContext } from "~/pages/auth/Auth.context" ;
11- import Typography from "@mui/material/Typography" ;
1212import githubLogo from "~/assets/logos/github-logo.svg" ;
1313import bitbucketLogo from "~/assets/logos/bitbucket-logo.svg" ;
1414import gitlabLogo from "~/assets/logos/gitlab-logo.svg" ;
1515import { insertRepo } from "./actions" ;
16+ import { CircularProgress } from "@mui/material" ;
1617
1718const logos : Record < Provider , string > = {
1819 github : githubLogo ,
@@ -23,23 +24,23 @@ const logos: Record<Provider, string> = {
2324export interface Props {
2425 repositories : Repo [ ] ;
2526 provider : Provider ;
26- loading : boolean ;
27+ isLoadingList : boolean ;
2728 isLoadingMore : boolean ;
28- error ?: string ;
2929 hasNextPage : boolean ;
3030 onNextPage : ( ) => void ;
31+ onSearch ?: ( term : string ) => void ;
3132}
3233
3334let filterTimer : NodeJS . Timeout ;
3435
3536export default function RepoList ( {
3637 repositories,
3738 provider,
38- loading ,
39+ isLoadingList ,
3940 isLoadingMore,
40- error,
4141 hasNextPage,
4242 onNextPage,
43+ onSearch,
4344} : Props ) {
4445 const [ filter , setFilter ] = useState < string > ( "" ) ;
4546 const [ loadingInsert , setLoadingInsert ] = useState ( "" ) ;
@@ -69,33 +70,37 @@ export default function RepoList({
6970
7071 return (
7172 < >
72- { ( ( repos . length > 0 && ! loading ) || filter ) && (
73- < TextField
74- fullWidth
75- label = "Filter repos"
76- variant = "filled"
77- placeholder = "Filter repos by name"
78- sx = { { mb : 2 } }
79- onChange = { e => {
80- setFilter ( e . target . value ) ;
81- clearTimeout ( filterTimer ) ;
82- filterTimer = setTimeout ( ( ) => {
73+ < TextField
74+ fullWidth
75+ label = { onSearch ? "Search repositories" : "Filter repositories" }
76+ variant = "filled"
77+ placeholder = "Search repositories by name"
78+ sx = { { mb : 2 } }
79+ autoFocus
80+ onChange = { e => {
81+ clearTimeout ( filterTimer ) ;
82+ filterTimer = setTimeout ( ( ) => {
83+ if ( onSearch ) {
84+ onSearch ( e . target . value ) ;
85+ } else {
8386 setFilter ( e . target . value ) ;
84- } , 250 ) ;
85- } }
86- InputLabelProps = { {
87- sx : {
88- pl : 1 ,
89- } ,
90- } }
91- InputProps = { {
87+ }
88+ } , 250 ) ;
89+ } }
90+ slotProps = { {
91+ inputLabel : { sx : { pl : 1 } } ,
92+ input : {
9293 sx : {
9394 pl : 0.75 ,
9495 } ,
95- endAdornment : < SearchIcon sx = { { width : 24 } } /> ,
96- } }
97- />
98- ) }
96+ endAdornment : isLoadingList ? (
97+ < CircularProgress size = "1rem" />
98+ ) : (
99+ < SearchIcon sx = { { width : "1rem" } } />
100+ ) ,
101+ } ,
102+ } }
103+ />
99104
100105 { repos . map ( r => (
101106 < Box
0 commit comments