mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55:44 +01:00
merge
This commit is contained in:
@@ -2,16 +2,23 @@
|
||||
import React from "react";
|
||||
|
||||
type Props = {
|
||||
icon?: string,
|
||||
label: string,
|
||||
action: () => void
|
||||
};
|
||||
|
||||
class NavAction extends React.Component<Props> {
|
||||
render() {
|
||||
const { label, action } = this.props;
|
||||
const { label, icon, action } = this.props;
|
||||
|
||||
let showIcon = null;
|
||||
if (icon) {
|
||||
showIcon = (<><i className={icon}></i>{" "}</>);
|
||||
}
|
||||
|
||||
return (
|
||||
<li>
|
||||
<a onClick={action}>{label}</a>
|
||||
<a onClick={action}>{showIcon}{label}</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {Link, Route} from "react-router-dom";
|
||||
|
||||
type Props = {
|
||||
to: string,
|
||||
icon?: string,
|
||||
label: string,
|
||||
activeOnlyWhenExact?: boolean,
|
||||
activeWhenMatch?: (route: any) => boolean
|
||||
@@ -23,10 +24,17 @@ class NavLink extends React.Component<Props> {
|
||||
}
|
||||
|
||||
renderLink = (route: any) => {
|
||||
const { to, label } = this.props;
|
||||
const { to, icon, label } = this.props;
|
||||
|
||||
let showIcon = null;
|
||||
if (icon) {
|
||||
showIcon = (<><i className={icon}></i>{" "}</>);
|
||||
}
|
||||
|
||||
return (
|
||||
<li>
|
||||
<Link className={this.isActive(route) ? "is-active" : ""} to={to}>
|
||||
{showIcon}
|
||||
{label}
|
||||
</Link>
|
||||
</li>
|
||||
@@ -35,6 +43,7 @@ class NavLink extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const { to, activeOnlyWhenExact } = this.props;
|
||||
|
||||
return (
|
||||
<Route path={to} exact={activeOnlyWhenExact} children={this.renderLink} />
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user