1515// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
1717import React , { useEffect , useState } from "react" ;
18-
19- import { Theme } from "@mui/material/styles" ;
20- import createStyles from "@mui/styles/createStyles" ;
21- import withStyles from "@mui/styles/withStyles" ;
22- import { Box , Grid } from "@mui/material" ;
2318import {
24- formFieldStyles ,
25- modalBasic ,
26- } from "../Common/FormComponents/common/styleLibrary" ;
27- import InputBoxWrapper from "../Common/FormComponents/InputBoxWrapper/InputBoxWrapper" ;
28- import { BackLink , Button , PageLayout } from "mds" ;
19+ BackLink ,
20+ Button ,
21+ FormLayout ,
22+ Grid ,
23+ InputBox ,
24+ PageLayout ,
25+ SectionTitle ,
26+ Switch ,
27+ } from "mds" ;
2928import { useNavigate } from "react-router-dom" ;
3029import { ErrorResponseHandler } from "../../../common/types" ;
3130import { useAppDispatch } from "../../../store" ;
31+ import { modalStyleUtils } from "../Common/FormComponents/common/styleLibrary" ;
3232import {
3333 setErrorSnackMessage ,
3434 setHelpName ,
3535 setServerNeedsRestart ,
3636} from "../../../systemSlice" ;
3737import useApi from "../Common/Hooks/useApi" ;
38- import SectionTitle from "../Common/SectionTitle" ;
39- import FormSwitchWrapper from "../Common/FormComponents/FormSwitchWrapper/FormSwitchWrapper" ;
4038import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper" ;
4139import HelpMenu from "../HelpMenu" ;
4240
@@ -51,14 +49,7 @@ type AddIDPConfigurationProps = {
5149 endpoint : string ;
5250} ;
5351
54- const styles = ( theme : Theme ) =>
55- createStyles ( {
56- ...formFieldStyles ,
57- ...modalBasic ,
58- } ) ;
59-
6052const AddIDPConfiguration = ( {
61- classes,
6253 icon,
6354 helpBox,
6455 header,
@@ -132,7 +123,7 @@ const AddIDPConfiguration = ({
132123 switch ( value . type ) {
133124 case "toggle" :
134125 return (
135- < FormSwitchWrapper
126+ < Switch
136127 indicatorLabels = { [ "Enabled" , "Disabled" ] }
137128 checked = { fields [ key ] === "on" ? true : false }
138129 value = { "is-field-enabled" }
@@ -148,7 +139,7 @@ const AddIDPConfiguration = ({
148139 ) ;
149140 default :
150141 return (
151- < InputBoxWrapper
142+ < InputBox
152143 id = { key }
153144 required = { value . required }
154145 name = { key }
@@ -178,76 +169,45 @@ const AddIDPConfiguration = ({
178169 actions = { < HelpMenu /> }
179170 />
180171 < PageLayout >
181- < Box
182- sx = { {
183- display : "grid" ,
184- padding : "25px" ,
185- gap : "25px" ,
186- gridTemplateColumns : {
187- md : "2fr 1.2fr" ,
188- xs : "1fr" ,
189- } ,
190- border : "1px solid #eaeaea" ,
191- } }
192- >
193- < Box >
194- < SectionTitle icon = { icon } > { title } </ SectionTitle >
195- < form
196- noValidate
197- autoComplete = "off"
198- onSubmit = { ( e : React . FormEvent < HTMLFormElement > ) => {
199- addRecord ( e ) ;
200- } }
201- >
202- < Grid container item spacing = "20" sx = { { marginTop : 1 } } >
203- < Grid xs = { 12 } item >
204- { Object . entries ( extraFormFields ) . map ( ( [ key , value ] ) => (
205- < Grid
206- item
207- xs = { 12 }
208- className = { classes . formFieldRow }
209- key = { key }
210- >
211- { renderFormField ( key , value ) }
212- </ Grid >
213- ) ) }
214- < Grid item xs = { 12 } textAlign = { "right" } >
215- < Box
216- sx = { {
217- display : "flex" ,
218- alignItems : "center" ,
219- justifyContent : "flex-end" ,
220- marginTop : "20px" ,
221- gap : "15px" ,
222- } }
223- >
224- < Button
225- id = { "clear" }
226- type = "button"
227- variant = "regular"
228- onClick = { resetForm }
229- label = { "Clear" }
230- />
231-
232- < Button
233- id = { "save-key" }
234- type = "submit"
235- variant = "callAction"
236- color = "primary"
237- disabled = { loading || ! validSave ( ) }
238- label = { "Save" }
239- />
240- </ Box >
241- </ Grid >
172+ < FormLayout helpBox = { helpBox } >
173+ < SectionTitle icon = { icon } > { title } </ SectionTitle >
174+ < form
175+ noValidate
176+ autoComplete = "off"
177+ onSubmit = { ( e : React . FormEvent < HTMLFormElement > ) => {
178+ addRecord ( e ) ;
179+ } }
180+ >
181+ < Grid container >
182+ < Grid xs = { 12 } item >
183+ { Object . entries ( extraFormFields ) . map ( ( [ key , value ] ) =>
184+ renderFormField ( key , value )
185+ ) }
186+ < Grid item xs = { 12 } sx = { modalStyleUtils . modalButtonBar } >
187+ < Button
188+ id = { "clear" }
189+ type = "button"
190+ variant = "regular"
191+ onClick = { resetForm }
192+ label = { "Clear" }
193+ />
194+
195+ < Button
196+ id = { "save-key" }
197+ type = "submit"
198+ variant = "callAction"
199+ color = "primary"
200+ disabled = { loading || ! validSave ( ) }
201+ label = { "Save" }
202+ />
242203 </ Grid >
243204 </ Grid >
244- </ form >
245- </ Box >
246- { helpBox }
247- </ Box >
205+ </ Grid >
206+ </ form >
207+ </ FormLayout >
248208 </ PageLayout >
249209 </ Grid >
250210 ) ;
251211} ;
252212
253- export default withStyles ( styles ) ( AddIDPConfiguration ) ;
213+ export default AddIDPConfiguration ;
0 commit comments