"atdb/git@git.astron.nl:astron-sdc/atdb-ldv.git" did not exist on "052ed683a26c1d78ee6502d08d3a6c894be21538"
-
Muthukrishnan authoredMuthukrishnan authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
AppMenu.js 3.79 KiB
import React, { Component } from 'react';
import {NavLink} from 'react-router-dom'
import PropTypes from 'prop-types';
import classNames from 'classnames';
class AppSubmenu extends Component {
static defaultProps = {
className: null,
items: null,
onMenuItemClick: null,
root: false,
permissions: null
}
static propTypes = {
className: PropTypes.string,
items: PropTypes.array,
onMenuItemClick: PropTypes.func,
root: PropTypes.bool,
permissions: PropTypes.array
}
constructor(props) {
super(props);
this.state = {activeIndex: null};
}
onMenuItemClick(event, item, index) {
//avoid processing disabled items
if(item.disabled) {
event.preventDefault();
return true;
}
//execute command
if(item.command) {
item.command({originalEvent: event, item: item});
}
if(index === this.state.activeIndex)
this.setState({activeIndex: null});
else
this.setState({activeIndex: index});
if(this.props.onMenuItemClick) {
this.props.onMenuItemClick({
originalEvent: event,
item: item
});
}
}
renderLinkContent(item) {
let submenuIcon = item.items && <i className="pi pi-fw pi-angle-down menuitem-toggle-icon"></i>;
let badge = item.badge && <span className="menuitem-badge">{item.badge}</span>;
return (
<React.Fragment>
<i className={item.icon}></i>
<span>{item.label}</span>
{submenuIcon}
{badge}
</React.Fragment>
);
}
renderLink(item, i) {
let content = this.renderLinkContent(item);