@@ -25,30 +25,36 @@ const WorkspacesPage: FC = () => {
25
25
const styles = useStyles ( )
26
26
const [ workspacesState , send ] = useMachine ( workspacesMachine )
27
27
28
- const form : FormikContextType < FilterFormValues > = useFormik < FilterFormValues > ( {
29
- initialValues : { query : workspacesState . context . filter || "" } ,
30
- onSubmit : ( data ) => {
28
+ const form = useFormik < FilterFormValues > ( {
29
+ initialValues : {
30
+ query : workspacesState . context . filter || "" ,
31
+ } ,
32
+ onSubmit : ( values ) => {
31
33
send ( {
32
34
type : "SET_FILTER" ,
33
- query : data . query ,
35
+ query : values . query ,
34
36
} )
35
37
} ,
36
38
} )
37
39
38
- const getFieldHelpers = getFormHelpers < FilterFormValues > ( form , { } )
40
+ const getFieldHelpers = getFormHelpers < FilterFormValues > ( form )
39
41
40
42
const [ anchorEl , setAnchorEl ] = useState < null | HTMLElement > ( null )
43
+
41
44
const handleClick = ( event : React . MouseEvent < HTMLButtonElement > ) => {
42
45
setAnchorEl ( event . currentTarget )
43
46
}
47
+
44
48
const handleClose = ( ) => {
45
49
setAnchorEl ( null )
46
50
}
51
+
47
52
const setYourWorkspaces = ( ) => {
48
53
form . setFieldValue ( "query" , "owner:me" )
49
54
void form . submitForm ( )
50
55
handleClose ( )
51
56
}
57
+
52
58
const setAllWorkspaces = ( ) => {
53
59
form . setFieldValue ( "query" , "" )
54
60
void form . submitForm ( )
@@ -60,13 +66,15 @@ const WorkspacesPage: FC = () => {
60
66
< Margins >
61
67
< div className = { styles . actions } >
62
68
< Stack direction = "row" >
63
- < Button aria-controls = "simple -menu" aria-haspopup = "true" onClick = { handleClick } >
69
+ < Button aria-controls = "filter -menu" aria-haspopup = "true" onClick = { handleClick } >
64
70
Filter
65
71
</ Button >
66
- < Menu id = "simple-menu" anchorEl = { anchorEl } keepMounted open = { Boolean ( anchorEl ) } onClose = { handleClose } >
72
+
73
+ < Menu id = "filter-menu" anchorEl = { anchorEl } keepMounted open = { Boolean ( anchorEl ) } onClose = { handleClose } >
67
74
< MenuItem onClick = { setYourWorkspaces } > Your workspaces</ MenuItem >
68
75
< MenuItem onClick = { setAllWorkspaces } > All workspaces</ MenuItem >
69
76
</ Menu >
77
+
70
78
< form onSubmit = { form . handleSubmit } >
71
79
< TextField { ...getFieldHelpers ( "query" ) } onChange = { onChangeTrimmed ( form ) } fullWidth variant = "outlined" />
72
80
</ form >
@@ -76,6 +84,7 @@ const WorkspacesPage: FC = () => {
76
84
< Button startIcon = { < AddCircleOutline /> } > { Language . createButton } </ Button >
77
85
</ Link >
78
86
</ div >
87
+
79
88
< WorkspacesPageView
80
89
loading = { workspacesState . hasTag ( "loading" ) }
81
90
workspaces = { workspacesState . context . workspaces }
0 commit comments