-
Notifications
You must be signed in to change notification settings - Fork 356
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
Use function getBack in .then instead of result of that function #990
Conversation
02275ee
to
436443f
Compare
@@ -58,13 +58,13 @@ ManageIQ.angular.app.controller('ansibleCredentialsFormController', ['$window', | |||
|
|||
vm.saveClicked = function(angularForm) { | |||
API.put('/api/authentications/' + credentialId, vm.credentialModel) | |||
.then(getBack(sprintf(__("Modification of Credential \"%s\" has been successfully queued."), vm.credentialModel.name), false)) | |||
.then(getBack.bind(vm, sprintf(__("Modification of Credential \"%s\" has been successfully queued."), vm.credentialModel.name), false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be either .then(getBack.bind(vm, sprintf(...), false, false))
(to provide all 3 params), or .then(function() { getBack(sprintf(...)); })
.
Otherwise, response
becomes the 3rd param, causing an error icon instead of success on the flash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZitaNemeckova @himdel How does using .bind
resolve this issue which is visible only in Firefox?
Would love to know more about this fix. Seems interesting.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AparnaKarve There is a difference between giving .then
a function and a result of a function. If you give it a function it runs it after it gets response from API call. But if you give it a result of a function as it was before this fix it runs the function to get the result before it gets response from API. So it generates error because there is no response but at the same time it runs success function getBack
to get its result into .then
. So perils of asynchronous programming :) I hope I got @himdel explanation right :D
.catch(miqService.handleFailure); | ||
}; | ||
|
||
vm.addClicked = function(angularForm) { | ||
API.post('/api/authentications/', vm.credentialModel) | ||
.then(getBack(sprintf(__("Add of Credential \"%s\" has been successfully queued."), vm.credentialModel.name))) | ||
.then(getBack.bind(vm, sprintf(__("Add of Credential \"%s\" has been successfully queued."), vm.credentialModel.name))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, otherwise response
becomes the 2nd param, causing a warning icon.
436443f
to
7ef6327
Compare
@himdel Fixed. |
Checked commit ZitaNemeckova@7ef6327 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Tested in the UI, we now wait for server response before redirecting. And the success flash is success again :). |
Use function getBack in .then instead of result of that function (cherry picked from commit b6a99da) https://bugzilla.redhat.com/show_bug.cgi?id=1441658
Fine backport details:
|
https://bugzilla.redhat.com/show_bug.cgi?id=1437373
In Firefox without disabled notifications.
Automation -> Ansible -> Credentials -> Configuration -> Add/Edit Credentials -> Add/Save button
Before:
There is a toaster error message after adding/saving a credentials.
After:
No toaster error message.
@miq-bot add_label bug, fine/yes, automation/ansible
@AparnaKarve please review. Thanks :)