mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-27 09:49:09 +01:00
unified navlink components
This commit is contained in:
@@ -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<Props, State> {
|
||||
render() {
|
||||
const { t, editUrl } = this.props;
|
||||
if (!this.isEditable()) {
|
||||
return null;
|
||||
}
|
||||
return <NavLink label={t("singleGroup.menu.generalNavLink")} to={editUrl} />;
|
||||
}
|
||||
|
||||
class GeneralGroupNavLink extends React.Component<Props> {
|
||||
isEditable = () => {
|
||||
return this.props.group._links.update;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { t, editUrl } = this.props;
|
||||
|
||||
if (!this.isEditable()) {
|
||||
return null;
|
||||
}
|
||||
return <NavLink to={editUrl} label={t("singleGroup.menu.generalNavLink")} />;
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("groups")(GeneralGroupNavLink);
|
||||
|
||||
@@ -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<Props> {
|
||||
isEditable = () => {
|
||||
return this.props.repository._links.update;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { editUrl, t } = this.props;
|
||||
|
||||
if (!this.isEditable()) {
|
||||
return null;
|
||||
}
|
||||
const { editUrl, t } = this.props;
|
||||
return <NavLink to={editUrl} label={t("repositoryRoot.menu.generalNavLink")} />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Props> {
|
||||
isEditable = () => {
|
||||
return this.props.user._links.update;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { t, editUrl } = this.props;
|
||||
|
||||
if (!this.isEditable()) {
|
||||
return null;
|
||||
}
|
||||
return <NavLink label={t("singleUser.menu.generalNavLink")} to={editUrl} />;
|
||||
return <NavLink to={editUrl} label={t("singleUser.menu.generalNavLink")} />;
|
||||
}
|
||||
|
||||
isEditable = () => {
|
||||
return this.props.user._links.update;
|
||||
};
|
||||
}
|
||||
|
||||
export default translate("users")(GeneralUserNavLink);
|
||||
|
||||
Reference in New Issue
Block a user