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 ability to update a variable #12011

Merged
merged 1 commit into from
Feb 20, 2019
Merged

Conversation

AlirieGray
Copy link
Contributor

@AlirieGray AlirieGray commented Feb 20, 2019

Closes #11844

This PR adds the ability to edit a variable's name and query from the Variables tab of the orgs page. It also includes notifications for when an update succeeds or fails.

  • Rebased/mergeable
  • Tests pass
  • CHANGELOG.md updated

@AlirieGray AlirieGray force-pushed the feat(variables)/edit-variable branch 2 times, most recently from 8410b82 to 4050192 Compare February 20, 2019 19:33
Copy link
Contributor

@ischolten ischolten 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. Just a few comments/suggestions

super(props)

const {variable} = this.props
const script = _.get(variable, 'arguments.values.query')
Copy link
Contributor

Choose a reason for hiding this comment

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

does there need to be a default in this get? like ""?

<Button
text="Submit"
type={ButtonType.Submit}
onClick={this.handleSubmit}
Copy link
Contributor

Choose a reason for hiding this comment

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

Forms have an onSubmit prop. Since this Button is already type submit, you could remove this.handleSubmit to the onSubmit prop on the form and then get default browser behavior here

return !!variable.name && !!script
}

private handleSubmit = (e): void => {
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 type annotate e?

}

private handleCloseOverlay = () => {
this.setState({variableOverlayState: OverlayState.Closed})
Copy link
Contributor

Choose a reason for hiding this comment

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

should this also reset variableID to null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

variable.id,
variable
)
notify(updateVariableSuccess(updatedVariable.name))
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!


interface Props {
variable: Variable
onDeleteVariable: (variable: Variable) => void
onUpdateVariable: (variable: Partial<Variable>) => void
onEditVariable: (variable: Variable) => void
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps there is a better name distinction between these two props? both of those names seem like they would do the same thing.

@AlirieGray AlirieGray force-pushed the feat(variables)/edit-variable branch 2 times, most recently from aa99185 to 35e7d42 Compare February 20, 2019 20:00
@AlirieGray AlirieGray force-pushed the feat(variables)/edit-variable branch from 35e7d42 to 9ccb785 Compare February 20, 2019 20:04
@AlirieGray AlirieGray merged commit d5b9948 into master Feb 20, 2019
@AlirieGray AlirieGray deleted the feat(variables)/edit-variable branch February 20, 2019 20:11
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