Send notification when query text contains user-defined template variable

pull/10616/head
Alex P 2018-05-01 14:08:44 -07:00 committed by Iris Scholten
parent ab1838889a
commit 26bae2da6f
4 changed files with 18 additions and 0 deletions

View File

@ -44,8 +44,10 @@ import {
CellQuery,
Legend,
Status,
Notification,
} from 'src/types'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {notifyBuilderDisabled} from 'src/shared/copy/notifications'
const staticLegend: Legend = {
type: 'static',
@ -77,6 +79,7 @@ interface Props {
gaugeColors: ColorNumber[]
lineColors: ColorString[]
cell: Cell
notify: (notification: Notification) => void
}
interface State {
@ -367,6 +370,10 @@ class CellEditorOverlay extends Component<Props, State> {
const isUsingUserDefinedTempVars: boolean = !!userDefinedTempVarsInQuery.length
if (isUsingUserDefinedTempVars) {
this.props.notify(notifyBuilderDisabled())
}
try {
const selectedTempVars: Template[] = isUsingUserDefinedTempVars
? removeUnselectedTemplateValues(userDefinedTempVarsInQuery)

View File

@ -293,6 +293,7 @@ class DashboardPage extends Component {
const {zoomedTimeRange} = this.state
const {zoomedLower, zoomedUpper} = zoomedTimeRange
const {
notify,
source,
sources,
timeRange,
@ -398,6 +399,7 @@ class DashboardPage extends Component {
thresholdsListColors={thresholdsListColors}
gaugeColors={gaugeColors}
lineColors={lineColors}
notify={notify}
/>
) : null}
<DashboardHeader

View File

@ -438,6 +438,13 @@ export const notifyCellDeleted = name => ({
message: `Deleted "${name}" from dashboard.`,
})
export const notifyBuilderDisabled = () => ({
type: 'info',
icon: 'graphline',
duration: 7500,
message: `Your query contains a user-defined Template Variable. The Schema Explorer cannot render the query and is disabled.`,
})
// Rule Builder Notifications
// ----------------------------------------------------------------------------
export const notifyAlertRuleCreated = () => ({

View File

@ -11,6 +11,7 @@ import {
import {AlertRule, Kapacitor, Task} from './kapacitor'
import {Source, SourceLinks} from './sources'
import {DropdownAction, DropdownItem} from './shared'
import {Notification} from 'src/kapacitor/components/AlertOutputs'
export {
Me,
@ -35,4 +36,5 @@ export {
DropdownItem,
TimeRange,
Task,
Notification,
}