2019-10-20 18:02:52 +02:00
|
|
|
import React from "react";
|
|
|
|
|
import { Repository } from "@scm-manager/ui-types";
|
|
|
|
|
import { NavLink } from "@scm-manager/ui-components";
|
2018-09-27 16:32:37 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-10-19 16:38:07 +02:00
|
|
|
repository: Repository;
|
|
|
|
|
to: string;
|
|
|
|
|
label: string;
|
|
|
|
|
linkName: string;
|
|
|
|
|
activeWhenMatch?: (route: any) => boolean;
|
|
|
|
|
activeOnlyWhenExact: boolean;
|
2018-09-27 16:32:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Component renders only if the repository contains the link with the given name.
|
|
|
|
|
*/
|
|
|
|
|
class RepositoryNavLink extends React.Component<Props> {
|
|
|
|
|
render() {
|
2018-10-24 10:12:07 +02:00
|
|
|
const { repository, linkName } = this.props;
|
2018-09-27 16:32:37 +02:00
|
|
|
|
|
|
|
|
if (!repository._links[linkName]) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-24 10:12:07 +02:00
|
|
|
return <NavLink {...this.props} />;
|
2018-09-27 16:32:37 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default RepositoryNavLink;
|