grafana/public/app/features/dashboard/components/DashboardSettings/DashboardSettings.tsx
Ryan McKinley 96ba32d0c8
Add a @grafana/runtime package with backendSrv interface (#16533)
grafana-runtime/tsconfig.json imports query to avoid a build error  ¯\_(ツ)_/¯
2019-06-03 17:55:59 +02:00

37 lines
913 B
TypeScript

// Libaries
import React, { PureComponent } from 'react';
// Utils & Services
import { AngularComponent, getAngularLoader } from '@grafana/runtime';
// Types
import { DashboardModel } from '../../state/DashboardModel';
export interface Props {
dashboard: DashboardModel | null;
}
export class DashboardSettings extends PureComponent<Props> {
element: HTMLElement;
angularCmp: AngularComponent;
componentDidMount() {
const loader = getAngularLoader();
const template = '<dashboard-settings dashboard="dashboard" class="dashboard-settings" />';
const scopeProps = { dashboard: this.props.dashboard };
this.angularCmp = loader.load(this.element, scopeProps, template);
}
componentWillUnmount() {
if (this.angularCmp) {
this.angularCmp.destroy();
}
}
render() {
return <div className="panel-height-helper" ref={element => (this.element = element)} />;
}
}