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

Fixes remaining bugs with multi slack handlers #3482

Merged
merged 1 commit into from
May 17, 2018

Conversation

bthesorceror
Copy link
Contributor

@bthesorceror bthesorceror commented May 17, 2018

Closes #2855

  • Rebased/mergeable
  • Tests pass
  • Sign CLA (if not already signed)

@bthesorceror bthesorceror force-pushed the fixes/continue-multiple-slack branch from b35124a to 1fa445c Compare May 17, 2018 17:39
@jaredscheib jaredscheib self-requested a review May 17, 2018 17:41
Copy link
Contributor

@jaredscheib jaredscheib left a comment

Choose a reason for hiding this comment

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

Looks good generally. Some ideas / clarifications / comments below. Nice work!

const {error} = data
if (!error) {
this.props.notify(
notifyAlertEndpointSaveFailed(section, 'Cannot save configuration')
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason why it can't save? this is more of a ux thing, but i could see a user not understanding why it couldn't save, so if there's any further specificity here possible, what do you think about adding it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we just get a 502 back from Kapa with no additional information.

Copy link
Contributor

Choose a reason for hiding this comment

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

word

</li>
))}
{handlersOnThisAlert.map(endpoint => {
return (
Copy link
Contributor

Choose a reason for hiding this comment

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

word. i'm preferring this, much like getting rid of ternaries.

key={uuid.v4()}
className={classnames('endpoint-tab', {
active:
endpoint.alias === (selectedHandler && selectedHandler.alias),
Copy link
Contributor

Choose a reason for hiding this comment

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

i appreciate this clarification of the var name.

kapacitor.go Outdated
@@ -117,6 +117,7 @@ type Slack struct {
Channel string `json:"channel"` // Slack channel in which to post messages.
Username string `json:"username"` // Username of the Slack bot.
IconEmoji string `json:"iconEmoji"` // IconEmoji is an emoji name surrounded in ':' characters; The emoji image will replace the normal user icon for the slack bot.
Workspace string `json:"workspace"`
Copy link
Contributor

Choose a reason for hiding this comment

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

possibly a comment to contextualize?


constructor(props) {
super(props)
this.state = {
testEnabled: this.props.enabled,
enabled: _.get(this.props, 'config.options.enabled', false),
workspace: _.get(this.props, 'config.options.workspace', '') || '',
Copy link
Contributor

Choose a reason for hiding this comment

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

the go struct for this seems to imply without omitempty that it will always be present as the field type's zero-value (''), so is it possible for there to not be a workspace?) could assurances be made on the backend to prevent the need for this _.get and || '' and the _.get on enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we get back a object that has {workspace: null} at this point so the _.get will just return the null and not the default since the key is present.

Copy link
Contributor

@jaredscheib jaredscheib May 17, 2018

Choose a reason for hiding this comment

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

you get null back from the server when it's a string type?

if (isNewConfig) {
properties.workspace = this.workspace.value
properties.workspace = workspace
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. a bit strange seeing a value on an object being assigned directly -- could a spread operator be used here?
  2. also in the context of all of these getters, this reads a bit weird to me -- what do you think about workspace --> this.workspace and putting workspace behind a getter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we only want to send the workspace on create, for updates we want to omit the key altogether.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

if (success) {
this.setState({testEnabled: true})
}
}

private handleDelete = async e => {
e.preventDefault()
await this.props.onDelete(this.workspace.value, this.workspaceID)
const {workspace} = this.state
Copy link
Contributor

Choose a reason for hiding this comment

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

see question above about a possible getter

@@ -73,7 +74,7 @@ class SlackConfigs extends PureComponent<Props, State> {
/>
)
})}
{isMultipleConfigsSupported && (
{this.isAddAllowed && (
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not clear to me what isAddAllowed would mean, semantically -- would you consider preserving some of the self-awareness around config, such as isConfigAddAllowed?

private get isAddAllowed(): boolean {
const {isMultipleConfigsSupported} = this.props
const {configs} = this.state
const allExisting = _.every(configs, c => !this.isNewConfig(c))
Copy link
Contributor

Choose a reason for hiding this comment

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

could you clarify what allExisting refers to, such as allExistingConfigs?

@@ -99,7 +108,13 @@ class SlackConfigs extends PureComponent<Props, State> {
private getWorkspace = (config: Config): string => {
const {isMultipleConfigsSupported} = this.props
if (isMultipleConfigsSupported) {
return get(config, 'options.workspace', 'new')
const workspace = _.get(config, 'options', {workspace: null}).workspace
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting

@bthesorceror bthesorceror force-pushed the fixes/continue-multiple-slack branch from 1fa445c to d0ff7a4 Compare May 17, 2018 18:37
- Alerts not persisting workspace
- Error when saving handler with empty nickname
- Allow users to add multiple empty rules

Co-authored-by: Iris Scholten <[email protected]>
@bthesorceror bthesorceror force-pushed the fixes/continue-multiple-slack branch from d0ff7a4 to 0c55409 Compare May 17, 2018 18:39
@bthesorceror bthesorceror merged commit 80420b6 into master May 17, 2018
@bthesorceror bthesorceror deleted the fixes/continue-multiple-slack branch May 17, 2018 19:47
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