mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
added submenu, made sure submenu visibility is always up to date
This commit is contained in:
36
public/app/features/dashboard/components/SubMenu/SubMenu.tsx
Normal file
36
public/app/features/dashboard/components/SubMenu/SubMenu.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
// Libaries
|
||||
import React, { PureComponent } from 'react';
|
||||
|
||||
// Utils & Services
|
||||
import { AngularComponent, getAngularLoader } from 'app/core/services/AngularLoader';
|
||||
|
||||
// Types
|
||||
import { DashboardModel } from '../../state/DashboardModel';
|
||||
|
||||
export interface Props {
|
||||
dashboard: DashboardModel | null;
|
||||
}
|
||||
|
||||
export class SubMenu extends PureComponent<Props> {
|
||||
element: HTMLElement;
|
||||
angularCmp: AngularComponent;
|
||||
|
||||
componentDidMount() {
|
||||
const loader = getAngularLoader();
|
||||
|
||||
const template = '<dashboard-submenu dashboard="dashboard" />';
|
||||
const scopeProps = { dashboard: this.props.dashboard };
|
||||
|
||||
this.angularCmp = loader.load(this.element, scopeProps, template);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.angularCmp) {
|
||||
this.angularCmp.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div ref={element => this.element = element} />;
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export { SubMenuCtrl } from './SubMenuCtrl';
|
||||
export { SubMenu } from './SubMenu';
|
||||
|
||||
Reference in New Issue
Block a user