Files
SCM-Manager/scm-ui/src/containers/Profile.js

99 lines
2.5 KiB
JavaScript
Raw Normal View History

2018-11-05 16:03:54 +01:00
// @flow
import React from "react";
import {
Page,
Navigation,
Section,
MailLink
} from "../../../scm-ui-components/packages/ui-components/src/index";
2018-11-05 16:03:54 +01:00
import { NavLink } from "react-router-dom";
import { getMe } from "../modules/auth";
2018-11-05 16:03:54 +01:00
import { compose } from "redux";
import { connect } from "react-redux";
import { translate } from "react-i18next";
import type { Me } from "../../../scm-ui-components/packages/ui-types/src/index";
import AvatarWrapper from "../repos/components/changesets/AvatarWrapper";
import { ErrorPage } from "@scm-manager/ui-components";
2018-11-05 16:03:54 +01:00
type Props = {
me: Me,
// Context props
t: string => string
};
type State = {};
class Profile extends React.Component<Props, State> {
render() {
const { me, t } = this.props;
if (me) {
return (
<ErrorPage
title={t("profile.error-title")}
subtitle={t("profile.error-subtitle")}
error={{ name: "Error", message: "'me' is undefined" }}
/>
);
2018-11-05 16:03:54 +01:00
}
return (
<Page title={me.displayName}>
<div className="columns">
<AvatarWrapper>
<div>
<figure className="media-left">
<p className="image is-64x64">
{
// TODO: add avatar
}
</p>
</figure>
</div>
</AvatarWrapper>
<div className="column is-two-quarters">
<table className="table">
<tbody>
<tr>
<td>{t("profile.username")}</td>
2018-11-05 16:03:54 +01:00
<td>{me.name}</td>
</tr>
<tr>
<td>{t("profile.displayName")}</td>
2018-11-05 16:03:54 +01:00
<td>{me.displayName}</td>
</tr>
<tr>
<td>{t("profile.mail")}</td>
2018-11-05 16:03:54 +01:00
<td>
<MailLink address={me.mail} />
</td>
</tr>
</tbody>
</table>
</div>
<div className="column is-one-quarter">
<Navigation>
<Section label={t("profile.actions-label")} />
<NavLink to={"me/password"}>
{t("profile.change-password")}
</NavLink>
2018-11-05 16:03:54 +01:00
</Navigation>
</div>
</div>
</Page>
);
}
}
const mapStateToProps = state => {
return {
me: getMe(state)
};
};
export default compose(
translate("commons"),
2018-11-05 16:03:54 +01:00
connect(mapStateToProps)
)(Profile);