2018-08-02 09:29:28 +02:00
|
|
|
//@flow
|
2018-08-31 10:47:42 +02:00
|
|
|
import React from "react";
|
2018-09-05 14:32:49 +02:00
|
|
|
import { NavLink } from "@scm-manager/ui-components";
|
2018-08-02 09:29:28 +02:00
|
|
|
import { translate } from "react-i18next";
|
2018-09-05 14:32:49 +02:00
|
|
|
import type { Group } from "@scm-manager/ui-types";
|
2018-08-02 09:29:28 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
t: string => string,
|
|
|
|
|
editUrl: string,
|
|
|
|
|
group: Group
|
2018-09-05 14:32:49 +02:00
|
|
|
};
|
2018-08-02 09:29:28 +02:00
|
|
|
|
2018-09-05 14:32:49 +02:00
|
|
|
type State = {};
|
2018-08-02 09:29:28 +02:00
|
|
|
|
2019-01-23 13:20:57 +01:00
|
|
|
class GeneralGroupNavLink extends React.Component<Props, State> {
|
2018-08-02 09:29:28 +02:00
|
|
|
render() {
|
|
|
|
|
const { t, editUrl } = this.props;
|
|
|
|
|
if (!this.isEditable()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2019-01-23 13:20:57 +01:00
|
|
|
return <NavLink label={t("singleGroup.menu.editNavLink")} to={editUrl} />;
|
2018-08-02 09:29:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isEditable = () => {
|
|
|
|
|
return this.props.group._links.update;
|
2018-09-05 14:32:49 +02:00
|
|
|
};
|
2018-08-02 09:29:28 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-23 13:20:57 +01:00
|
|
|
export default translate("groups")(GeneralGroupNavLink);
|