From 5e7739480ba8d93a58f0aea47d3c57766e7d2638 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Mon, 10 Aug 2020 09:28:54 +0200 Subject: [PATCH] cleanup --- scm-ui/ui-webapp/src/containers/Main.tsx | 7 ++++--- scm-ui/ui-webapp/src/containers/Profile.tsx | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scm-ui/ui-webapp/src/containers/Main.tsx b/scm-ui/ui-webapp/src/containers/Main.tsx index 03cb3262b1..0f1a3966d5 100644 --- a/scm-ui/ui-webapp/src/containers/Main.tsx +++ b/scm-ui/ui-webapp/src/containers/Main.tsx @@ -61,12 +61,12 @@ class Main extends React.Component { if (authenticated) { url = "/repos/"; } - if (!me) { - url = "/login"; - } if (redirectUrlFactory) { url = redirectUrlFactory(this.props); } + if (!me) { + url = "/login"; + } return (
@@ -95,6 +95,7 @@ class Main extends React.Component { renderAll={true} props={{ authenticated, + me, links }} /> diff --git a/scm-ui/ui-webapp/src/containers/Profile.tsx b/scm-ui/ui-webapp/src/containers/Profile.tsx index 56122d0c01..fd7118f7bb 100644 --- a/scm-ui/ui-webapp/src/containers/Profile.tsx +++ b/scm-ui/ui-webapp/src/containers/Profile.tsx @@ -23,7 +23,7 @@ */ import React from "react"; import { Route, RouteComponentProps, withRouter } from "react-router-dom"; -import { getMe, isAnonymous } from "../modules/auth"; +import { getMe } from "../modules/auth"; import { compose } from "redux"; import { connect } from "react-redux"; import { WithTranslation, withTranslation } from "react-i18next"; @@ -63,6 +63,11 @@ class Profile extends React.Component { return this.stripEndingSlash(this.props.match.url); }; + mayChangePassword = () => { + const { me } = this.props; + return !!me?._links?.password; + } + render() { const url = this.matchedUrl(); @@ -92,7 +97,7 @@ class Profile extends React.Component { } /> - {me?._links?.password && ( + {this.mayChangePassword() && ( } /> )} @@ -105,7 +110,7 @@ class Profile extends React.Component { label={t("profile.informationNavLink")} title={t("profile.informationNavLink")} /> - {!isAnonymous(me) && ( + {this.mayChangePassword() && (