From 2e3fcbd86029dbf88202c4199cc62f432b5cbdcf Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Wed, 23 Jan 2019 15:16:36 +0100 Subject: [PATCH] unified navlink components --- .../navLinks/GeneralGroupNavLink.js | 27 +++++++++---------- .../repos/components/GeneralRepoNavLink.js | 12 ++++++--- .../components/navLinks/GeneralUserNavLink.js | 16 +++++------ 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/scm-ui/src/groups/components/navLinks/GeneralGroupNavLink.js b/scm-ui/src/groups/components/navLinks/GeneralGroupNavLink.js index 5b0528ba3a..b04e572937 100644 --- a/scm-ui/src/groups/components/navLinks/GeneralGroupNavLink.js +++ b/scm-ui/src/groups/components/navLinks/GeneralGroupNavLink.js @@ -1,29 +1,28 @@ //@flow import React from "react"; +import type { Group } from "@scm-manager/ui-types"; import { NavLink } from "@scm-manager/ui-components"; import { translate } from "react-i18next"; -import type { Group } from "@scm-manager/ui-types"; type Props = { - t: string => string, + group: Group, editUrl: string, - group: Group + t: string => string }; -type State = {}; - -class GeneralGroupNavLink extends React.Component { - render() { - const { t, editUrl } = this.props; - if (!this.isEditable()) { - return null; - } - return ; - } - +class GeneralGroupNavLink extends React.Component { isEditable = () => { return this.props.group._links.update; }; + + render() { + const { t, editUrl } = this.props; + + if (!this.isEditable()) { + return null; + } + return ; + } } export default translate("groups")(GeneralGroupNavLink); diff --git a/scm-ui/src/repos/components/GeneralRepoNavLink.js b/scm-ui/src/repos/components/GeneralRepoNavLink.js index a76231529b..650cf0f62c 100644 --- a/scm-ui/src/repos/components/GeneralRepoNavLink.js +++ b/scm-ui/src/repos/components/GeneralRepoNavLink.js @@ -1,20 +1,26 @@ //@flow import React from "react"; +import type { Repository } from "@scm-manager/ui-types"; import { NavLink } from "@scm-manager/ui-components"; import { translate } from "react-i18next"; -import type { Repository } from "@scm-manager/ui-types"; -type Props = { editUrl: string, t: string => string, repository: Repository }; +type Props = { + repository: Repository, + editUrl: string, + t: string => string +}; class GeneralRepoNavLink extends React.Component { isEditable = () => { return this.props.repository._links.update; }; + render() { + const { editUrl, t } = this.props; + if (!this.isEditable()) { return null; } - const { editUrl, t } = this.props; return ; } } diff --git a/scm-ui/src/users/components/navLinks/GeneralUserNavLink.js b/scm-ui/src/users/components/navLinks/GeneralUserNavLink.js index 417c9c76f6..e222a7bec2 100644 --- a/scm-ui/src/users/components/navLinks/GeneralUserNavLink.js +++ b/scm-ui/src/users/components/navLinks/GeneralUserNavLink.js @@ -1,28 +1,28 @@ //@flow import React from "react"; -import { translate } from "react-i18next"; import type { User } from "@scm-manager/ui-types"; import { NavLink } from "@scm-manager/ui-components"; +import { translate } from "react-i18next"; type Props = { - t: string => string, user: User, - editUrl: String + editUrl: String, + t: string => string }; class GeneralUserNavLink extends React.Component { + isEditable = () => { + return this.props.user._links.update; + }; + render() { const { t, editUrl } = this.props; if (!this.isEditable()) { return null; } - return ; + return ; } - - isEditable = () => { - return this.props.user._links.update; - }; } export default translate("users")(GeneralUserNavLink);