Add additional options to override for testing slack config
parent
7616e28b2e
commit
801cdc2992
|
@ -48,7 +48,7 @@ import DeprecationWarning from 'src/admin/components/DeprecationWarning'
|
||||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||||
|
|
||||||
import {Source, Kapacitor} from 'src/types'
|
import {Source, Kapacitor} from 'src/types'
|
||||||
import {ServiceProperties} from 'src/types/kapacitor'
|
import {ServiceProperties, SpecificConfigOptions} from 'src/types/kapacitor'
|
||||||
import SlackConfigs from 'src/kapacitor/components/config/SlackConfigs'
|
import SlackConfigs from 'src/kapacitor/components/config/SlackConfigs'
|
||||||
import {
|
import {
|
||||||
AlertDisplayText,
|
AlertDisplayText,
|
||||||
|
@ -513,7 +513,7 @@ class AlertTabs extends PureComponent<Props, State> {
|
||||||
|
|
||||||
private handleTestConfig = (section: string, options?: object) => async (
|
private handleTestConfig = (section: string, options?: object) => async (
|
||||||
e: MouseEvent<HTMLButtonElement>,
|
e: MouseEvent<HTMLButtonElement>,
|
||||||
specificConfig?: string
|
specificConfigOptions?: SpecificConfigOptions
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ class AlertTabs extends PureComponent<Props, State> {
|
||||||
this.props.kapacitor,
|
this.props.kapacitor,
|
||||||
section,
|
section,
|
||||||
options,
|
options,
|
||||||
specificConfig
|
specificConfigOptions
|
||||||
)
|
)
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
this.props.notify(notifyTestAlertSent(section))
|
this.props.notify(notifyTestAlertSent(section))
|
||||||
|
|
|
@ -19,7 +19,10 @@ interface Props {
|
||||||
isNewConfigInSection: boolean,
|
isNewConfigInSection: boolean,
|
||||||
specificConfig: string
|
specificConfig: string
|
||||||
) => void
|
) => void
|
||||||
onTest: (e: MouseEvent<HTMLButtonElement>, specificConfig: string) => void
|
onTest: (
|
||||||
|
e: MouseEvent<HTMLButtonElement>,
|
||||||
|
specificConfigOptions: Partial<SlackProperties>
|
||||||
|
) => void
|
||||||
onDelete: (specificConfig: string, workspaceID: string) => void
|
onDelete: (specificConfig: string, workspaceID: string) => void
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
isNewConfig: boolean
|
isNewConfig: boolean
|
||||||
|
@ -168,10 +171,10 @@ class SlackConfig extends PureComponent<Props, State> {
|
||||||
const {
|
const {
|
||||||
onTest,
|
onTest,
|
||||||
config: {
|
config: {
|
||||||
options: {workspace},
|
options: {workspace, channel},
|
||||||
},
|
},
|
||||||
} = this.props
|
} = this.props
|
||||||
onTest(e, workspace)
|
onTest(e, {workspace, channel})
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleEnabledChange = (e: ChangeEvent<HTMLInputElement>) => {
|
private handleEnabledChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|
|
@ -21,7 +21,10 @@ interface Props {
|
||||||
specificConfig: string
|
specificConfig: string
|
||||||
) => void
|
) => void
|
||||||
onDelete: (specificConfig: string) => void
|
onDelete: (specificConfig: string) => void
|
||||||
onTest: (e: MouseEvent<HTMLButtonElement>, specificConfig: string) => void
|
onTest: (
|
||||||
|
e: MouseEvent<HTMLButtonElement>,
|
||||||
|
specificConfigOptions: Partial<SlackProperties>
|
||||||
|
) => void
|
||||||
onEnabled: (specificConfig: string) => boolean
|
onEnabled: (specificConfig: string) => boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ export const testAlertOutput = async (
|
||||||
kapacitor,
|
kapacitor,
|
||||||
outputName,
|
outputName,
|
||||||
options,
|
options,
|
||||||
specificConfig
|
specificConfigOptions
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
|
@ -232,9 +232,11 @@ export const testAlertOutput = async (
|
||||||
} = await kapacitorProxy(kapacitor, 'GET', '/kapacitor/v1/service-tests')
|
} = await kapacitorProxy(kapacitor, 'GET', '/kapacitor/v1/service-tests')
|
||||||
const service = services.find(s => s.name === outputName)
|
const service = services.find(s => s.name === outputName)
|
||||||
|
|
||||||
let body = options
|
let body = {}
|
||||||
if (outputName === AlertTypes.slack) {
|
if (options) {
|
||||||
body = {workspace: specificConfig}
|
body = options
|
||||||
|
} else if (outputName === AlertTypes.slack) {
|
||||||
|
body = specificConfigOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
return kapacitorProxy(kapacitor, 'POST', service.link.href, body)
|
return kapacitorProxy(kapacitor, 'POST', service.link.href, body)
|
||||||
|
|
|
@ -401,3 +401,5 @@ export type ServiceProperties =
|
||||||
| TalkProperties
|
| TalkProperties
|
||||||
| TelegramProperties
|
| TelegramProperties
|
||||||
| VictorOpsProperties
|
| VictorOpsProperties
|
||||||
|
|
||||||
|
export type SpecificConfigOptions = Partial<SlackProperties>
|
||||||
|
|
Loading…
Reference in New Issue