-
Notifications
You must be signed in to change notification settings - Fork 358
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
Refactor - Replace .success calls with .then/.catch #13
Conversation
@miq-bot add_label wip,refactor |
@AparnaKarve Cannot apply the following label because they are not recognized: refactor |
4f660e0
to
b17c135
Compare
@himdel Let me know what you think of these changes. If this looks good, I would like to replicate this approach across all angular controllers. I've also tried to address some of the CodeClimate issues, specifically the ones that were easily addressable and pertaining to the changes made in this PR. |
} | ||
$scope.actionUrl = $scope.newRecord ? $scope.createUrl : $scope.updateUrl; | ||
$scope.currentTab = "default"; | ||
|
||
function getEmsFormIdDataComplete(response, status, headers, config) { |
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.
(response, status, headers, config)
The docs say that the handler takes only one parameter, which is an object containing data
, status,
headers
, config
and statusText
- not 4. Or am I reading it wrong?
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.
You're right. I'll definitely go with what the Angular docs say.
My source was this, which could be outdated.
|
||
function getEmsFormDataFailed(e) { | ||
miqService.sparkleOff(); | ||
console.log(e.message); |
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.
I'd do (e && e.message) || e
here (or something like that): there's no guarantee the error will have a message field. (There is if it was a failure in http, but if the then
function throws an exception, that one doesn't have to have a message.)
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.
We would always have e
, although e.message
could be questionable.
So I'll change it to --
if (e.message) {
console.log(e.message);
}
@AparnaKarve the approach looks solid, except for that args oversight I have nothing to add 👍 :) |
f151f02
to
1da247f
Compare
Thanks! I've implemented your suggestions. |
d204071
to
9264705
Compare
@himdel I'm thinking of dividing this task into smaller chunks. Here's why --
So close to 37 controllers need to be addressed. |
@AparnaKarve agreed there, split any way you like ;) Just one thing I'm noticing now.. can you move that error handler function to |
Yes, I thought about that too...moving the error handler to |
@AparnaKarve yeah, kinda agreed but better there than in every controller :). Or, if you're really unconfortable with putting this in a service, an alternative would be a global function, defined in As for a common controller .. yeah, agreed completely, in fact I was planning to do a |
Interesting! |
to Move function declaration to function body root.
9264705
to
8b27691
Compare
8b27691
to
25eaa96
Compare
Checked commits AparnaKarve/manageiq-ui-classic@eadd9a1~...25eaa96 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 |
@himdel Ideally I would like this PR merged before I move on to the next set of controllers. |
Sorry @AparnaKarve it took so long.. merged :) LGTM 👍, tested in the UI.. (ems_common at least) |
@himdel Thanks for merging and thank you 🙏 especially for testing in the UI! |
With Angular 1.6+, the
$http .success
and$http .error
would not be supported anymore.The PR currently addresses the
.success
calls in one controller.The other controllers will follow suit.
Tackling the following controllers in this PR: