From 2747ce76c42ec6085874f7e5933a5708d75aeb98 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Tue, 13 Aug 2024 15:41:52 -0500 Subject: [PATCH 1/3] add warning mechanism --- src/actions/index.js | 14 ++++++++ src/components/HomePage.jsx | 6 ++++ src/components/children/WarningMessage.jsx | 42 ++++++++++++++++++++++ src/reducers/index.js | 4 ++- src/reducers/warning.js | 27 ++++++++++++++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/components/children/WarningMessage.jsx create mode 100644 src/reducers/warning.js diff --git a/src/actions/index.js b/src/actions/index.js index 3eaf7238..ea64c635 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -731,3 +731,17 @@ export async function getRepoVersion() { return githubVersionResponseFallback; } } + + + +export const OPEN_WARNING_MESSAGE = "OPEN_WARNING_MESSAGE"; +export const CLOSE_WARNING_MESSAGE = "CLOSE_WARNING_MESSAGE"; + +export const openWarningMessage = (message) => ({ + type: OPEN_WARNING_MESSAGE, + message: message, +}); + +export const closeWarningMessage = () => ({ + type: CLOSE_WARNING_MESSAGE, +}); diff --git a/src/components/HomePage.jsx b/src/components/HomePage.jsx index 57d46e04..cc2549b0 100644 --- a/src/components/HomePage.jsx +++ b/src/components/HomePage.jsx @@ -15,6 +15,7 @@ import QuestionAnswerIcon from "@material-ui/icons/QuestionAnswer"; import ArrowDropDownIcon from "@material-ui/icons/ArrowDropDown"; import ArrowDropUpIcon from "@material-ui/icons/ArrowDropUp"; import { trackPageview, trackEvent } from "./analytics"; +import { openWarningMessage } from "../../actions"; const useStyles = makeStyles((theme) => ({ root: { @@ -348,6 +349,7 @@ const HomePage = () => { }; const classes = useStyles(); + const dispatch = useDispatch(); React.useEffect(() => { getRepoVersion().then((data) => { @@ -355,6 +357,10 @@ const HomePage = () => { }); // Call trackPageview to track page view trackPageview(window.location.pathname); + + dispatch(openWarningMessage("NOTE: Changes were recently made to IN-CORE's user management system. " + + "If you were registered as an IN-CORE user before 08/21/2024 and are experiencing login issues, " + + "you need to reset your password.")); }, []); return ( diff --git a/src/components/children/WarningMessage.jsx b/src/components/children/WarningMessage.jsx new file mode 100644 index 00000000..10cbd3a3 --- /dev/null +++ b/src/components/children/WarningMessage.jsx @@ -0,0 +1,42 @@ +import React from "react"; +import { Alert } from "@material-ui/lab"; +import { Collapse, IconButton } from "@material-ui/core"; +import CloseIcon from "@material-ui/icons/Close"; +import { useDispatch, useSelector } from "react-redux"; +import { closeWarningMessage} from "../../actions"; + +const WarningMessage = () => { + + const dispatch = useDispatch(); + const { messageOpen, error, message } = useSelector( + (state) => state.warning + ); + + const handleClose = () => { + dispatch(closeWarningMessage()); + }; + + return ( + + + + + + + } + > + {message} + + + ); +}; + +export default ErrorMessage; diff --git a/src/reducers/index.js b/src/reducers/index.js index 1930540f..57bcaa62 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -9,6 +9,7 @@ import datatypes from "./datatypes"; import semantics from "./semantics"; import usage from "./usage"; import user from "./user.ts"; +import warning from "./warning"; const rootReducer = combineReducers({ routing: routerReducer, @@ -20,7 +21,8 @@ const rootReducer = combineReducers({ space: spaces, user: user, datatype: datatypes, - semantics: semantics + semantics: semantics, + warning: warning }); export default rootReducer; diff --git a/src/reducers/warning.js b/src/reducers/warning.js new file mode 100644 index 00000000..ed93f274 --- /dev/null +++ b/src/reducers/warning.js @@ -0,0 +1,27 @@ +import { OPEN_WARNING_MESSAGE, CLOSE_WARNING_MESSAGE } from "../actions/index"; + +const initialState = { + messageOpen: false, + message: "", +}; + +const warning = (state = initialState, action) => { + switch (action.type) { + case OPEN_WARNING_MESSAGE: + return { + ...state, + messageOpen: true, + message: action.message, + }; + case CLOSE_WARNING_MESSAGE: + return { + ...state, + messageOpen: false, + message: "", + }; + default: + return state; + } +}; + +export default warning; From ffa054c11e95d9e44e8b6b100ee058ee939c569b Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Tue, 13 Aug 2024 15:57:16 -0500 Subject: [PATCH 2/3] changelog; add message to config --- CHANGELOG.md | 3 +++ src/app.config.js | 6 +++++- src/components/HomePage.jsx | 9 +++++---- src/components/children/WarningMessage.jsx | 4 +--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 098c1c1e..1edee5d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added +- Warning on landing page notifying user to reset your password. [#215](https://github.com/IN-CORE/incore-ui/issues/215) + ### Changed - Restrict unapproved user from performing any action or accessing any resources. [#206](https://github.com/IN-CORE/incore-ui/issues/206) - Convert DataViewer and DFR3Viewer into Functional based components. [#183](https://github.com/IN-CORE/incore-ui/issues/183) diff --git a/src/app.config.js b/src/app.config.js index 3a012d3f..3dacbf6b 100644 --- a/src/app.config.js +++ b/src/app.config.js @@ -51,4 +51,8 @@ config["keycloakConfig"] = { clientId: config["client_id"] }; -export default config; \ No newline at end of file +config["resetPwWarningMessage"] = "NOTE: Changes were recently made to IN-CORE's user management system. If you were " + + "registered as an IN-CORE user before 08/21/2024 and are experiencing login issues, you need to reset your " + + "password."; + +export default config; diff --git a/src/components/HomePage.jsx b/src/components/HomePage.jsx index cc2549b0..f809648d 100644 --- a/src/components/HomePage.jsx +++ b/src/components/HomePage.jsx @@ -15,7 +15,9 @@ import QuestionAnswerIcon from "@material-ui/icons/QuestionAnswer"; import ArrowDropDownIcon from "@material-ui/icons/ArrowDropDown"; import ArrowDropUpIcon from "@material-ui/icons/ArrowDropUp"; import { trackPageview, trackEvent } from "./analytics"; -import { openWarningMessage } from "../../actions"; +import { openWarningMessage } from "../actions/index"; +import { WarningMessage } from "./children/WarningMessage"; +import { useDispatch } from "react-redux"; const useStyles = makeStyles((theme) => ({ root: { @@ -358,13 +360,12 @@ const HomePage = () => { // Call trackPageview to track page view trackPageview(window.location.pathname); - dispatch(openWarningMessage("NOTE: Changes were recently made to IN-CORE's user management system. " + - "If you were registered as an IN-CORE user before 08/21/2024 and are experiencing login issues, " + - "you need to reset your password.")); + dispatch(openWarningMessage(config.resetPwWarningMessage)); }, []); return (
+ {/*header*/}
diff --git a/src/components/children/WarningMessage.jsx b/src/components/children/WarningMessage.jsx index 10cbd3a3..519c9a17 100644 --- a/src/components/children/WarningMessage.jsx +++ b/src/components/children/WarningMessage.jsx @@ -5,7 +5,7 @@ import CloseIcon from "@material-ui/icons/Close"; import { useDispatch, useSelector } from "react-redux"; import { closeWarningMessage} from "../../actions"; -const WarningMessage = () => { +export const WarningMessage = () => { const dispatch = useDispatch(); const { messageOpen, error, message } = useSelector( @@ -38,5 +38,3 @@ const WarningMessage = () => { ); }; - -export default ErrorMessage; From ed726c0db22b3cfcf742418daf2068336cc46b13 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Tue, 13 Aug 2024 16:00:28 -0500 Subject: [PATCH 3/3] too much blank spaces --- src/actions/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index ea64c635..ba5dccd7 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -732,8 +732,6 @@ export async function getRepoVersion() { } } - - export const OPEN_WARNING_MESSAGE = "OPEN_WARNING_MESSAGE"; export const CLOSE_WARNING_MESSAGE = "CLOSE_WARNING_MESSAGE";