diff --git a/public/app/features/dashboard/dashgrid/DashboardRow.tsx b/public/app/features/dashboard/dashgrid/DashboardRow.tsx index 00999e4005e..3d4ec474886 100644 --- a/public/app/features/dashboard/dashgrid/DashboardRow.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardRow.tsx @@ -2,6 +2,7 @@ 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 { @@ -10,6 +11,9 @@ export interface DashboardRowProps { } export class DashboardRow extends React.Component { + dashboard: any; + panelContainer: any; + constructor(props) { super(props); @@ -17,15 +21,15 @@ export class DashboardRow extends React.Component { collapsed: this.props.panel.collapsed, }; + this.panelContainer = this.props.getPanelContainer(); + this.dashboard = this.panelContainer.getDashboard(); + this.toggle = this.toggle.bind(this); this.openSettings = this.openSettings.bind(this); } toggle() { - const panelContainer = this.props.getPanelContainer(); - const dashboard = panelContainer.getDashboard(); - - dashboard.toggleRow(this.props.panel); + this.dashboard.toggleRow(this.props.panel); this.setState(prevState => { return { collapsed: !prevState.collapsed }; @@ -72,13 +76,14 @@ export class DashboardRow extends React.Component { '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; return (
- {this.props.panel.title} + {title} ({hiddenPanels} hidden panels)
diff --git a/public/app/features/templating/all.ts b/public/app/features/templating/all.ts index 84ad8082c0b..c970b73fe59 100644 --- a/public/app/features/templating/all.ts +++ b/public/app/features/templating/all.ts @@ -1,7 +1,7 @@ import './editor_ctrl'; import coreModule from 'app/core/core_module'; -import { TemplateSrv } from './template_srv'; +import templateSrv from './template_srv'; import { VariableSrv } from './variable_srv'; import { IntervalVariable } from './interval_variable'; import { QueryVariable } from './query_variable'; @@ -10,10 +10,11 @@ import { CustomVariable } from './custom_variable'; import { ConstantVariable } from './constant_variable'; import { AdhocVariable } from './adhoc_variable'; -coreModule.service('templateSrv', TemplateSrv); +coreModule.factory('templateSrv', function() { + return templateSrv; +}); export { - TemplateSrv, VariableSrv, IntervalVariable, QueryVariable, diff --git a/public/app/features/templating/template_srv.ts b/public/app/features/templating/template_srv.ts index f499a24f848..85e2b672083 100644 --- a/public/app/features/templating/template_srv.ts +++ b/public/app/features/templating/template_srv.ts @@ -240,3 +240,5 @@ export class TemplateSrv { return value.join(','); } } + +export default new TemplateSrv();