Moved Profile component to top level; added error message

This commit is contained in:
Philipp Czora
2018-11-07 12:55:09 +01:00
parent 521f3dd9e9
commit 74382f26b7
3 changed files with 31 additions and 14 deletions

View File

@@ -38,5 +38,14 @@
"paginator": { "paginator": {
"next": "Next", "next": "Next",
"previous": "Previous" "previous": "Previous"
},
"profile": {
"actions-label": "Actions",
"username": "Username",
"displayName": "Display Name",
"mail": "E-Mail",
"change-password": "Change password",
"error-title": "Error",
"error-subtitle": "Cannot display profile"
} }
} }

View File

@@ -19,7 +19,7 @@ import SingleGroup from "../groups/containers/SingleGroup";
import AddGroup from "../groups/containers/AddGroup"; import AddGroup from "../groups/containers/AddGroup";
import Config from "../config/containers/Config"; import Config from "../config/containers/Config";
import Profile from "../users/containers/Profile"; import Profile from "./Profile";
type Props = { type Props = {
authenticated?: boolean authenticated?: boolean

View File

@@ -7,14 +7,15 @@ import {
Navigation, Navigation,
Section, Section,
MailLink MailLink
} from "@scm-manager/ui-components"; } from "../../../scm-ui-components/packages/ui-components/src/index";
import { NavLink } from "react-router-dom"; import { NavLink } from "react-router-dom";
import { getMe } from "../../modules/auth"; import { getMe } from "../modules/auth";
import { compose } from "redux"; import { compose } from "redux";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import type { Me } from "@scm-manager/ui-types"; import type { Me } from "../../../scm-ui-components/packages/ui-types/src/index";
import AvatarWrapper from "../../repos/components/changesets/AvatarWrapper"; import AvatarWrapper from "../repos/components/changesets/AvatarWrapper";
import { ErrorPage } from "@scm-manager/ui-components";
type Props = { type Props = {
me: Me, me: Me,
@@ -28,8 +29,14 @@ class Profile extends React.Component<Props, State> {
render() { render() {
const { me, t } = this.props; const { me, t } = this.props;
if (!me) { if (me) {
return null; return (
<ErrorPage
title={t("profile.error-title")}
subtitle={t("profile.error-subtitle")}
error={{ name: "Error", message: "'me' is undefined" }}
/>
);
} }
return ( return (
<Page title={me.displayName}> <Page title={me.displayName}>
@@ -41,7 +48,6 @@ class Profile extends React.Component<Props, State> {
{ {
// TODO: add avatar // TODO: add avatar
} }
}
</p> </p>
</figure> </figure>
</div> </div>
@@ -50,15 +56,15 @@ class Profile extends React.Component<Props, State> {
<table className="table"> <table className="table">
<tbody> <tbody>
<tr> <tr>
<td>{t("user.name")}</td> <td>{t("profile.username")}</td>
<td>{me.name}</td> <td>{me.name}</td>
</tr> </tr>
<tr> <tr>
<td>{t("user.displayName")}</td> <td>{t("profile.displayName")}</td>
<td>{me.displayName}</td> <td>{me.displayName}</td>
</tr> </tr>
<tr> <tr>
<td>{t("user.mail")}</td> <td>{t("profile.mail")}</td>
<td> <td>
<MailLink address={me.mail} /> <MailLink address={me.mail} />
</td> </td>
@@ -68,8 +74,10 @@ class Profile extends React.Component<Props, State> {
</div> </div>
<div className="column is-one-quarter"> <div className="column is-one-quarter">
<Navigation> <Navigation>
<Section label={t("single-user.actions-label")} /> <Section label={t("profile.actions-label")} />
<NavLink to={"me/password"}>{t("profile.change-pw")}</NavLink> <NavLink to={"me/password"}>
{t("profile.change-password")}
</NavLink>
</Navigation> </Navigation>
</div> </div>
</div> </div>
@@ -85,6 +93,6 @@ const mapStateToProps = state => {
}; };
export default compose( export default compose(
translate("users"), translate("commons"),
connect(mapStateToProps) connect(mapStateToProps)
)(Profile); )(Profile);