Skip to content

Commit 39e94c8

Browse files
authored
Replaced Notification components with mds variants (#3103)
Replaced Notification components for mds variants - Updated Warning Message components - Replaced Snackbar component Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent 7010394 commit 39e94c8

File tree

13 files changed

+84
-311
lines changed

13 files changed

+84
-311
lines changed

portal-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"local-storage-fallback": "^4.1.1",
1818
"lodash": "^4.17.21",
1919
"luxon": "^3.4.3",
20-
"mds": "https://github.com/minio/mds.git#v0.10.0",
20+
"mds": "https://github.com/minio/mds.git#v0.10.1",
2121
"react": "^18.1.0",
2222
"react-component-export-image": "^1.0.6",
2323
"react-copy-to-clipboard": "^5.0.2",

portal-ui/src/screens/Console/Account/ChangePasswordModal.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
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, { useState } from "react";
17+
import React, { Fragment, useState } from "react";
1818
import {
1919
Button,
2020
ChangePasswordIcon,
2121
InputBox,
2222
Grid,
2323
FormLayout,
2424
ProgressBar,
25+
InformativeMessage,
2526
} from "mds";
2627
import ModalWrapper from "../Common/ModalWrapper/ModalWrapper";
2728

@@ -35,7 +36,6 @@ import { useAppDispatch } from "../../../store";
3536
import { api } from "api";
3637
import { AccountChangePasswordRequest, ApiError } from "api/consoleApi";
3738
import { errorToHandler } from "api/errors";
38-
import WarningMessage from "../Common/WarningMessage/WarningMessage";
3939

4040
interface IChangePasswordProps {
4141
open: boolean;
@@ -120,24 +120,24 @@ const ChangePassword = ({ open, closeModal }: IChangePasswordProps) => {
120120
This will change your Console password. Please note your new password
121121
down, as it will be required to log into Console after this session.
122122
</div>
123-
<WarningMessage
124-
title={""}
125-
label={
126-
<div>
127-
<div>
128-
If you are looking to change MINIO_ROOT_USER credentials, Please
129-
refer to{" "}
130-
<a
131-
target="_blank"
132-
rel="noopener"
133-
href="https://min.io/docs/minio/linux/administration/identity-access-management/minio-user-management.html#id4?ref=con"
134-
>
135-
rotating
136-
</a>{" "}
137-
credentials .
138-
</div>
139-
</div>
123+
<InformativeMessage
124+
variant={"warning"}
125+
title={"Warning"}
126+
message={
127+
<Fragment>
128+
If you are looking to change MINIO_ROOT_USER credentials, <br />
129+
Please refer to{" "}
130+
<a
131+
target="_blank"
132+
rel="noopener"
133+
href="https://min.io/docs/minio/linux/administration/identity-access-management/minio-user-management.html#id4?ref=con"
134+
>
135+
rotating
136+
</a>{" "}
137+
credentials.
138+
</Fragment>
140139
}
140+
sx={{ margin: "15px 0" }}
141141
/>
142142
<form
143143
noValidate

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/Preview/PreviewFileContent.tsx

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

1717
import React, { Fragment, useCallback, useEffect, useState } from "react";
18-
import { ProgressBar, Grid, Box } from "mds";
18+
import { ProgressBar, Grid, Box, InformativeMessage } from "mds";
1919
import get from "lodash/get";
2020
import { BucketObjectItem } from "../ListObjects/types";
2121
import { AllowedPreviews, previewObjectType } from "../utils";
2222
import { encodeURLString } from "../../../../../../common/utils";
2323
import { api } from "../../../../../../api";
24-
import WarningMessage from "../../../../Common/WarningMessage/WarningMessage";
2524

2625
interface IPreviewFileProps {
2726
bucketName: string;
@@ -177,10 +176,12 @@ const PreviewFile = ({
177176
)}
178177
{objectType === "none" && (
179178
<div>
180-
<WarningMessage
181-
label=" File couldn't be previewed using file extension or mime type. Please
179+
<InformativeMessage
180+
variant={"error"}
181+
message=" File couldn't be previewed using file extension or mime type. Please
182182
try Download instead"
183-
title="Preview unavailable "
183+
title="Preview unavailable"
184+
sx={{ margin: "15px 0" }}
184185
/>
185186
</div>
186187
)}

portal-ui/src/screens/Console/Common/FormComponents/common/styleLibrary.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -368,45 +368,6 @@ export const formFieldStyles: any = {
368368
},
369369
};
370370

371-
export const deleteDialogStyles: any = {
372-
root: {
373-
"& .MuiPaper-root": {
374-
padding: "1rem 2rem 2rem 1rem",
375-
},
376-
},
377-
title: {
378-
display: "flex",
379-
alignItems: "center",
380-
justifyContent: "space-between",
381-
},
382-
titleText: {
383-
fontSize: 20,
384-
fontWeight: 600,
385-
display: "flex",
386-
alignItems: "center",
387-
"& svg": {
388-
marginRight: 10,
389-
},
390-
wordBreak: "break-all",
391-
whiteSpace: "normal",
392-
},
393-
closeContainer: {
394-
"& .MuiIconButton-root": {
395-
top: -20,
396-
left: 30,
397-
position: "relative",
398-
padding: 1,
399-
"&:focus, &:hover": {
400-
background: "#EAEAEA",
401-
},
402-
},
403-
"& .min-icon": {
404-
height: 16,
405-
width: 16,
406-
},
407-
},
408-
};
409-
410371
export const modalStyleUtils: any = {
411372
modalButtonBar: {
412373
marginTop: 15,

portal-ui/src/screens/Console/Common/MainError/MainError.tsx

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

1717
import React, { useCallback, useEffect, useState } from "react";
18+
import { Snackbar } from "mds";
1819
import { useSelector } from "react-redux";
1920
import get from "lodash/get";
2021
import { AppState, useAppDispatch } from "../../../../store";
21-
22-
import { AlertCloseIcon, Box, breakPoints } from "mds";
23-
import { Portal } from "@mui/base";
2422
import {
2523
setErrorSnackMessage,
2624
setModalSnackMessage,
@@ -30,16 +28,6 @@ interface IMainErrorProps {
3028
isModal?: boolean;
3129
}
3230

33-
let timerI: any;
34-
35-
const startHideTimer = (callbackFunction: () => void) => {
36-
timerI = setInterval(callbackFunction, 10000);
37-
};
38-
39-
const stopHideTimer = () => {
40-
clearInterval(timerI);
41-
};
42-
4331
const MainError = ({ isModal = false }: IMainErrorProps) => {
4432
const dispatch = useAppDispatch();
4533
const snackBar = useSelector((state: AppState) => {
@@ -55,15 +43,13 @@ const MainError = ({ isModal = false }: IMainErrorProps) => {
5543
if (!displayErrorMsg) {
5644
dispatch(setErrorSnackMessage({ detailedError: "", errorMessage: "" }));
5745
dispatch(setModalSnackMessage(""));
58-
clearInterval(timerI);
5946
}
6047
}, [dispatch, displayErrorMsg]);
6148

6249
useEffect(() => {
6350
if (snackBar.message !== "" && snackBar.type === "error") {
6451
//Error message received, we trigger the animation
6552
setDisplayErrorMsg(true);
66-
startHideTimer(closeErrorMessage);
6753
}
6854
}, [closeErrorMessage, snackBar.message, snackBar.type]);
6955

@@ -75,91 +61,14 @@ const MainError = ({ isModal = false }: IMainErrorProps) => {
7561
}
7662

7763
return (
78-
<Portal>
79-
<Box
80-
sx={{
81-
"&.alert": {
82-
border: 0,
83-
left: 0,
84-
right: 0,
85-
top: 0,
86-
height: "75px",
87-
position: "fixed",
88-
color: "#ffffff",
89-
padding: "0 30px 0 30px",
90-
zIndex: 10000,
91-
display: "flex",
92-
justifyContent: "center",
93-
alignItems: "center",
94-
fontWeight: 600,
95-
backgroundColor: "#C72C48",
96-
opacity: 0,
97-
width: "100%",
98-
99-
"&.show": {
100-
opacity: 1,
101-
},
102-
},
103-
"& .message-text": {
104-
flex: 2,
105-
fontSize: "14px",
106-
textAlign: "center",
107-
[`@media (max-width: ${breakPoints.sm}px)`]: {
108-
textAlign: "left",
109-
},
110-
},
111-
112-
"& .close-btn-container": {
113-
cursor: "pointer",
114-
border: 0,
115-
display: "flex",
116-
alignItems: "center",
117-
justifyContent: "center",
118-
height: "100%",
119-
marginLeft: 0,
120-
[`@media (max-width: ${breakPoints.sm}px)`]: {
121-
marginLeft: 10,
122-
},
123-
124-
"& .close-btn": {
125-
display: "flex",
126-
alignItems: "center",
127-
justifyContent: "center",
128-
height: "23px",
129-
width: "23px",
130-
borderRadius: "50%",
131-
132-
border: 0,
133-
backgroundColor: "transparent",
134-
cursor: "pointer",
135-
136-
"&:hover,&:focus": {
137-
border: 0,
138-
outline: 0,
139-
backgroundColor: "#ba0202",
140-
},
141-
"& .min-icon": {
142-
height: "11px",
143-
width: "11px",
144-
fill: "#ffffff",
145-
},
146-
},
147-
},
148-
}}
149-
onMouseOver={stopHideTimer}
150-
onMouseLeave={() => startHideTimer(closeErrorMessage)}
151-
className={`alert ${displayErrorMsg ? "show" : ""}`}
152-
>
153-
<div className="message-text">
154-
{messageDetails ? messageDetails : `${message}.`}
155-
</div>
156-
<div className="close-btn-container">
157-
<button className="close-btn" autoFocus onClick={closeErrorMessage}>
158-
<AlertCloseIcon />
159-
</button>
160-
</div>
161-
</Box>
162-
</Portal>
64+
<Snackbar
65+
onClose={closeErrorMessage}
66+
open={displayErrorMsg}
67+
variant={"error"}
68+
message={messageDetails ? messageDetails : `${message}.`}
69+
autoHideDuration={10}
70+
closeButton
71+
/>
16372
);
16473
};
16574

portal-ui/src/screens/Console/Common/ModalWrapper/ModalWrapper.tsx

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,13 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
import React, { useEffect, useState } from "react";
1717
import { useSelector } from "react-redux";
18-
import Snackbar from "@mui/material/Snackbar";
19-
import { Theme } from "@mui/material/styles";
20-
import createStyles from "@mui/styles/createStyles";
21-
import withStyles from "@mui/styles/withStyles";
22-
import {
23-
deleteDialogStyles,
24-
snackBarCommon,
25-
} from "../FormComponents/common/styleLibrary";
18+
import { ModalBox, Snackbar } from "mds";
19+
import { CSSObject } from "styled-components";
2620
import { AppState, useAppDispatch } from "../../../../store";
27-
import MainError from "../MainError/MainError";
2821
import { setModalSnackMessage } from "../../../../systemSlice";
29-
import { ModalBox } from "mds";
30-
import { CSSObject } from "styled-components";
22+
import MainError from "../MainError/MainError";
3123

3224
interface IModalProps {
33-
classes: any;
3425
onClose: () => void;
3526
modalOpen: boolean;
3627
title: string | React.ReactNode;
@@ -41,18 +32,11 @@ interface IModalProps {
4132
sx?: CSSObject;
4233
}
4334

44-
const styles = (theme: Theme) =>
45-
createStyles({
46-
...deleteDialogStyles,
47-
...snackBarCommon,
48-
});
49-
5035
const ModalWrapper = ({
5136
onClose,
5237
modalOpen,
5338
title,
5439
children,
55-
classes,
5640
wideLimit = true,
5741
titleIcon = null,
5842
iconColor = "default",
@@ -111,26 +95,17 @@ const ModalWrapper = ({
11195
>
11296
<MainError isModal={true} />
11397
<Snackbar
98+
onClose={closeSnackBar}
11499
open={openSnackbar}
115-
className={classes.snackBarModal}
116-
onClose={() => {
117-
closeSnackBar();
118-
}}
119100
message={message}
120-
ContentProps={{
121-
className: `${classes.snackBar} ${
122-
modalSnackMessage && modalSnackMessage.type === "error"
123-
? classes.errorSnackBar
124-
: ""
125-
}`,
126-
}}
127-
autoHideDuration={
128-
modalSnackMessage && modalSnackMessage.type === "error" ? 10000 : 5000
129-
}
101+
mode={"inline"}
102+
variant={modalSnackMessage.type === "error" ? "error" : "default"}
103+
autoHideDuration={modalSnackMessage.type === "error" ? 10 : 5}
104+
condensed
130105
/>
131106
{children}
132107
</ModalBox>
133108
);
134109
};
135110

136-
export default withStyles(styles)(ModalWrapper);
111+
export default ModalWrapper;

0 commit comments

Comments
 (0)