From 7c40496e2db32186e1948d767f6c77b52d1b5b54 Mon Sep 17 00:00:00 2001 From: Brandon Farmer Date: Tue, 17 Apr 2018 14:28:21 -0700 Subject: [PATCH] Add error handling to kapacitor components --- ui/src/kapacitor/components/AlertTabs.js | 2 ++ ui/src/kapacitor/components/HandlerOptions.js | 4 +++- ui/src/kapacitor/components/KapacitorRule.js | 2 ++ ui/src/kapacitor/components/NameSection.js | 2 ++ ui/src/kapacitor/components/RuleDetailsText.js | 2 ++ ui/src/kapacitor/components/RuleHandlers.js | 2 ++ ui/src/kapacitor/components/RuleHeader.js | 2 ++ ui/src/kapacitor/components/RuleMessage.js | 2 ++ ui/src/kapacitor/components/RuleMessageTemplates.js | 2 ++ ui/src/kapacitor/components/TickscriptEditor.js | 2 ++ ui/src/kapacitor/components/TickscriptID.js | 2 ++ ui/src/kapacitor/components/TickscriptSave.tsx | 2 ++ ui/src/kapacitor/components/config/AlertaConfig.tsx | 4 +++- ui/src/kapacitor/components/config/HipChatConfig.tsx | 4 +++- ui/src/kapacitor/components/config/OpsGenieConfig.tsx | 4 +++- ui/src/kapacitor/components/config/PagerDutyConfig.tsx | 4 +++- ui/src/kapacitor/components/config/PushoverConfig.tsx | 4 +++- ui/src/kapacitor/components/config/RedactedInput.tsx | 2 ++ ui/src/kapacitor/components/config/SMTPConfig.tsx | 2 ++ ui/src/kapacitor/components/config/SensuConfig.tsx | 2 ++ ui/src/kapacitor/components/config/SlackConfig.tsx | 4 +++- ui/src/kapacitor/components/config/TalkConfig.tsx | 4 +++- ui/src/kapacitor/components/config/TelegramConfig.tsx | 4 +++- ui/src/kapacitor/components/config/VictorOpsConfig.tsx | 4 +++- ui/src/kapacitor/containers/KapacitorPage.tsx | 2 ++ ui/src/kapacitor/containers/KapacitorRulePage.js | 2 ++ ui/src/kapacitor/containers/KapacitorRulesPage.tsx | 2 ++ ui/src/kapacitor/containers/TickscriptPage.tsx | 2 ++ 28 files changed, 66 insertions(+), 10 deletions(-) diff --git a/ui/src/kapacitor/components/AlertTabs.js b/ui/src/kapacitor/components/AlertTabs.js index f455bf3773..841cfce388 100644 --- a/ui/src/kapacitor/components/AlertTabs.js +++ b/ui/src/kapacitor/components/AlertTabs.js @@ -31,7 +31,9 @@ import { notifyTestAlertSent, notifyTestAlertFailed, } from 'shared/copy/notifications' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class AlertTabs extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/HandlerOptions.js b/ui/src/kapacitor/components/HandlerOptions.js index 67e39b1a00..eea9d8e0e3 100644 --- a/ui/src/kapacitor/components/HandlerOptions.js +++ b/ui/src/kapacitor/components/HandlerOptions.js @@ -16,8 +16,10 @@ import { TalkHandler, TelegramHandler, VictoropsHandler, -} from './handlers' +} from 'src/kapacitor/components/handlers' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class HandlerOptions extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/KapacitorRule.js b/ui/src/kapacitor/components/KapacitorRule.js index 6aa2909beb..3248f9673e 100644 --- a/ui/src/kapacitor/components/KapacitorRule.js +++ b/ui/src/kapacitor/components/KapacitorRule.js @@ -25,7 +25,9 @@ import { notifyAlertRuleRequiresConditionValue, notifyAlertRuleDeadmanInvalid, } from 'shared/copy/notifications' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class KapacitorRule extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/NameSection.js b/ui/src/kapacitor/components/NameSection.js index 025b18c27e..c4491e9a6e 100644 --- a/ui/src/kapacitor/components/NameSection.js +++ b/ui/src/kapacitor/components/NameSection.js @@ -1,7 +1,9 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import {DEFAULT_RULE_ID} from 'src/kapacitor/constants' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class NameSection extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/RuleDetailsText.js b/ui/src/kapacitor/components/RuleDetailsText.js index ba9a451ef5..38cab56095 100644 --- a/ui/src/kapacitor/components/RuleDetailsText.js +++ b/ui/src/kapacitor/components/RuleDetailsText.js @@ -1,6 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class RuleDetailsText extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/RuleHandlers.js b/ui/src/kapacitor/components/RuleHandlers.js index 3205da6030..4e6a7d5046 100644 --- a/ui/src/kapacitor/components/RuleHandlers.js +++ b/ui/src/kapacitor/components/RuleHandlers.js @@ -8,7 +8,9 @@ import Dropdown from 'shared/components/Dropdown' import {parseHandlersFromRule} from 'src/shared/parsing/parseHandlersFromRule' import {DEFAULT_HANDLERS} from 'src/kapacitor/constants' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class RuleHandlers extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/RuleHeader.js b/ui/src/kapacitor/components/RuleHeader.js index 19f95e31a7..9ecf4c2eba 100644 --- a/ui/src/kapacitor/components/RuleHeader.js +++ b/ui/src/kapacitor/components/RuleHeader.js @@ -1,7 +1,9 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import RuleHeaderSave from 'src/kapacitor/components/RuleHeaderSave' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class RuleHeader extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/RuleMessage.js b/ui/src/kapacitor/components/RuleMessage.js index d5da4f575e..1d871f00da 100644 --- a/ui/src/kapacitor/components/RuleMessage.js +++ b/ui/src/kapacitor/components/RuleMessage.js @@ -3,7 +3,9 @@ import PropTypes from 'prop-types' import RuleMessageText from 'src/kapacitor/components/RuleMessageText' import RuleMessageTemplates from 'src/kapacitor/components/RuleMessageTemplates' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class RuleMessage extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/RuleMessageTemplates.js b/ui/src/kapacitor/components/RuleMessageTemplates.js index 3b0fd01d27..5f6c1a663d 100644 --- a/ui/src/kapacitor/components/RuleMessageTemplates.js +++ b/ui/src/kapacitor/components/RuleMessageTemplates.js @@ -6,8 +6,10 @@ import ReactTooltip from 'react-tooltip' import CodeData from 'src/kapacitor/components/CodeData' import {RULE_MESSAGE_TEMPLATES} from 'src/kapacitor/constants' +import {ErrorHandling} from 'src/shared/decorators/errors' // needs to be React Component for CodeData click handler to work +@ErrorHandling class RuleMessageTemplates extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/TickscriptEditor.js b/ui/src/kapacitor/components/TickscriptEditor.js index fa35c3ca1c..fe8236821c 100644 --- a/ui/src/kapacitor/components/TickscriptEditor.js +++ b/ui/src/kapacitor/components/TickscriptEditor.js @@ -2,7 +2,9 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import {Controlled as CodeMirror} from 'react-codemirror2' import 'src/external/codemirror' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class TickscriptEditor extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/TickscriptID.js b/ui/src/kapacitor/components/TickscriptID.js index f618b72d24..7aaa0ceec9 100644 --- a/ui/src/kapacitor/components/TickscriptID.js +++ b/ui/src/kapacitor/components/TickscriptID.js @@ -1,6 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class TickscriptID extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/TickscriptSave.tsx b/ui/src/kapacitor/components/TickscriptSave.tsx index 2a12b468e8..5750cd7e24 100644 --- a/ui/src/kapacitor/components/TickscriptSave.tsx +++ b/ui/src/kapacitor/components/TickscriptSave.tsx @@ -1,5 +1,6 @@ import React, {PureComponent} from 'react' import {DBRP} from 'src/types/kapacitor' +import {ErrorHandling} from 'src/shared/decorators/errors' export interface Task { dbrps: DBRP[] @@ -13,6 +14,7 @@ interface SaveProps { unsavedChanges: boolean } +@ErrorHandling class TickscriptSave extends PureComponent { public render() { const {onSave} = this.props diff --git a/ui/src/kapacitor/components/config/AlertaConfig.tsx b/ui/src/kapacitor/components/config/AlertaConfig.tsx index 84a9eb4fc7..1bbcc57b8b 100644 --- a/ui/src/kapacitor/components/config/AlertaConfig.tsx +++ b/ui/src/kapacitor/components/config/AlertaConfig.tsx @@ -1,6 +1,7 @@ import React, {PureComponent} from 'react' -import RedactedInput from './RedactedInput' +import RedactedInput from 'src/kapacitor/components/config/RedactedInput' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { environment: string @@ -29,6 +30,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class AlertaConfig extends PureComponent { private environment: HTMLInputElement private origin: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/HipChatConfig.tsx b/ui/src/kapacitor/components/config/HipChatConfig.tsx index 2ce9b7090e..26875496cd 100644 --- a/ui/src/kapacitor/components/config/HipChatConfig.tsx +++ b/ui/src/kapacitor/components/config/HipChatConfig.tsx @@ -2,7 +2,8 @@ import React, {PureComponent} from 'react' import QuestionMarkTooltip from 'src/shared/components/QuestionMarkTooltip' import {HIPCHAT_TOKEN_TIP} from 'src/kapacitor/copy' -import RedactedInput from './RedactedInput' +import RedactedInput from 'src/kapacitor/components/config/RedactedInput' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { room: string @@ -29,6 +30,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class HipchatConfig extends PureComponent { private room: HTMLInputElement private token: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/OpsGenieConfig.tsx b/ui/src/kapacitor/components/config/OpsGenieConfig.tsx index f82b2b7f8c..81220edbc6 100644 --- a/ui/src/kapacitor/components/config/OpsGenieConfig.tsx +++ b/ui/src/kapacitor/components/config/OpsGenieConfig.tsx @@ -1,7 +1,8 @@ import React, {PureComponent} from 'react' -import RedactedInput from './RedactedInput' +import RedactedInput from 'src/kapacitor/components/config/RedactedInput' import TagInput from 'src/shared/components/TagInput' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { 'api-key': string @@ -34,6 +35,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class OpsGenieConfig extends PureComponent { private apiKey: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/PagerDutyConfig.tsx b/ui/src/kapacitor/components/config/PagerDutyConfig.tsx index a30c804f96..576a700a6b 100644 --- a/ui/src/kapacitor/components/config/PagerDutyConfig.tsx +++ b/ui/src/kapacitor/components/config/PagerDutyConfig.tsx @@ -1,5 +1,6 @@ import React, {PureComponent} from 'react' -import RedactedInput from './RedactedInput' +import RedactedInput from 'src/kapacitor/components/config/RedactedInput' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { 'service-key': string @@ -24,6 +25,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class PagerDutyConfig extends PureComponent { private serviceKey: HTMLInputElement private url: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/PushoverConfig.tsx b/ui/src/kapacitor/components/config/PushoverConfig.tsx index 1493c61fa8..91301df25d 100644 --- a/ui/src/kapacitor/components/config/PushoverConfig.tsx +++ b/ui/src/kapacitor/components/config/PushoverConfig.tsx @@ -1,7 +1,8 @@ import React, {PureComponent} from 'react' import QuestionMarkTooltip from 'src/shared/components/QuestionMarkTooltip' -import RedactedInput from './RedactedInput' +import RedactedInput from 'src/kapacitor/components/config/RedactedInput' +import {ErrorHandling} from 'src/shared/decorators/errors' import {PUSHOVER_DOCS_LINK} from 'src/kapacitor/copy' @@ -30,6 +31,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class PushoverConfig extends PureComponent { private token: HTMLInputElement private url: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/RedactedInput.tsx b/ui/src/kapacitor/components/config/RedactedInput.tsx index 235e0df176..f61bb41790 100644 --- a/ui/src/kapacitor/components/config/RedactedInput.tsx +++ b/ui/src/kapacitor/components/config/RedactedInput.tsx @@ -1,4 +1,5 @@ import React, {PureComponent} from 'react' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Props { id: string @@ -11,6 +12,7 @@ interface State { editing: boolean } +@ErrorHandling class RedactedInput extends PureComponent { constructor(props) { super(props) diff --git a/ui/src/kapacitor/components/config/SMTPConfig.tsx b/ui/src/kapacitor/components/config/SMTPConfig.tsx index db2a676473..50157f9b60 100644 --- a/ui/src/kapacitor/components/config/SMTPConfig.tsx +++ b/ui/src/kapacitor/components/config/SMTPConfig.tsx @@ -1,4 +1,5 @@ import React, {PureComponent} from 'react' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { host: string @@ -31,6 +32,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class SMTPConfig extends PureComponent { private host: HTMLInputElement private port: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/SensuConfig.tsx b/ui/src/kapacitor/components/config/SensuConfig.tsx index 112d344e86..2e91dd50d5 100644 --- a/ui/src/kapacitor/components/config/SensuConfig.tsx +++ b/ui/src/kapacitor/components/config/SensuConfig.tsx @@ -1,4 +1,5 @@ import React, {PureComponent} from 'react' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { source: string @@ -23,6 +24,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class SensuConfig extends PureComponent { private source: HTMLInputElement private addr: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/SlackConfig.tsx b/ui/src/kapacitor/components/config/SlackConfig.tsx index 36dc6f1acd..212a1fa377 100644 --- a/ui/src/kapacitor/components/config/SlackConfig.tsx +++ b/ui/src/kapacitor/components/config/SlackConfig.tsx @@ -1,5 +1,6 @@ import React, {PureComponent} from 'react' -import RedactedInput from './RedactedInput' +import RedactedInput from 'src/kapacitor/components/config/RedactedInput' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { channel: string @@ -24,6 +25,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class SlackConfig extends PureComponent { private url: HTMLInputElement private channel: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/TalkConfig.tsx b/ui/src/kapacitor/components/config/TalkConfig.tsx index 4c989d4073..0d4345a64c 100644 --- a/ui/src/kapacitor/components/config/TalkConfig.tsx +++ b/ui/src/kapacitor/components/config/TalkConfig.tsx @@ -1,6 +1,7 @@ import React, {PureComponent} from 'react' -import RedactedInput from './RedactedInput' +import RedactedInput from 'src/kapacitor/components/config/RedactedInput' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { url: string @@ -25,6 +26,7 @@ interface Props { enabled: boolean } +@ErrorHandling class TalkConfig extends PureComponent { private url: HTMLInputElement private author: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/TelegramConfig.tsx b/ui/src/kapacitor/components/config/TelegramConfig.tsx index 62ec64dd5e..27924ac8fa 100644 --- a/ui/src/kapacitor/components/config/TelegramConfig.tsx +++ b/ui/src/kapacitor/components/config/TelegramConfig.tsx @@ -2,7 +2,8 @@ import React, {PureComponent} from 'react' import QuestionMarkTooltip from 'src/shared/components/QuestionMarkTooltip' import {TELEGRAM_CHAT_ID_TIP, TELEGRAM_TOKEN_TIP} from 'src/kapacitor/copy' -import RedactedInput from './RedactedInput' +import RedactedInput from 'src/kapacitor/components/config/RedactedInput' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { 'chat-id': string @@ -33,6 +34,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class TelegramConfig extends PureComponent { private parseModeHTML: HTMLInputElement private parseModeMarkdown: HTMLInputElement diff --git a/ui/src/kapacitor/components/config/VictorOpsConfig.tsx b/ui/src/kapacitor/components/config/VictorOpsConfig.tsx index a3f458fcb0..477301073e 100644 --- a/ui/src/kapacitor/components/config/VictorOpsConfig.tsx +++ b/ui/src/kapacitor/components/config/VictorOpsConfig.tsx @@ -1,6 +1,7 @@ import React, {PureComponent} from 'react' -import RedactedInput from './RedactedInput' +import RedactedInput from 'src/kapacitor/components/config/RedactedInput' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Properties { 'api-key': string @@ -27,6 +28,7 @@ interface State { testEnabled: boolean } +@ErrorHandling class VictorOpsConfig extends PureComponent { private apiKey: HTMLInputElement private routingKey: HTMLInputElement diff --git a/ui/src/kapacitor/containers/KapacitorPage.tsx b/ui/src/kapacitor/containers/KapacitorPage.tsx index c0f447d42b..63de5f327c 100644 --- a/ui/src/kapacitor/containers/KapacitorPage.tsx +++ b/ui/src/kapacitor/containers/KapacitorPage.tsx @@ -24,6 +24,7 @@ import { notifyKapacitorUpdateFailed, notifyKapacitorUpdated, } from 'src/shared/copy/notifications' +import {ErrorHandling} from 'src/shared/decorators/errors' export const defaultName = 'My Kapacitor' export const kapacitorPort = '9092' @@ -64,6 +65,7 @@ interface State { exists: boolean } +@ErrorHandling export class KapacitorPage extends PureComponent { constructor(props) { super(props) diff --git a/ui/src/kapacitor/containers/KapacitorRulePage.js b/ui/src/kapacitor/containers/KapacitorRulePage.js index 70ad74dea9..78fa9db171 100644 --- a/ui/src/kapacitor/containers/KapacitorRulePage.js +++ b/ui/src/kapacitor/containers/KapacitorRulePage.js @@ -16,7 +16,9 @@ import { notifyKapacitorCreateFailed, notifyCouldNotFindKapacitor, } from 'shared/copy/notifications' +import {ErrorHandling} from 'src/shared/decorators/errors' +@ErrorHandling class KapacitorRulePage extends Component { constructor(props) { super(props) diff --git a/ui/src/kapacitor/containers/KapacitorRulesPage.tsx b/ui/src/kapacitor/containers/KapacitorRulesPage.tsx index d369f03b48..5663644765 100644 --- a/ui/src/kapacitor/containers/KapacitorRulesPage.tsx +++ b/ui/src/kapacitor/containers/KapacitorRulesPage.tsx @@ -12,6 +12,7 @@ import FancyScrollbar from 'src/shared/components/FancyScrollbar' import QuestionMarkTooltip from 'src/shared/components/QuestionMarkTooltip' import {Source, Kapacitor, AlertRule} from 'src/types' +import {ErrorHandling} from 'src/shared/decorators/errors' interface Props { source: Source @@ -29,6 +30,7 @@ interface State { loading: boolean } +@ErrorHandling export class KapacitorRulesPage extends PureComponent { constructor(props) { super(props) diff --git a/ui/src/kapacitor/containers/TickscriptPage.tsx b/ui/src/kapacitor/containers/TickscriptPage.tsx index 340d59af12..afa344639f 100644 --- a/ui/src/kapacitor/containers/TickscriptPage.tsx +++ b/ui/src/kapacitor/containers/TickscriptPage.tsx @@ -17,6 +17,7 @@ import { notifyTickscriptLoggingError, notifyKapacitorNotFound, } from 'src/shared/copy/notifications' +import {ErrorHandling} from 'src/shared/decorators/errors' interface ErrorActions { errorThrown: (notify: string | object) => void @@ -69,6 +70,7 @@ interface State { unsavedChanges: boolean } +@ErrorHandling export class TickscriptPage extends PureComponent { constructor(props) { super(props)