mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Footer: Single footer implementation for both react & angular pages * Export type * Updates * Use footer links in help menu * Updates & Fixes * Updated snapshot * updated snapshot
105 lines
3.0 KiB
TypeScript
105 lines
3.0 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import appEvents from '../../app_events';
|
|
import { User } from '../../services/context_srv';
|
|
import { NavModelItem } from '@grafana/data';
|
|
import { CoreEvents } from 'app/types';
|
|
import { OrgSwitcher } from '../OrgSwitcher';
|
|
import { getFooterLinks } from '../Footer/Footer';
|
|
|
|
export interface Props {
|
|
link: NavModelItem;
|
|
user: User;
|
|
}
|
|
|
|
interface State {
|
|
showSwitcherModal: boolean;
|
|
}
|
|
|
|
class BottomNavLinks extends PureComponent<Props, State> {
|
|
state: State = {
|
|
showSwitcherModal: false,
|
|
};
|
|
|
|
onOpenShortcuts = () => {
|
|
appEvents.emit(CoreEvents.showModal, {
|
|
templateHtml: '<help-modal></help-modal>',
|
|
});
|
|
};
|
|
|
|
toggleSwitcherModal = () => {
|
|
this.setState(prevState => ({
|
|
showSwitcherModal: !prevState.showSwitcherModal,
|
|
}));
|
|
};
|
|
|
|
render() {
|
|
const { link, user } = this.props;
|
|
const { showSwitcherModal } = this.state;
|
|
|
|
let children = link.children || [];
|
|
|
|
if (link.id === 'help') {
|
|
children = getFooterLinks();
|
|
}
|
|
|
|
return (
|
|
<div className="sidemenu-item dropdown dropup">
|
|
<a href={link.url} className="sidemenu-link" target={link.target}>
|
|
<span className="icon-circle sidemenu-icon">
|
|
{link.icon && <i className={link.icon} />}
|
|
{link.img && <img src={link.img} />}
|
|
</span>
|
|
</a>
|
|
<ul className="dropdown-menu dropdown-menu--sidemenu" role="menu">
|
|
{link.subTitle && (
|
|
<li className="sidemenu-subtitle">
|
|
<span className="sidemenu-item-text">{link.subTitle}</span>
|
|
</li>
|
|
)}
|
|
{link.showOrgSwitcher && (
|
|
<li className="sidemenu-org-switcher">
|
|
<a onClick={this.toggleSwitcherModal}>
|
|
<div>
|
|
<div className="sidemenu-org-switcher__org-name">{user.orgName}</div>
|
|
<div className="sidemenu-org-switcher__org-current">Current Org:</div>
|
|
</div>
|
|
<div className="sidemenu-org-switcher__switch">
|
|
<i className="fa fa-fw fa-random" />
|
|
Switch
|
|
</div>
|
|
</a>
|
|
</li>
|
|
)}
|
|
|
|
{showSwitcherModal && <OrgSwitcher onDismiss={this.toggleSwitcherModal} />}
|
|
|
|
{children.map((child, index) => {
|
|
return (
|
|
<li key={`${child.text}-${index}`}>
|
|
<a href={child.url} target="_blank" rel="noopener">
|
|
{child.icon && <i className={child.icon} />}
|
|
{child.text}
|
|
</a>
|
|
</li>
|
|
);
|
|
})}
|
|
|
|
{link.id === 'help' && (
|
|
<li key="keyboard-shortcuts">
|
|
<a onClick={() => this.onOpenShortcuts()}>
|
|
<i className="fa fa-keyboard-o" /> Keyboard shortcuts
|
|
</a>
|
|
</li>
|
|
)}
|
|
|
|
<li className="side-menu-header">
|
|
<span className="sidemenu-item-text">{link.text}</span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default BottomNavLinks;
|