@@ -8,6 +8,7 @@ import { setSpecificServiceFilter } from "../slices/tableFilterSlice";
88import { getErrorCount , getHealthStatus } from "../selectors/healthSelectors" ;
99import {
1010 getOrgProperties ,
11+ getUserBasicInfo ,
1112 getUserInformation ,
1213} from "../selectors/userInfoSelectors" ;
1314import { availableHotkeys } from "../configs/hotkeysConfig" ;
@@ -26,6 +27,8 @@ import { ModalHandle } from "./shared/modals/Modal";
2627import { broadcastLogout } from "../utils/broadcastSync" ;
2728import BaseButton from "./shared/BaseButton" ;
2829import { LuBell , LuCheck , LuChevronDown , LuCirclePlay , LuMessageCircleQuestion , LuVideo } from "react-icons/lu" ;
30+ import { fetchUserDetails } from "../slices/userDetailsSlice" ;
31+ import ChangePasswordModal from "./shared/modals/ChangePassword" ;
2932
3033// References for detecting a click outside of the container of the dropdown menus
3134const containerLang = React . createRef < HTMLDivElement > ( ) ;
@@ -46,6 +49,7 @@ const Header = () => {
4649 const [ displayMenuHelp , setMenuHelp ] = useState ( false ) ;
4750 const registrationModalRef = useRef < ModalHandle > ( null ) ;
4851 const hotKeyCheatSheetModalRef = useRef < ModalHandle > ( null ) ;
52+ const changePasswordModalRef = useRef < ModalHandle > ( null ) ;
4953
5054 const healthStatus = useAppSelector ( state => getHealthStatus ( state ) ) ;
5155 const errorCounter = useAppSelector ( state => getErrorCount ( state ) ) ;
@@ -266,7 +270,11 @@ const Header = () => {
266270 < LuChevronDown className = "dropdown-icon" />
267271 </ BaseButton >
268272 { /* Click on username, a dropdown menu with the option to logout opens */ }
269- { displayMenuUser && < MenuUser /> }
273+ { displayMenuUser &&
274+ < MenuUser
275+ changePasswordRef = { changePasswordModalRef }
276+ />
277+ }
270278 </ div >
271279 </ nav >
272280 </ header >
@@ -279,6 +287,9 @@ const Header = () => {
279287
280288 { /* Hotkey Cheat Sheet */ }
281289 < HotKeyCheatSheet modalRef = { hotKeyCheatSheetModalRef } />
290+
291+ { /* Change Password Modal */ }
292+ < ChangePasswordModal modalRef = { changePasswordModalRef } />
282293 </ >
283294 ) ;
284295} ;
@@ -425,16 +436,35 @@ const MenuHelp = ({
425436 ) ;
426437} ;
427438
428- const MenuUser = ( ) => {
439+ const MenuUser = ( {
440+ changePasswordRef,
441+ } : {
442+ changePasswordRef : React . RefObject < ModalHandle | null >
443+ } ) => {
429444 const { t } = useTranslation ( ) ;
445+ const dispatch = useAppDispatch ( ) ;
446+
447+ const user = useAppSelector ( getUserBasicInfo ) ;
430448
431449 const logout = ( ) => {
432450 // Here we broadcast logout, in order to redirect other tabs to login page!
433451 broadcastLogout ( ) ;
434452 window . location . href = "/j_spring_security_logout" ;
435453 } ;
454+
455+ const showChangePasswordModal = async ( ) => {
456+ await dispatch ( fetchUserDetails ( user . username ) ) ;
457+
458+ changePasswordRef . current ?. open ( ) ;
459+ } ;
460+
436461 return (
437462 < ul className = "dropdown-ul" >
463+ < li >
464+ < ButtonLikeAnchor onClick = { ( ) => showChangePasswordModal ( ) } >
465+ < span > { t ( "USER_MENU.CHANGE_PASSWORD" ) } </ span >
466+ </ ButtonLikeAnchor >
467+ </ li >
438468 < li >
439469 < ButtonLikeAnchor onClick = { ( ) => logout ( ) } >
440470 < span className = "logout-icon" > { t ( "LOGOUT" ) } </ span >
0 commit comments