From 8cade8458d0de5f9398daa2ff3ef0afc0a9386fd Mon Sep 17 00:00:00 2001 From: Iris Scholten Date: Wed, 9 May 2018 13:34:33 -0700 Subject: [PATCH] Change updateKapacitorConfigSection function so that if a specific config is passed, it updates that specific config and not just the default --- ui/src/kapacitor/components/AlertTabs.tsx | 6 ++++-- .../kapacitor/components/config/SlackConfig.tsx | 12 ++++++++++-- .../kapacitor/components/config/SlackConfigs.tsx | 6 +++++- ui/src/shared/apis/index.js | 15 ++++++++++++++- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/ui/src/kapacitor/components/AlertTabs.tsx b/ui/src/kapacitor/components/AlertTabs.tsx index 1fe8569fc8..54982c7757 100644 --- a/ui/src/kapacitor/components/AlertTabs.tsx +++ b/ui/src/kapacitor/components/AlertTabs.tsx @@ -480,7 +480,8 @@ class AlertTabs extends PureComponent { private handleSaveConfig = (section: string) => async ( properties, - isNewConfigInSection?: boolean + isNewConfigInSection?: boolean, + specificConfig?: string ): Promise => { if (section !== '') { const propsToSend = this.sanitizeProperties(section, properties) @@ -495,7 +496,8 @@ class AlertTabs extends PureComponent { await updateKapacitorConfigSection( this.props.kapacitor, section, - propsToSend + propsToSend, + specificConfig ) } this.refreshKapacitorConfig(this.props.kapacitor) diff --git a/ui/src/kapacitor/components/config/SlackConfig.tsx b/ui/src/kapacitor/components/config/SlackConfig.tsx index c9782c826d..e0b8cadc22 100644 --- a/ui/src/kapacitor/components/config/SlackConfig.tsx +++ b/ui/src/kapacitor/components/config/SlackConfig.tsx @@ -21,7 +21,11 @@ interface Config { interface Props { config: Config - onSave: (properties: Properties, isNewConfigInSection: boolean) => void + onSave: ( + properties: Properties, + isNewConfigInSection: boolean, + specificConfig: string + ) => void onTest: (event: React.MouseEvent) => void enabled: boolean isNewConfig: boolean @@ -159,7 +163,11 @@ class SlackConfig extends PureComponent { if (isNewConfig) { properties.workspace = this.workspace.value } - const success = await this.props.onSave(properties, isNewConfig) + const success = await this.props.onSave( + properties, + isNewConfig, + this.workspace.value + ) if (success) { this.setState({testEnabled: true}) } diff --git a/ui/src/kapacitor/components/config/SlackConfigs.tsx b/ui/src/kapacitor/components/config/SlackConfigs.tsx index 717de02089..786ac30bd0 100644 --- a/ui/src/kapacitor/components/config/SlackConfigs.tsx +++ b/ui/src/kapacitor/components/config/SlackConfigs.tsx @@ -21,7 +21,11 @@ interface Config { interface Props { slackConfigs: any[] config: Config - onSave: (properties: Properties, isNewConfigInSection: boolean) => void + onSave: ( + properties: Properties, + isNewConfigInSection: boolean, + specificConfig: string + ) => void onTest: (event: React.MouseEvent) => void enabled: boolean } diff --git a/ui/src/shared/apis/index.js b/ui/src/shared/apis/index.js index a692a52058..94cc8f0d30 100644 --- a/ui/src/shared/apis/index.js +++ b/ui/src/shared/apis/index.js @@ -155,12 +155,25 @@ export const getKapacitorConfigSection = (kapacitor, section) => { return kapacitorProxy(kapacitor, 'GET', `/kapacitor/v1/config/${section}`, '') } +<<<<<<< HEAD export function updateKapacitorConfigSection(kapacitor, section, properties) { const params = { +======= +export function updateKapacitorConfigSection( + kapacitor, + section, + properties, + specificConfig +) { + const config = specificConfig || '' + const path = `/kapacitor/v1/config/${section}/${config}` + + return AJAX({ +>>>>>>> Change updateKapacitorConfigSection function so that if a specific config is passed, it updates that specific config and not just the default method: 'POST', url: kapacitor.links.proxy, params: { - path: `/kapacitor/v1/config/${section}/`, + path, }, data: { set: properties,