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

[webui] jquery code review #1917

Closed
wants to merge 5 commits into from
Closed

[webui] jquery code review #1917

wants to merge 5 commits into from

Conversation

avindra
Copy link
Member

@avindra avindra commented Jul 7, 2016

These are some changes to update jQuery usage to recommended standards / best practices per jQuery 3.0 (latest). More will be needed, but this is a start.

@@ -207,7 +207,7 @@ function change_role(obj) {
complete: function () {
$('#' + type + '_spinner').hide();
$('#' + type + '_table input').animate({opacity: 1}, 200);
$('#' + type + '_table input').removeAttr('disabled');
$('#' + type + '_table input').prop('disabled', false);
Copy link
Member

Choose a reason for hiding this comment

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

this btw already fails in jquery 2.1

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean @coolo? that the prop method doesn't work in jquery 2.1? I have tried this at build.opensuse.org in the javascript console and it works...

Copy link
Member Author

@avindra avindra Jul 7, 2016

Choose a reason for hiding this comment

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

@coolo : I switched the .removeAttr(prop) to .prop(prop, false) per jQuery's recommendation. Can you give an example of this failing?

It is almost always a mistake to use .removeAttr( "checked" ) on a DOM element.

Copy link
Member

Choose a reason for hiding this comment

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

I meant to say that removeAttr('disabled') already fails in jquery 2.1 - but build.oo uses jquery 1.11.

So 👍 for the change

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah thanks for the clarification. Also, TIL Bootstrap 3.x is not compatible with jQuery 3.x (twbs/bootstrap#16834)

Copy link
Member

Choose a reason for hiding this comment

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

yeah, but till buildservice drops bento theme, bootstrap 19 is out ;)

@mdeniz
Copy link
Contributor

mdeniz commented Jul 8, 2016

Nice then. @avindra can you rebase and push again to see if the tests stop failing? If it doesn't stop then you need to find out why....

@bgeuken
Copy link
Member

bgeuken commented Jul 8, 2016

@mdeniz @avindra Tests can be rerun in travis by clicking the 'Restart Job' icon. I just did that. Let's see if it fails again.

@mdeniz
Copy link
Contributor

mdeniz commented Jul 8, 2016

@bgeuken I have already done this many times before... But the failing test is in the webui suite, so I wanted him to verify if is because the changes added

@avindra
Copy link
Member Author

avindra commented Jul 8, 2016

@mdeniz : Sure thing, will rebase + push to trigger tests when I have a chance.

These are some changes to update jQuery usage to recommended standards / best practices per jQuery 3.0 (latest). More will be needed, but this is a start.

 * .attr('disabled') and .removeAttr('disabled') -> .prop('disabled') per https://jquery.com/upgrade-guide/3.0/#breaking-change-removeattr-no-longer-sets-properties-to-false

 * Replace $.each usage with Array.prototype.{forEach,map,reduce}, etc... These functions are natively supported in IE9+, and their callback signature is more chainable and usable than what jQuery went with.

 * replace success(data) with success(meaningfulName) (should be done throughout codebase).
@avindra
Copy link
Member Author

avindra commented Jul 9, 2016

The test suite is failing again after rebasing and pushing:

https://travis-ci.org/openSUSE/open-build-service/jobs/143567753

The following 3 tests are failing:

Webui::PackageControllerTest
  test_Iggy_adds_himself_as_reviewer 
  test_Iggy_removes_himself_as_bugowner

Webui::ProjectControllerTest
  test_Iggy_adds_himself_as_reviewer 

Does anyone have any insight as to how my proposed changes are breaking these tests? I can't spot anything obvious.

@bgeuken
Copy link
Member

bgeuken commented Jul 11, 2016

Not without having a closer look.
You could git bisect this to encircle the problem.

@hennevogel
Copy link
Member

@avindra are you going to do anything about this?

@avindra
Copy link
Member Author

avindra commented Aug 11, 2016

@hennevogel : I haven't gotten time to look at the failing tests yet. I'll have another look this weekend

@hennevogel
Copy link
Member

@avindra awesome, thanks

@hennevogel
Copy link
Member

@avindra if you find the time to look into it please re-submit a PR. Thanks

@hennevogel hennevogel closed this Aug 22, 2016
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.

5 participants