2019-10-20 18:02:52 +02:00
|
|
|
import React from "react";
|
2019-10-23 15:47:08 +02:00
|
|
|
import { WithTranslation, withTranslation } from "react-i18next";
|
2019-10-20 18:02:52 +02:00
|
|
|
import { User } from "@scm-manager/ui-types";
|
|
|
|
|
import { NavLink } from "@scm-manager/ui-components";
|
2019-10-19 16:38:07 +02:00
|
|
|
|
2019-10-23 15:47:08 +02:00
|
|
|
type Props = WithTranslation & {
|
2019-10-19 16:38:07 +02:00
|
|
|
user: User;
|
|
|
|
|
passwordUrl: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ChangePasswordNavLink extends React.Component<Props> {
|
|
|
|
|
render() {
|
|
|
|
|
const { t, passwordUrl } = this.props;
|
|
|
|
|
|
|
|
|
|
if (!this.hasPermissionToSetPassword()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2019-10-21 10:57:56 +02:00
|
|
|
return <NavLink to={passwordUrl} label={t("singleUser.menu.setPasswordNavLink")} />;
|
2019-10-19 16:38:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hasPermissionToSetPassword = () => {
|
|
|
|
|
return this.props.user._links.password;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 15:47:08 +02:00
|
|
|
export default withTranslation("users")(ChangePasswordNavLink);
|