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

Fixed "DEFAULT ANSWER" to be properly deleted for Integer and Float types #4479

Merged
merged 1 commit into from
Aug 15, 2019
Merged

Conversation

saito-hideki
Copy link
Member

@saito-hideki saito-hideki commented Aug 14, 2019

SUMMARY

Fixed the value of "DEFAULT ANSWER" to be properly deleted for Integer and Float types.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • UI
AWX VERSION
  • AWX: devel
  • Ansible Tower: 3.4, 3.5
ADDITIONAL INFORMATION

None

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@saito-hideki saito-hideki changed the title [WIP] Fixed "DEFAULT ANSWER" to be properly deleted for Integer and Float types Fixed "DEFAULT ANSWER" to be properly deleted for Integer and Float types Aug 14, 2019
@jakemcdermott jakemcdermott self-requested a review August 14, 2019 14:14
data.default = scope.default_float;
} else if (scope.type.type === 'integer') {
} else if (scope.type.type === 'integer' && scope.default_int) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@saito-hideki
We can't rely on the truthiness of scope.default_int for all cases. For example, this would prevent someone from updating the default value to 0.

Copy link
Contributor

@jakemcdermott jakemcdermott Aug 14, 2019

Choose a reason for hiding this comment

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

@saito-hideki
When these fields are cleared, their values can become an empty string or null depending on how it's been initialized.

Adding some more specificity to the validation checks might be all that's needed here:

...
} else if (scope.type.type === 'float' &&
    scope.default_float !== '' &&
    scope.default_float !== null) {
    data.default = scope.default_float;
} else if (scope.type.type === 'integer' &&
    scope.default_int !== '' &&
    scope.default_int !== null) {
    data.default = scope.default_int;
} else {
...

Copy link
Member Author

Choose a reason for hiding this comment

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

@jakemcdermott Thank you for your kind review!
As you pointed out, there was a problem with this condition handling. So I have fixed it.

Copy link
Contributor

@jakemcdermott jakemcdermott left a comment

Choose a reason for hiding this comment

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

Just a minor revision is needed (see review comments) and I think this will be ready to go.

thanks for taking a look at this, @saito-hideki !

@saito-hideki saito-hideki changed the title Fixed "DEFAULT ANSWER" to be properly deleted for Integer and Float types [WIP] Fixed "DEFAULT ANSWER" to be properly deleted for Integer and Float types Aug 15, 2019
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@saito-hideki
Copy link
Member Author

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@saito-hideki
Copy link
Member Author

saito-hideki commented Aug 15, 2019

@jakemcdermott Thank you for your great advice! I have fixed wrong condition handling.
If it is possible, could you review my latest code?

@saito-hideki saito-hideki changed the title [WIP] Fixed "DEFAULT ANSWER" to be properly deleted for Integer and Float types Fixed "DEFAULT ANSWER" to be properly deleted for Integer and Float types Aug 15, 2019
Copy link
Contributor

@jakemcdermott jakemcdermott 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 to me - thanks!

…ypes

- Fixed issue ansible/tower#3639

Signed-off-by: Hideki Saito <saito@fgrep.org>
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit dc44e68 into ansible:devel Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants