mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
Fixed routing for profile page
This commit is contained in:
@@ -5,16 +5,14 @@ import React from "react";
|
|||||||
import {
|
import {
|
||||||
Page,
|
Page,
|
||||||
Navigation,
|
Navigation,
|
||||||
Section,
|
Section
|
||||||
MailLink
|
|
||||||
} from "../../../scm-ui-components/packages/ui-components/src/index";
|
} from "../../../scm-ui-components/packages/ui-components/src/index";
|
||||||
import { NavLink, Route } from "react-router-dom";
|
import { NavLink, Route, withRouter } 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-ui-components/packages/ui-types/src/index";
|
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";
|
import { ErrorPage } from "@scm-manager/ui-components";
|
||||||
import ChangeUserPassword from "./ChangeUserPassword";
|
import ChangeUserPassword from "./ChangeUserPassword";
|
||||||
import ProfileInfo from "./ProfileInfo";
|
import ProfileInfo from "./ProfileInfo";
|
||||||
@@ -23,12 +21,26 @@ type Props = {
|
|||||||
me: Me,
|
me: Me,
|
||||||
|
|
||||||
// Context props
|
// Context props
|
||||||
t: string => string
|
t: string => string,
|
||||||
|
match: any
|
||||||
};
|
};
|
||||||
type State = {};
|
type State = {};
|
||||||
|
|
||||||
class Profile extends React.Component<Props, State> {
|
class Profile extends React.Component<Props, State> {
|
||||||
|
stripEndingSlash = (url: string) => {
|
||||||
|
if (url.endsWith("/")) {
|
||||||
|
return url.substring(0, url.length - 2);
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
|
matchedUrl = () => {
|
||||||
|
return this.stripEndingSlash(this.props.match.url);
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const url = this.matchedUrl();
|
||||||
|
|
||||||
const { me, t } = this.props;
|
const { me, t } = this.props;
|
||||||
|
|
||||||
if (!me) {
|
if (!me) {
|
||||||
@@ -43,8 +55,24 @@ class Profile extends React.Component<Props, State> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Page title={me.displayName}>
|
<Page title={me.displayName}>
|
||||||
<Route path={""} render={() => <ProfileInfo me={me} />} />
|
<div className="columns">
|
||||||
<Route path={"/password"} component={ChangeUserPassword} />
|
<div className="column is-three-quarters">
|
||||||
|
<Route path={url} exact render={() => <ProfileInfo me={me} />} />
|
||||||
|
<Route
|
||||||
|
path={`${url}/password`}
|
||||||
|
exact
|
||||||
|
component={ChangeUserPassword}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="column">
|
||||||
|
<Navigation>
|
||||||
|
<Section label={t("profile.actions-label")} />
|
||||||
|
<NavLink to={`${url}/password`}>
|
||||||
|
{t("profile.change-password")}
|
||||||
|
</NavLink>
|
||||||
|
</Navigation>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -58,5 +86,6 @@ const mapStateToProps = state => {
|
|||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
translate("commons"),
|
translate("commons"),
|
||||||
connect(mapStateToProps)
|
connect(mapStateToProps),
|
||||||
|
withRouter
|
||||||
)(Profile);
|
)(Profile);
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import AvatarWrapper from "../repos/components/changesets/AvatarWrapper";
|
import AvatarWrapper from "../repos/components/changesets/AvatarWrapper";
|
||||||
import { NavLink } from "react-router-dom";
|
|
||||||
import type { Me } from "@scm-manager/ui-types";
|
import type { Me } from "@scm-manager/ui-types";
|
||||||
import { MailLink, Navigation, Section } from "@scm-manager/ui-components";
|
import { MailLink } from "@scm-manager/ui-components";
|
||||||
import { compose } from "redux";
|
import { compose } from "redux";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ class ProfileInfo extends React.Component<Props, State> {
|
|||||||
render() {
|
render() {
|
||||||
const { me, t } = this.props;
|
const { me, t } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className="columns">
|
<>
|
||||||
<AvatarWrapper>
|
<AvatarWrapper>
|
||||||
<div>
|
<div>
|
||||||
<figure className="media-left">
|
<figure className="media-left">
|
||||||
@@ -31,33 +30,25 @@ class ProfileInfo extends React.Component<Props, State> {
|
|||||||
</figure>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
</AvatarWrapper>
|
</AvatarWrapper>
|
||||||
<div className="column is-two-quarters">
|
<table className="table">
|
||||||
<table className="table">
|
<tbody>
|
||||||
<tbody>
|
<tr>
|
||||||
<tr>
|
<td>{t("profile.username")}</td>
|
||||||
<td>{t("profile.username")}</td>
|
<td>{me.name}</td>
|
||||||
<td>{me.name}</td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<td>{t("profile.displayName")}</td>
|
||||||
<td>{t("profile.displayName")}</td>
|
<td>{me.displayName}</td>
|
||||||
<td>{me.displayName}</td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<td>{t("profile.mail")}</td>
|
||||||
<td>{t("profile.mail")}</td>
|
<td>
|
||||||
<td>
|
<MailLink address={me.mail} />
|
||||||
<MailLink address={me.mail} />
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
</tbody>
|
||||||
</tbody>
|
</table>
|
||||||
</table>
|
</>
|
||||||
</div>
|
|
||||||
<div className="column is-one-quarter">
|
|
||||||
<Navigation>
|
|
||||||
<Section label={t("profile.actions-label")} />
|
|
||||||
<NavLink to={"password"}>{t("profile.change-password")}</NavLink>
|
|
||||||
</Navigation>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user