@@ -105,33 +105,13 @@ export const CreateUserForm: FC<
105
105
)
106
106
107
107
const styles = useStyles ( )
108
- // This, unfortunately, cannot be an actual component because mui requires
109
- // that all `MenuItem`s must be direct children of the `Select` they belong to
110
- const authMethodSelect = ( value : keyof typeof authMethodLanguage ) => {
111
- const language = authMethodLanguage [ value ]
112
- return (
113
- < MenuItem key = { value } id = { "item-" + value } value = { value } >
114
- < Stack spacing = { 0 } maxWidth = { 400 } >
115
- { language . displayName }
116
- < span className = { styles . labelDescription } >
117
- { language . description }
118
- </ span >
119
- </ Stack >
120
- </ MenuItem >
121
- )
122
- }
123
108
124
- const methods = [ ]
125
- if ( authMethods ?. password . enabled ) {
126
- methods . push ( authMethodSelect ( "password" ) )
127
- }
128
- if ( authMethods ?. oidc . enabled ) {
129
- methods . push ( authMethodSelect ( "oidc" ) )
130
- }
131
- if ( authMethods ?. github . enabled ) {
132
- methods . push ( authMethodSelect ( "github" ) )
133
- }
134
- methods . push ( authMethodSelect ( "none" ) )
109
+ const methods = [
110
+ authMethods ?. password . enabled && "password" ,
111
+ authMethods ?. oidc . enabled && "oidc" ,
112
+ authMethods ?. github . enabled && "github" ,
113
+ "none" ,
114
+ ] . filter ( Boolean ) as Array < keyof typeof authMethodLanguage >
135
115
136
116
return (
137
117
< FullPageForm title = "Create user" >
@@ -177,7 +157,19 @@ export const CreateUserForm: FC<
177
157
?. displayName ?? "" ,
178
158
} }
179
159
>
180
- { methods }
160
+ { methods . map ( ( value ) => {
161
+ const language = authMethodLanguage [ value ]
162
+ return (
163
+ < MenuItem key = { value } id = { "item-" + value } value = { value } >
164
+ < Stack spacing = { 0 } maxWidth = { 400 } >
165
+ { language . displayName }
166
+ < span className = { styles . labelDescription } >
167
+ { language . description }
168
+ </ span >
169
+ </ Stack >
170
+ </ MenuItem >
171
+ )
172
+ } ) }
181
173
</ TextField >
182
174
< TextField
183
175
{ ...getFieldHelpers (
0 commit comments