diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0447b95be7..dd02a043bf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
### Features
1. [#2409](https://github.com/influxdata/chronograf/pull/2409): Allow adding multiple event handlers to a rule
1. [#2709](https://github.com/influxdata/chronograf/pull/2709): Add "send test alert" button to test kapacitor alert configurations"
+1. [#2708](https://github.com/influxdata/chronograf/pull/2708): Link to specified kapacitor config panel from rule builder alert handlers
### UI Improvements
1. [#2698](https://github.com/influxdata/chronograf/pull/2698): Improve clarity of terminology surrounding InfluxDB & Kapacitor connections
### Bug Fixes
diff --git a/ui/src/index.js b/ui/src/index.js
index 287d24a73d..31b1b20488 100644
--- a/ui/src/index.js
+++ b/ui/src/index.js
@@ -133,6 +133,10 @@ const Root = React.createClass({
+
diff --git a/ui/src/kapacitor/components/AlertTabs.js b/ui/src/kapacitor/components/AlertTabs.js
index 726eae8285..a427e7fdc2 100644
--- a/ui/src/kapacitor/components/AlertTabs.js
+++ b/ui/src/kapacitor/components/AlertTabs.js
@@ -27,7 +27,6 @@ class AlertTabs extends Component {
super(props)
this.state = {
- selectedHandler: 'smtp',
configSections: null,
}
}
@@ -42,18 +41,17 @@ class AlertTabs extends Component {
}
}
- refreshKapacitorConfig = kapacitor => {
- getKapacitorConfig(kapacitor)
- .then(({data: {sections}}) => {
- this.setState({configSections: sections})
- })
- .catch(() => {
- this.setState({configSections: null})
- this.props.addFlashMessage({
- type: 'error',
- text: 'There was an error getting the Kapacitor config',
- })
+ refreshKapacitorConfig = async kapacitor => {
+ try {
+ const {data: {sections}} = await getKapacitorConfig(kapacitor)
+ this.setState({configSections: sections})
+ } catch (error) {
+ this.setState({configSections: null})
+ this.props.addFlashMessage({
+ type: 'error',
+ text: 'There was an error getting the Kapacitor config',
})
+ }
}
getSection = (sections, section) => {
@@ -72,23 +70,26 @@ class AlertTabs extends Component {
return this.getSection(sections, section)
}
- handleSaveConfig = section => properties => {
+ handleSaveConfig = section => async properties => {
if (section !== '') {
const propsToSend = this.sanitizeProperties(section, properties)
- updateKapacitorConfigSection(this.props.kapacitor, section, propsToSend)
- .then(() => {
- this.refreshKapacitorConfig(this.props.kapacitor)
- this.props.addFlashMessage({
- type: 'success',
- text: `Alert configuration for ${section} successfully saved.`,
- })
+ try {
+ await updateKapacitorConfigSection(
+ this.props.kapacitor,
+ section,
+ propsToSend
+ )
+ this.refreshKapacitorConfig(this.props.kapacitor)
+ this.props.addFlashMessage({
+ type: 'success',
+ text: `Alert configuration for ${section} successfully saved.`,
})
- .catch(() => {
- this.props.addFlashMessage({
- type: 'error',
- text: `There was an error saving the alert configuration for ${section}.`,
- })
+ } catch (error) {
+ this.props.addFlashMessage({
+ type: 'error',
+ text: `There was an error saving the alert configuration for ${section}.`,
})
+ }
}
}
@@ -123,8 +124,14 @@ class AlertTabs extends Component {
return cleanProps
}
+ getInitialIndex = (supportedConfigs, hash) => {
+ const index = _.indexOf(_.keys(supportedConfigs), _.replace(hash, '#', ''))
+ return index >= 0 ? index : 0
+ }
+
render() {
const {configSections} = this.state
+ const {hash} = this.props
if (!configSections) {
return null
@@ -252,7 +259,6 @@ class AlertTabs extends Component {
/>,
},
}
-
return (
@@ -261,7 +267,10 @@ class AlertTabs extends Component {
-
+
{_.reduce(
configSections,
@@ -312,6 +321,7 @@ AlertTabs.propTypes = {
}).isRequired,
}),
addFlashMessage: func.isRequired,
+ hash: string.isRequired,
}
export default AlertTabs
diff --git a/ui/src/kapacitor/components/HandlerOptions.js b/ui/src/kapacitor/components/HandlerOptions.js
index 9a8861326b..5b2c6fdaea 100644
--- a/ui/src/kapacitor/components/HandlerOptions.js
+++ b/ui/src/kapacitor/components/HandlerOptions.js
@@ -65,7 +65,7 @@ class HandlerOptions extends Component {
)
@@ -85,7 +85,7 @@ class HandlerOptions extends Component {
)
@@ -94,7 +94,7 @@ class HandlerOptions extends Component {
)
@@ -103,7 +103,7 @@ class HandlerOptions extends Component {
)
@@ -112,7 +112,7 @@ class HandlerOptions extends Component {
)
@@ -121,7 +121,7 @@ class HandlerOptions extends Component {
)
@@ -130,7 +130,7 @@ class HandlerOptions extends Component {
)
@@ -139,7 +139,7 @@ class HandlerOptions extends Component {
)
@@ -148,7 +148,7 @@ class HandlerOptions extends Component {
)
@@ -157,7 +157,7 @@ class HandlerOptions extends Component {
)
diff --git a/ui/src/kapacitor/components/KapacitorForm.js b/ui/src/kapacitor/components/KapacitorForm.js
index 9395994120..c98326a4c7 100644
--- a/ui/src/kapacitor/components/KapacitorForm.js
+++ b/ui/src/kapacitor/components/KapacitorForm.js
@@ -109,7 +109,7 @@ class KapacitorForm extends Component {
// TODO: move these to another page. they dont belong on this page
renderAlertOutputs() {
- const {exists, kapacitor, addFlashMessage, source} = this.props
+ const {exists, kapacitor, addFlashMessage, source, hash} = this.props
if (exists) {
return (
@@ -117,6 +117,7 @@ class KapacitorForm extends Component {
source={source}
kapacitor={kapacitor}
addFlashMessage={addFlashMessage}
+ hash={hash}
/>
)
}
@@ -154,6 +155,7 @@ KapacitorForm.propTypes = {
source: shape({}).isRequired,
addFlashMessage: func.isRequired,
exists: bool.isRequired,
+ hash: string.isRequired,
}
export default KapacitorForm
diff --git a/ui/src/kapacitor/components/KapacitorRule.js b/ui/src/kapacitor/components/KapacitorRule.js
index bde83ec222..338a7b9426 100644
--- a/ui/src/kapacitor/components/KapacitorRule.js
+++ b/ui/src/kapacitor/components/KapacitorRule.js
@@ -75,10 +75,12 @@ class KapacitorRule extends Component {
})
}
- handleSaveToConfig = () => {
+ handleSaveToConfig = configName => () => {
const {rule, configLink, router} = this.props
if (this.validationError()) {
- router.push(configLink)
+ router.push({
+ pathname: `${configLink}#${configName}`,
+ })
} else if (rule.id === DEFAULT_RULE_ID) {
this.handleCreate(configLink)
} else {
diff --git a/ui/src/kapacitor/containers/KapacitorPage.js b/ui/src/kapacitor/containers/KapacitorPage.js
index 55b6c1c04d..4204d62dac 100644
--- a/ui/src/kapacitor/containers/KapacitorPage.js
+++ b/ui/src/kapacitor/containers/KapacitorPage.js
@@ -136,9 +136,9 @@ class KapacitorPage extends Component {
}
render() {
- const {source, addFlashMessage} = this.props
+ const {source, addFlashMessage, location, params} = this.props
+ const hash = (location && location.hash) || (params && params.hash) || ''
const {kapacitor, exists} = this.state
-
return (
)
}
@@ -168,6 +169,7 @@ KapacitorPage.propTypes = {
url: string.isRequired,
kapacitors: array,
}),
+ location: shape({pathname: string, hash: string}).isRequired,
}
export default withRouter(KapacitorPage)