Ensure that multiple slack nodes are only available for kapacitor versions 1.5 and up
parent
eca3f5c707
commit
7a8f7139d3
|
@ -349,6 +349,19 @@ class AlertTabs extends PureComponent<Props, State> {
|
|||
/>
|
||||
)
|
||||
case AlertTypes.slack:
|
||||
const hasPagerDuty2: Section = get(
|
||||
configSections,
|
||||
AlertTypes.pagerduty2,
|
||||
undefined
|
||||
)
|
||||
const hasOpsGenie2: Section = get(
|
||||
configSections,
|
||||
AlertTypes.opsgenie2,
|
||||
undefined
|
||||
)
|
||||
// if kapacitor supports pagerduty2 and opsgenie2, its at least v1.5
|
||||
const isMultipleConfigsSupported: boolean =
|
||||
!_.isUndefined(hasPagerDuty2) && !_.isUndefined(hasOpsGenie2)
|
||||
return (
|
||||
<SlackConfigs
|
||||
configs={this.getSectionElements(configSections, AlertTypes.slack)}
|
||||
|
@ -359,8 +372,10 @@ class AlertTabs extends PureComponent<Props, State> {
|
|||
configSections,
|
||||
AlertTypes.slack
|
||||
)}
|
||||
isMultipleConfigsSupported={isMultipleConfigsSupported}
|
||||
/>
|
||||
)
|
||||
|
||||
case AlertTypes.smtp:
|
||||
return (
|
||||
<SMTPConfig
|
||||
|
|
|
@ -26,6 +26,7 @@ interface Props {
|
|||
specificConfigOptions: Partial<SlackProperties>
|
||||
) => void
|
||||
onEnabled: (specificConfig: string) => boolean
|
||||
isMultipleConfigsSupported: boolean
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
@ -47,7 +48,7 @@ class SlackConfigs extends PureComponent<Props, State> {
|
|||
|
||||
public render() {
|
||||
const {configs} = this.state
|
||||
const {onSave, onTest, onEnabled} = this.props
|
||||
const {onSave, onTest, onEnabled, isMultipleConfigsSupported} = this.props
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -72,11 +73,13 @@ class SlackConfigs extends PureComponent<Props, State> {
|
|||
/>
|
||||
)
|
||||
})}
|
||||
{isMultipleConfigsSupported && (
|
||||
<div className="form-group col-xs-12 text-center">
|
||||
<button className="btn btn-md btn-default" onClick={this.addConfig}>
|
||||
<span className="icon plus" /> Add Another Config
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -94,8 +97,12 @@ class SlackConfigs extends PureComponent<Props, State> {
|
|||
}
|
||||
|
||||
private getWorkspace = (config: Config): string => {
|
||||
const {isMultipleConfigsSupported} = this.props
|
||||
if (isMultipleConfigsSupported) {
|
||||
return get(config, 'options.workspace', 'new')
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
private getWorkspaceID = (config: Config): string => {
|
||||
if (this.isDefaultConfig(config)) {
|
||||
|
|
Loading…
Reference in New Issue