Skip to content

Commit 803ffe2

Browse files
authored
Migrated OpenID module components to mds (#2925)
Signed-off-by: Benjamin Perez <[email protected]>
1 parent c96c959 commit 803ffe2

File tree

5 files changed

+156
-238
lines changed

5 files changed

+156
-238
lines changed

portal-ui/src/screens/Console/IDP/AddIDPConfiguration.tsx

Lines changed: 47 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,26 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
import 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";
2318
import {
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";
2928
import { useNavigate } from "react-router-dom";
3029
import { ErrorResponseHandler } from "../../../common/types";
3130
import { useAppDispatch } from "../../../store";
31+
import { modalStyleUtils } from "../Common/FormComponents/common/styleLibrary";
3232
import {
3333
setErrorSnackMessage,
3434
setHelpName,
3535
setServerNeedsRestart,
3636
} from "../../../systemSlice";
3737
import useApi from "../Common/Hooks/useApi";
38-
import SectionTitle from "../Common/SectionTitle";
39-
import FormSwitchWrapper from "../Common/FormComponents/FormSwitchWrapper/FormSwitchWrapper";
4038
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
4139
import 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-
6052
const 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;

portal-ui/src/screens/Console/IDP/AddIDPConfigurationHelpbox.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
import React, { Fragment } from "react";
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2023 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
216

3-
import { Box } from "@mui/material";
4-
import { HelpIconFilled } from "mds";
17+
import React, { Fragment } from "react";
18+
import { HelpIconFilled, Box } from "mds";
519

620
interface IContent {
721
icon: React.ReactNode;

portal-ui/src/screens/Console/IDP/DeleteIDPConfigurationModal.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,16 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import React from "react";
18-
19-
import { DialogContentText } from "@mui/material";
20-
import { ErrorResponseHandler } from "../../../common/types";
21-
import useApi from "../Common/Hooks/useApi";
22-
import ConfirmDialog from "../Common/ModalWrapper/ConfirmDialog";
17+
import React, { Fragment } from "react";
2318
import { ConfirmDeleteIcon } from "mds";
2419
import {
2520
setErrorSnackMessage,
2621
setServerNeedsRestart,
2722
} from "../../../systemSlice";
2823
import { useAppDispatch } from "../../../store";
24+
import { ErrorResponseHandler } from "../../../common/types";
25+
import useApi from "../Common/Hooks/useApi";
26+
import ConfirmDialog from "../Common/ModalWrapper/ConfirmDialog";
2927

3028
interface IDeleteIDPConfigurationModalProps {
3129
closeDeleteModalAndRefresh: (refresh: boolean) => void;
@@ -74,10 +72,10 @@ const DeleteIDPConfigurationModal = ({
7472
disabled: deleteLoading,
7573
}}
7674
confirmationContent={
77-
<DialogContentText>
75+
<Fragment>
7876
Are you sure you want to delete IDP <b>{displayName}</b>{" "}
7977
configuration? <br />
80-
</DialogContentText>
78+
</Fragment>
8179
}
8280
/>
8381
);

0 commit comments

Comments
 (0)