2019-02-04 04:19:45 -06:00
|
|
|
// 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() {
|
2019-02-13 04:14:53 -06:00
|
|
|
return <div ref={element => (this.element = element)} />;
|
2019-02-04 04:19:45 -06:00
|
|
|
}
|
|
|
|
}
|