mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Types: Adds type safety to appEvents (#19418)
* Types: Add type safety to appEvents
This commit is contained in:
@@ -4,6 +4,7 @@ import { PanelModel } from '../../state/PanelModel';
|
||||
import { DashboardModel } from '../../state/DashboardModel';
|
||||
import templateSrv from 'app/features/templating/template_srv';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { CoreEvents } from 'app/types';
|
||||
|
||||
export interface DashboardRowProps {
|
||||
panel: PanelModel;
|
||||
@@ -18,11 +19,11 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
|
||||
collapsed: this.props.panel.collapsed,
|
||||
};
|
||||
|
||||
this.props.dashboard.on('template-variable-value-updated', this.onVariableUpdated);
|
||||
this.props.dashboard.on(CoreEvents.templateVariableValueUpdated, this.onVariableUpdated);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.dashboard.off('template-variable-value-updated', this.onVariableUpdated);
|
||||
this.props.dashboard.off(CoreEvents.templateVariableValueUpdated, this.onVariableUpdated);
|
||||
}
|
||||
|
||||
onVariableUpdated = () => {
|
||||
@@ -43,7 +44,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
|
||||
};
|
||||
|
||||
onOpenSettings = () => {
|
||||
appEvents.emit('show-modal', {
|
||||
appEvents.emit(CoreEvents.showModal, {
|
||||
templateHtml: `<row-options row="model.row" on-updated="model.onUpdated()" dismiss="dismiss()"></row-options>`,
|
||||
modalClass: 'modal--narrow',
|
||||
model: {
|
||||
@@ -54,7 +55,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
|
||||
};
|
||||
|
||||
onDelete = () => {
|
||||
appEvents.emit('confirm-modal', {
|
||||
appEvents.emit(CoreEvents.showConfirmModal, {
|
||||
title: 'Delete Row',
|
||||
text: 'Are you sure you want to remove this row and all its panels?',
|
||||
altActionText: 'Delete row only',
|
||||
|
||||
Reference in New Issue
Block a user