From 3907ca1c3d1a587ab8ce112c9254d8c176e3a23e Mon Sep 17 00:00:00 2001 From: olewandowski1 Date: Wed, 17 Jan 2024 12:52:25 +0100 Subject: [PATCH 1/2] OM-80: main contribution improvement, do not display password change route --- src/components/ProfileMainMenu.js | 37 +++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/components/ProfileMainMenu.js b/src/components/ProfileMainMenu.js index ef36737..dddeebe 100644 --- a/src/components/ProfileMainMenu.js +++ b/src/components/ProfileMainMenu.js @@ -1,6 +1,9 @@ import React, { Component } from "react"; import { injectIntl } from "react-intl"; +import { connect } from "react-redux"; + import { AccountCircle, Fingerprint, InsertEmoticon } from "@material-ui/icons"; + import { formatMessage, MainMenuContribution, @@ -10,21 +13,32 @@ import { const PROFILE_MAIN_MENU_CONTRIBUTION_KEY = "profile.MainMenu"; class ProfileMainMenu extends Component { + constructor(props) { + super(props); + this.isWorker = props.modulesManager.getConf("fe-insuree", "isWorker", false); + } + render() { + const { rights, intl, modulesManager } = this.props; + console.log(this.isWorker); let entries = [ { - text: formatMessage(this.props.intl, "profile", "menu.myProfile"), + text: formatMessage(intl, "profile", "menu.myProfile"), icon: , route: "/profile/myProfile", }, - { - text: formatMessage(this.props.intl, "profile", "menu.changePassword"), - icon: , - route: "/profile/changePassword", - }, ]; + + if (!this.isWorker) { + entries.push({ + text: formatMessage(intl, "profile", "menu.changePassword"), + icon: , + route: "/profile/mobile/password", + }); + } + entries.push( - ...this.props.modulesManager + ...modulesManager .getContribs(PROFILE_MAIN_MENU_CONTRIBUTION_KEY) .filter((c) => !c.filter || c.filter(rights)) ); @@ -32,11 +46,16 @@ class ProfileMainMenu extends Component { return ( } entries={entries} /> ); } } -export default injectIntl(withModulesManager(ProfileMainMenu)); + +const mapStateToProps = (state) => ({ + rights: state.core?.user?.i_user?.rights ?? [], +}); + +export default injectIntl(withModulesManager(connect(mapStateToProps)(ProfileMainMenu))); From be1cf2c428871d5b5864e6dd7837e3a3f9e98c7a Mon Sep 17 00:00:00 2001 From: olewandowski1 Date: Wed, 24 Jan 2024 13:05:37 +0100 Subject: [PATCH 2/2] OM-80: delete console log --- src/components/ProfileMainMenu.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ProfileMainMenu.js b/src/components/ProfileMainMenu.js index dddeebe..51ac213 100644 --- a/src/components/ProfileMainMenu.js +++ b/src/components/ProfileMainMenu.js @@ -20,7 +20,6 @@ class ProfileMainMenu extends Component { render() { const { rights, intl, modulesManager } = this.props; - console.log(this.isWorker); let entries = [ { text: formatMessage(intl, "profile", "menu.myProfile"),