mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'react-mobx'
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import React from "react";
|
||||
import classNames from "classnames";
|
||||
import { PanelModel } from "../panel_model";
|
||||
import { PanelContainer } from "./PanelContainer";
|
||||
import templateSrv from "app/features/templating/template_srv";
|
||||
import appEvents from "app/core/app_events";
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { PanelModel } from '../panel_model';
|
||||
import { PanelContainer } from './PanelContainer';
|
||||
import templateSrv from 'app/features/templating/template_srv';
|
||||
import appEvents from 'app/core/app_events';
|
||||
|
||||
export interface DashboardRowProps {
|
||||
panel: PanelModel;
|
||||
@@ -18,7 +18,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
collapsed: this.props.panel.collapsed
|
||||
collapsed: this.props.panel.collapsed,
|
||||
};
|
||||
|
||||
this.panelContainer = this.props.getPanelContainer();
|
||||
@@ -38,22 +38,22 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
|
||||
}
|
||||
|
||||
openSettings() {
|
||||
appEvents.emit("show-modal", {
|
||||
appEvents.emit('show-modal', {
|
||||
templateHtml: `<row-options row="model.row" on-updated="model.onUpdated()" dismiss="dismiss()"></row-options>`,
|
||||
modalClass: "modal--narrow",
|
||||
modalClass: 'modal--narrow',
|
||||
model: {
|
||||
row: this.props.panel,
|
||||
onUpdated: this.forceUpdate.bind(this)
|
||||
}
|
||||
onUpdated: this.forceUpdate.bind(this),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
delete() {
|
||||
appEvents.emit("confirm-modal", {
|
||||
title: "Delete Row",
|
||||
text: "Are you sure you want to remove this row and all its panels?",
|
||||
altActionText: "Delete row only",
|
||||
icon: "fa-trash",
|
||||
appEvents.emit('confirm-modal', {
|
||||
title: 'Delete Row',
|
||||
text: 'Are you sure you want to remove this row and all its panels?',
|
||||
altActionText: 'Delete row only',
|
||||
icon: 'fa-trash',
|
||||
onConfirm: () => {
|
||||
const panelContainer = this.props.getPanelContainer();
|
||||
const dashboard = panelContainer.getDashboard();
|
||||
@@ -63,37 +63,30 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
|
||||
const panelContainer = this.props.getPanelContainer();
|
||||
const dashboard = panelContainer.getDashboard();
|
||||
dashboard.removeRow(this.props.panel, false);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const classes = classNames({
|
||||
"dashboard-row": true,
|
||||
"dashboard-row--collapsed": this.state.collapsed
|
||||
'dashboard-row': true,
|
||||
'dashboard-row--collapsed': this.state.collapsed,
|
||||
});
|
||||
const chevronClass = classNames({
|
||||
fa: true,
|
||||
"fa-chevron-down": !this.state.collapsed,
|
||||
"fa-chevron-right": this.state.collapsed
|
||||
'fa-chevron-down': !this.state.collapsed,
|
||||
'fa-chevron-right': this.state.collapsed,
|
||||
});
|
||||
|
||||
let title = templateSrv.replaceWithText(
|
||||
this.props.panel.title,
|
||||
this.props.panel.scopedVars
|
||||
);
|
||||
const hiddenPanels = this.props.panel.panels
|
||||
? this.props.panel.panels.length
|
||||
: 0;
|
||||
let title = templateSrv.replaceWithText(this.props.panel.title, this.props.panel.scopedVars);
|
||||
const hiddenPanels = this.props.panel.panels ? this.props.panel.panels.length : 0;
|
||||
|
||||
return (
|
||||
<div className={classes}>
|
||||
<a className="dashboard-row__title pointer" onClick={this.toggle}>
|
||||
<i className={chevronClass} />
|
||||
{title}
|
||||
<span className="dashboard-row__panel_count">
|
||||
({hiddenPanels} hidden panels)
|
||||
</span>
|
||||
<span className="dashboard-row__panel_count">({hiddenPanels} hidden panels)</span>
|
||||
</a>
|
||||
<div className="dashboard-row__actions">
|
||||
<a className="pointer" onClick={this.openSettings}>
|
||||
|
||||
Reference in New Issue
Block a user