Change updateKapacitorConfigSection function so that if a specific config is passed, it updates that specific config and not just the default

pull/10616/head
Iris Scholten 2018-05-09 13:34:33 -07:00
parent 21a7c65d05
commit 8cade8458d
4 changed files with 33 additions and 6 deletions

View File

@ -480,7 +480,8 @@ class AlertTabs extends PureComponent<Props, State> {
private handleSaveConfig = (section: string) => async (
properties,
isNewConfigInSection?: boolean
isNewConfigInSection?: boolean,
specificConfig?: string
): Promise<boolean> => {
if (section !== '') {
const propsToSend = this.sanitizeProperties(section, properties)
@ -495,7 +496,8 @@ class AlertTabs extends PureComponent<Props, State> {
await updateKapacitorConfigSection(
this.props.kapacitor,
section,
propsToSend
propsToSend,
specificConfig
)
}
this.refreshKapacitorConfig(this.props.kapacitor)

View File

@ -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<HTMLButtonElement>) => void
enabled: boolean
isNewConfig: boolean
@ -159,7 +163,11 @@ class SlackConfig extends PureComponent<Props, State> {
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})
}

View File

@ -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<HTMLButtonElement>) => void
enabled: boolean
}

View File

@ -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,