2018-11-05 16:03:54 +01:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
Page,
|
|
|
|
|
Navigation,
|
|
|
|
|
Section,
|
|
|
|
|
MailLink
|
2018-11-07 12:55:09 +01:00
|
|
|
} from "../../../scm-ui-components/packages/ui-components/src/index";
|
2018-11-07 14:45:27 +01:00
|
|
|
import { NavLink, Route } from "react-router-dom";
|
2018-11-07 12:55:09 +01:00
|
|
|
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";
|
2018-11-07 12:55:09 +01:00
|
|
|
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-07 14:45:27 +01:00
|
|
|
import ChangeUserPassword from "./ChangeUserPassword";
|
|
|
|
|
import ProfileInfo from "./ProfileInfo";
|
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;
|
|
|
|
|
|
2018-11-07 14:45:27 +01:00
|
|
|
if (!me) {
|
2018-11-07 12:55:09 +01:00
|
|
|
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
|
|
|
}
|
2018-11-07 14:45:27 +01:00
|
|
|
|
2018-11-05 16:03:54 +01:00
|
|
|
return (
|
|
|
|
|
<Page title={me.displayName}>
|
2018-11-07 14:45:27 +01:00
|
|
|
<Route path={""} render={() => <ProfileInfo me={me} />} />
|
|
|
|
|
<Route path={"/password"} component={ChangeUserPassword} />
|
2018-11-05 16:03:54 +01:00
|
|
|
</Page>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
|
|
|
return {
|
|
|
|
|
me: getMe(state)
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default compose(
|
2018-11-07 12:55:09 +01:00
|
|
|
translate("commons"),
|
2018-11-05 16:03:54 +01:00
|
|
|
connect(mapStateToProps)
|
|
|
|
|
)(Profile);
|