diff --git a/ui/src/kapacitor/components/AlertTabs.tsx b/ui/src/kapacitor/components/AlertTabs.tsx index df7af573cb..0dec3b49a2 100644 --- a/ui/src/kapacitor/components/AlertTabs.tsx +++ b/ui/src/kapacitor/components/AlertTabs.tsx @@ -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 diff --git a/ui/src/kapacitor/components/config/SlackConfigs.tsx b/ui/src/kapacitor/components/config/SlackConfigs.tsx index 5659f89f57..03d7fc39f8 100644 --- a/ui/src/kapacitor/components/config/SlackConfigs.tsx +++ b/ui/src/kapacitor/components/config/SlackConfigs.tsx @@ -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> { /> ) })} - <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> + {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,7 +97,11 @@ class SlackConfigs extends PureComponent<Props, State> { } private getWorkspace = (config: Config): string => { - return get(config, 'options.workspace', 'new') + const {isMultipleConfigsSupported} = this.props + if (isMultipleConfigsSupported) { + return get(config, 'options.workspace', 'new') + } + return '' } private getWorkspaceID = (config: Config): string => {