From 7a8f7139d3bfaf48cf17183d987ea3e6dcec6f89 Mon Sep 17 00:00:00 2001 From: Iris Scholten Date: Wed, 16 May 2018 10:37:57 -0700 Subject: [PATCH] Ensure that multiple slack nodes are only available for kapacitor versions 1.5 and up --- ui/src/kapacitor/components/AlertTabs.tsx | 15 +++++++++++++ .../components/config/SlackConfigs.tsx | 21 ++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) 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 { /> ) 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 ( { configSections, AlertTypes.slack )} + isMultipleConfigsSupported={isMultipleConfigsSupported} /> ) + case AlertTypes.smtp: return ( ) => void onEnabled: (specificConfig: string) => boolean + isMultipleConfigsSupported: boolean } interface State { @@ -47,7 +48,7 @@ class SlackConfigs extends PureComponent { public render() { const {configs} = this.state - const {onSave, onTest, onEnabled} = this.props + const {onSave, onTest, onEnabled, isMultipleConfigsSupported} = this.props return (
@@ -72,11 +73,13 @@ class SlackConfigs extends PureComponent { /> ) })} -
- -
+ {isMultipleConfigsSupported && ( +
+ +
+ )}
) } @@ -94,7 +97,11 @@ class SlackConfigs extends PureComponent { } 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 => {