Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation to Alert Rule message templates #4479

Merged
merged 1 commit into from
Sep 24, 2018

Conversation

ebb-tide
Copy link
Contributor

@ebb-tide ebb-tide commented Sep 21, 2018

Closes #4398

What was the problem?
Kapacitor allows the creation of alert rules/tasks that can not be enabled.
When the alert rule builder sent the BE an alert rule with a message that contained improper templates, it would receive a 422 error (and display can't create alert to user), but the alert rule would still be created in the background.

What was the solution?
Require that the alert message be validated before the Save Rule button is enabled, and notify user that their message contains bad templates. REGEX TO THE MAX!

  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Rebased/mergeable
  • Tests pass
  • swagger.json updated (if modified Go structs or API)
  • Sign CLA (if not already signed)

Copy link
Contributor

@121watts 121watts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions. Otherwise :shipit:

return exactMatch || fuzzyMatch
}

const isValidMessage = (message: string): boolean => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a test for this function?

/>
</div>
)
const RuleMessageText: SFC<Props> = ({rule, updateMessage}) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this started out as an SFC, but I think this would be easier to read and extend if converted to a class with getters for textAreaClass, isValid, and removing the ternaries.

@ebb-tide ebb-tide force-pushed the bugfix/validate-alert-rule-messages branch from 456901b to 7e2c787 Compare September 24, 2018 17:52
@ebb-tide ebb-tide merged commit b6824a2 into master Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants