Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/disable alert configs #3416

Merged
merged 4 commits into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
1. [#3233](https://github.com/influxdata/chronograf/pull/3233): Add default retention policy field as option in source configuration for use in querying hosts from Host List page & Host pages
1. [#3290](https://github.com/influxdata/chronograf/pull/3290): Add support for PagerDuty v2 in UI
1. [#3369](https://github.com/influxdata/chronograf/pull/3369): Add support for OpsGenie v2 in UI
1. [#3416](https://github.com/influxdata/chronograf/pull/3416): Allow kapacitor services to be disabled

### UI Improvements

Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"webpack-dev-server": "^2.11.1"
},
"dependencies": {
"axios": "^0.13.1",
"axios": "^0.18.0",
"bignumber.js": "^4.0.2",
"calculate-size": "^1.1.1",
"chroma-js": "^1.3.6",
Expand Down
4 changes: 2 additions & 2 deletions ui/src/kapacitor/components/AlertTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class AlertTabs extends PureComponent<Props, State> {
return _.get(
sections,
[section, 'elements', '0', 'options', 'enabled'],
null
false
)
}

Expand Down Expand Up @@ -475,7 +475,7 @@ class AlertTabs extends PureComponent<Props, State> {
}

private sanitizeProperties = (section: string, properties: Props): Props => {
const cleanProps = {...properties, enabled: true}
const cleanProps = {enabled: true, ...properties}
const {redacted} = this.getSection(this.state.configSections, section)
if (redacted && redacted.length) {
redacted.forEach(badProp => {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/kapacitor/components/HandlerEmpty.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const HandlerEmpty = ({onGoToConfig, validationError}) => (
<div className="endpoint-tab-contents">
<div className="endpoint-tab--parameters">
<div className="endpoint-tab--parameters--empty">
<p>This handler has not been configured</p>
<p>This handler is not enabled</p>
<div className="form-group form-group-submit col-xs-12 text-center">
<button
className="btn btn-primary"
Expand Down
28 changes: 25 additions & 3 deletions ui/src/kapacitor/components/config/AlertaConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {PureComponent} from 'react'
import _ from 'lodash'
import React, {PureComponent, ChangeEvent} from 'react'

import RedactedInput from 'src/kapacitor/components/config/RedactedInput'
import {ErrorHandling} from 'src/shared/decorators/errors'
Expand All @@ -16,6 +17,7 @@ interface Config {
origin: string
token: boolean
url: string
enabled: boolean
}
}

Expand All @@ -28,6 +30,7 @@ interface Props {

interface State {
testEnabled: boolean
enabled: boolean
}

@ErrorHandling
Expand All @@ -41,12 +44,13 @@ class AlertaConfig extends PureComponent<Props, State> {
super(props)
this.state = {
testEnabled: this.props.enabled,
enabled: _.get(this.props, 'config.options.enabled', false),
}
}

public render() {
const {environment, origin, token, url} = this.props.config.options
const {testEnabled} = this.state
const {testEnabled, enabled} = this.state

return (
<form onSubmit={this.handleSubmit}>
Expand Down Expand Up @@ -97,6 +101,18 @@ class AlertaConfig extends PureComponent<Props, State> {
/>
</div>

<div className="form-group col-xs-12">
<div className="form-control-static">
<input
type="checkbox"
id="disabled"
checked={enabled}
onChange={this.handleEnabledChange}
/>
<label htmlFor="disabled">Configuration Enabled</label>
</div>
</div>

<div className="form-group form-group-submit col-xs-12 text-center">
<button
className="btn btn-primary"
Expand All @@ -108,7 +124,7 @@ class AlertaConfig extends PureComponent<Props, State> {
</button>
<button
className="btn btn-primary"
disabled={!this.state.testEnabled}
disabled={!this.state.testEnabled || !enabled}
onClick={this.props.onTest}
>
<span className="icon pulse-c" />
Expand All @@ -119,6 +135,11 @@ class AlertaConfig extends PureComponent<Props, State> {
)
}

private handleEnabledChange = (e: ChangeEvent<HTMLInputElement>) => {
this.setState({enabled: e.target.checked})
this.disableTest()
}

private handleSubmit = async e => {
e.preventDefault()

Expand All @@ -127,6 +148,7 @@ class AlertaConfig extends PureComponent<Props, State> {
origin: this.origin.value,
token: this.token.value,
url: this.url.value,
enabled: this.state.enabled,
}

const success = await this.props.onSave(properties)
Expand Down
28 changes: 25 additions & 3 deletions ui/src/kapacitor/components/config/HipChatConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {PureComponent} from 'react'
import _ from 'lodash'
import React, {PureComponent, ChangeEvent} from 'react'

import QuestionMarkTooltip from 'src/shared/components/QuestionMarkTooltip'
import {HIPCHAT_TOKEN_TIP} from 'src/kapacitor/copy'
Expand All @@ -16,6 +17,7 @@ interface Config {
room: string
token: boolean
url: string
enabled: boolean
}
}

Expand All @@ -28,6 +30,7 @@ interface Props {

interface State {
testEnabled: boolean
enabled: boolean
}

@ErrorHandling
Expand All @@ -40,13 +43,14 @@ class HipchatConfig extends PureComponent<Props, State> {
super(props)
this.state = {
testEnabled: this.props.enabled,
enabled: _.get(this.props, 'config.options.enabled', false),
}
}

public render() {
const {options} = this.props.config
const {url, room, token} = options
const {testEnabled} = this.state
const {testEnabled, enabled} = this.state

const subdomain = url
.replace('https://', '')
Expand Down Expand Up @@ -94,6 +98,18 @@ class HipchatConfig extends PureComponent<Props, State> {
/>
</div>

<div className="form-group col-xs-12">
<div className="form-control-static">
<input
type="checkbox"
id="disabled"
checked={enabled}
onChange={this.handleEnabledChange}
/>
<label htmlFor="disabled">Configuration Enabled</label>
</div>
</div>

<div className="form-group form-group-submit col-xs-12 text-center">
<button
className="btn btn-primary"
Expand All @@ -105,7 +121,7 @@ class HipchatConfig extends PureComponent<Props, State> {
</button>
<button
className="btn btn-primary"
disabled={!this.state.testEnabled}
disabled={!this.state.testEnabled || !enabled}
onClick={this.props.onTest}
>
<span className="icon pulse-c" />
Expand All @@ -116,13 +132,19 @@ class HipchatConfig extends PureComponent<Props, State> {
)
}

private handleEnabledChange = (e: ChangeEvent<HTMLInputElement>) => {
this.setState({enabled: e.target.checked})
this.disableTest()
}

private handleSubmit = async e => {
e.preventDefault()

const properties = {
room: this.room.value,
url: `https://${this.url.value}.hipchat.com/v2/room`,
token: this.token.value,
enabled: this.state.enabled,
}

const success = await this.props.onSave(properties)
Expand Down
28 changes: 25 additions & 3 deletions ui/src/kapacitor/components/config/OpsGenieConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {PureComponent} from 'react'
import _ from 'lodash'
import React, {PureComponent, ChangeEvent} from 'react'

import RedactedInput from 'src/kapacitor/components/config/RedactedInput'
import TagInput from 'src/shared/components/TagInput'
Expand All @@ -15,6 +16,7 @@ interface Config {
'api-key': boolean
teams: string[]
recipients: string[]
enabled: boolean
}
}

Expand All @@ -33,6 +35,7 @@ interface State {
currentTeams: string[]
currentRecipients: string[]
testEnabled: boolean
enabled: boolean
}

@ErrorHandling
Expand All @@ -48,13 +51,14 @@ class OpsGenieConfig extends PureComponent<Props, State> {
currentTeams: teams || [],
currentRecipients: recipients || [],
testEnabled: this.props.enabled,
enabled: _.get(this.props, 'config.options.enabled', false),
}
}

public render() {
const {options} = this.props.config
const apiKey = options['api-key']
const {testEnabled} = this.state
const {testEnabled, enabled} = this.state

return (
<form onSubmit={this.handleSubmit}>
Expand Down Expand Up @@ -84,6 +88,18 @@ class OpsGenieConfig extends PureComponent<Props, State> {
disableTest={this.disableTest}
/>

<div className="form-group col-xs-12">
<div className="form-control-static">
<input
type="checkbox"
id="disabled"
checked={enabled}
onChange={this.handleEnabledChange}
/>
<label htmlFor="disabled">Configuration Enabled</label>
</div>
</div>

<div className="form-group form-group-submit col-xs-12 text-center">
<button
className="btn btn-primary"
Expand All @@ -95,7 +111,7 @@ class OpsGenieConfig extends PureComponent<Props, State> {
</button>
<button
className="btn btn-primary"
disabled={!this.state.testEnabled}
disabled={!this.state.testEnabled || !enabled}
onClick={this.props.onTest}
>
<span className="icon pulse-c" />
Expand All @@ -106,6 +122,11 @@ class OpsGenieConfig extends PureComponent<Props, State> {
)
}

private handleEnabledChange = (e: ChangeEvent<HTMLInputElement>) => {
this.setState({enabled: e.target.checked})
this.disableTest()
}

private get currentTeamsForTags(): Item[] {
const {currentTeams} = this.state
return currentTeams.map(team => ({name: team}))
Expand All @@ -123,6 +144,7 @@ class OpsGenieConfig extends PureComponent<Props, State> {
'api-key': this.apiKey.value,
teams: this.state.currentTeams,
recipients: this.state.currentRecipients,
enabled: this.state.enabled,
}

const success = await this.props.onSave(properties)
Expand Down
28 changes: 25 additions & 3 deletions ui/src/kapacitor/components/config/PagerDutyConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {PureComponent} from 'react'
import _ from 'lodash'
import React, {PureComponent, ChangeEvent} from 'react'
import RedactedInput from 'src/kapacitor/components/config/RedactedInput'
import {ErrorHandling} from 'src/shared/decorators/errors'

Expand All @@ -11,6 +12,7 @@ interface Config {
options: {
'service-key': boolean
url: string
enabled: boolean
}
}

Expand All @@ -23,6 +25,7 @@ interface Props {

interface State {
testEnabled: boolean
enabled: boolean
}

@ErrorHandling
Expand All @@ -34,14 +37,15 @@ class PagerDutyConfig extends PureComponent<Props, State> {
super(props)
this.state = {
testEnabled: this.props.enabled,
enabled: _.get(this.props, 'config.options.enabled', false),
}
}

public render() {
const {options} = this.props.config
const {url} = options
const serviceKey = options['service-key']
const {testEnabled} = this.state
const {testEnabled, enabled} = this.state

return (
<form onSubmit={this.handleSubmit}>
Expand All @@ -68,6 +72,18 @@ class PagerDutyConfig extends PureComponent<Props, State> {
/>
</div>

<div className="form-group col-xs-12">
<div className="form-control-static">
<input
type="checkbox"
id="disabled"
checked={enabled}
onChange={this.handleEnabledChange}
/>
<label htmlFor="disabled">Configuration Enabled</label>
</div>
</div>

<div className="form-group form-group-submit col-xs-12 text-center">
<button
className="btn btn-primary"
Expand All @@ -79,7 +95,7 @@ class PagerDutyConfig extends PureComponent<Props, State> {
</button>
<button
className="btn btn-primary"
disabled={!this.state.testEnabled}
disabled={!this.state.testEnabled || !enabled}
onClick={this.props.onTest}
>
<span className="icon pulse-c" />
Expand All @@ -92,12 +108,18 @@ class PagerDutyConfig extends PureComponent<Props, State> {

private handleServiceKeyRef = r => (this.serviceKey = r)

private handleEnabledChange = (e: ChangeEvent<HTMLInputElement>) => {
this.setState({enabled: e.target.checked})
this.disableTest()
}

private handleSubmit = async e => {
e.preventDefault()

const properties = {
'service-key': this.serviceKey.value,
url: this.url.value,
enabled: this.state.enabled,
}

const success = await this.props.onSave(properties)
Expand Down
Loading