Skip to content

Commit

Permalink
Merge pull request #24 from openimis/feature/OM-80
Browse files Browse the repository at this point in the history
OM-80: main contribution improvement, do not display password change …
  • Loading branch information
jdolkowski authored Jan 24, 2024
2 parents 17ec7ae + be1cf2c commit 38dd3b7
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/components/ProfileMainMenu.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -10,33 +13,48 @@ 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;
let entries = [
{
text: formatMessage(this.props.intl, "profile", "menu.myProfile"),
text: formatMessage(intl, "profile", "menu.myProfile"),
icon: <InsertEmoticon />,
route: "/profile/myProfile",
},
{
text: formatMessage(this.props.intl, "profile", "menu.changePassword"),
icon: <Fingerprint />,
route: "/profile/changePassword",
},
];

if (!this.isWorker) {
entries.push({
text: formatMessage(intl, "profile", "menu.changePassword"),
icon: <Fingerprint />,
route: "/profile/mobile/password",
});
}

entries.push(
...this.props.modulesManager
...modulesManager
.getContribs(PROFILE_MAIN_MENU_CONTRIBUTION_KEY)
.filter((c) => !c.filter || c.filter(rights))
);

return (
<MainMenuContribution
{...this.props}
header={formatMessage(this.props.intl, "profile", "mainMenu")}
header={formatMessage(intl, "profile", "mainMenu")}
icon={<AccountCircle />}
entries={entries}
/>
);
}
}
export default injectIntl(withModulesManager(ProfileMainMenu));

const mapStateToProps = (state) => ({
rights: state.core?.user?.i_user?.rights ?? [],
});

export default injectIntl(withModulesManager(connect(mapStateToProps)(ProfileMainMenu)));

0 comments on commit 38dd3b7

Please sign in to comment.