Files
SCM-Manager/scm-ui/ui-webapp/src/users/components/table/UserRow.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-03-13 12:07:18 +01:00
// @flow
import React from "react";
import { translate } from "react-i18next";
2019-03-13 12:07:18 +01:00
import { Link } from "react-router-dom";
import type { User } from "@scm-manager/ui-types";
import { Icon } from "@scm-manager/ui-components";
2019-03-13 12:07:18 +01:00
type Props = {
user: User,
// context props
t: string => string
2019-03-13 12:07:18 +01:00
};
class UserRow extends React.Component<Props> {
2019-03-13 12:07:18 +01:00
renderLink(to: string, label: string) {
return <Link to={to}>{label}</Link>;
}
render() {
const { user, t } = this.props;
2019-03-13 12:07:18 +01:00
const to = `/user/${user.name}`;
const iconType = user.active ? (
<Icon title={t("user.active")} name="user" />
) : (
<Icon title={t("user.inactive")} name="user-slash" />
);
2019-03-13 12:07:18 +01:00
return (
<tr className={user.active ? "border-is-green" : "border-is-yellow"}>
<td>{iconType} {this.renderLink(to, user.name)}</td>
<td className="is-hidden-mobile">
{this.renderLink(to, user.displayName)}
</td>
2019-03-13 12:07:18 +01:00
<td>
<a href={`mailto:${user.mail}`}>{user.mail}</a>
2019-03-13 12:07:18 +01:00
</td>
</tr>
);
}
}
export default translate("users")(UserRow);