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