Files
SCM-Manager/scm-ui/ui-webapp/src/repos/components/RepositoryNavLink.tsx

30 lines
665 B
TypeScript
Raw Normal View History

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 = {
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() {
const { repository, linkName } = this.props;
2018-09-27 16:32:37 +02:00
if (!repository._links[linkName]) {
return null;
}
return <NavLink {...this.props} />;
2018-09-27 16:32:37 +02:00
}
}
export default RepositoryNavLink;