Skip to content

Commit

Permalink
Add stronger types to PagerDuty2Config
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredscheib committed May 14, 2018
1 parent 02f0aee commit 13b6bda
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ui/src/kapacitor/components/config/PagerDuty2Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors'
interface Properties {
'routing-key': string
url: string
enabled: boolean
}

interface Config {
Expand Down Expand Up @@ -33,7 +34,7 @@ class PagerDuty2Config extends PureComponent<Props, State> {
private routingKey: HTMLInputElement
private url: HTMLInputElement

constructor(props) {
constructor(props: Props) {
super(props)
this.state = {
testEnabled: this.props.enabled,
Expand Down Expand Up @@ -106,17 +107,20 @@ class PagerDuty2Config extends PureComponent<Props, State> {
)
}

private handleRoutingKeyRef = r => (this.routingKey = r)
private handleRoutingKeyRef = (r: HTMLInputElement): HTMLInputElement =>
(this.routingKey = r)

private handleEnabledChange = (e: ChangeEvent<HTMLInputElement>) => {
private handleEnabledChange = (e: ChangeEvent<HTMLInputElement>): void => {
this.setState({enabled: e.target.checked})
this.disableTest()
}

private handleSubmit = async e => {
private handleSubmit = async (
e: React.FormEvent<HTMLFormElement>
): Promise<void> => {
e.preventDefault()

const properties = {
const properties: Properties = {
'routing-key': this.routingKey.value,
url: this.url.value,
enabled: this.state.enabled,
Expand All @@ -128,7 +132,7 @@ class PagerDuty2Config extends PureComponent<Props, State> {
}
}

private disableTest = () => {
private disableTest = (): void => {
this.setState({testEnabled: false})
}
}
Expand Down

0 comments on commit 13b6bda

Please sign in to comment.