Rewrite CoffeeScript components in ES6#5081
Conversation
3bce0e2 to
5a9f325
Compare
8d91f42 to
6391981
Compare
|
I'm just going to remove |
|
This is ready for review if you have the time. I've kept the commits focused so open each if you want to see only the changes for that. Should be easier to review and see what's changing. Thanks! After merging this in, I will start replacing the |
|
Once I removed coffeescript (coffee-rails gem), running the test app in a browser after starting the local server wasn't working, but it seems that my test app stuck around even after clearing out the test app with |
varyonic
left a comment
There was a problem hiding this comment.
Looks reasonable to me.
c0ee141 to
510c704
Compare
6588453 to
24c97f1
Compare
|
@varyonic thanks! You reviewed, but not approved. Are you ok with me merging in? Anyone else feel like putting it in a review? I would like to get this in very soon as I've already started updating components. Its going really well! I'm updating the PerPage component to demonstrate what it would be like without the jQuery UI widget bridge and also not needing to attach Turbolinks events either (we'll do event delegation through document instead which solves that problem). Working great so far! |
Tested that the modal receives focus, not the first input within it. Updated the serializeArray method to be functional by using reduce instead.
Existing functionality preserved
Removed duplicate code for the clear filters functionality, so now we filter out the params as we want first, and then use it to adjust what the location. All original functionality has been preserved. Fix regex
Tested all functionality and its maintained for both table checkbox toggler and the checkbox toggler (this is used by another index page type in conjunction with `resource_selection_cell`).
Tested all functionality and works great even with existing or no query params. I adjusted the regex to account for the preceding “?” character in the query string rather than just doing `substring(1)` at the end of `window.location.search` which isn’t clear at first why its there. I preferred to keep everything in the regex as it makes sense since the character is part of the string.
Tested all functionality and it works great, even checking every checkbox on an index page. Tested with both default index table and when used on a custom index type with resource_selection_cell.
Tested functionality and works well. I left the option method in place because we use the plugin method with an argument from the batch actions code to enable/disable the drop down based on what has and hasn’t been checked.
Tested and working fine with all the various options shown in the example in the docs. Opening and closing the dialog works great too.
Tested on the new post form by adding tags and saving, then moving and saving, and deleting as well. Everything worked as it did before.
This doesn’t add any behavior, only modifies appearance for an extreme case. No actual functionality is broken because of this and the presentation part is dealt in activeadmin#3862 as CSS where it should be.
I’m keeping the manifest file as `.js` since there is no need to have it be `.es6` so its very much on purpose.
24c97f1 to
7ec59ff
Compare
|
The build is green but for some reason codecov failed. Its not able to compare commits. I had rebased and edited a commit so that could be why. |
varyonic
left a comment
There was a problem hiding this comment.
Would like to see more approvals, but yes, I'm OK with this.
|
This change makes the |
|
Simply requiring the |
|
@faucct since you mentioned phantomjs, I know it was replaced recently with headless chrome so it could be you are running tests on an older version. Best we moved off of phantomjs. |
|
I don't mean |
|
So you're running the tests against the ES6 code rather than what it compiles too? When it tested against CoffeeScript, did it not first convert it to JS or were the tests running against the CoffeeScript code itself? |
|
Of course the tests are running against the compiled code, but the compiled code expects your browser have some es6 constants defined (Symbol in this case). You can see the compiled code for yourself and find that this line has transformed into something that uses global |
|
I ask because I'm not aware if they are so its not obvious to me. Do you know why its expecting to have an ES6 constant defined? I thought by having this here it would convert but keep the code in ES5 and not rely on something that is ES6 based in the compiled code. Do you know why its using the Symbol variable? Do you have a suggestion on rewriting that line so it doesn't use the Symbol variable perhaps? Yes I know what polyfills are for. This is unexpected so its not something you can expect me or others to be aware of since it wasn't even clear what it was when you described the issue. There is no need for a condescending tone. I'm trying to help but first I need to understand what's wrong. |
|
Sorry, didn't mean to be offensive: the ES6 is a new thing to me too and I don't understand the reasons for a lot of things there. You should use |
|
I'm sorry as ES6 is also new to me. I love some of the improvements but overall I don't know ES6 very well. I'm glad you pointed that out, because why I asked several questions before is that I used a CoffeeScript to ES6 converter which now addresses your concern as to why it might seem odd it was one way rather than another. Now we are getting somewhere and are understanding each other. 👍🏻 A fair amount of JS I rewrote because it was simple enough. The portion you linked too though is so gnarly. 😱 I dug through many commits to understand why it was written the way it was. I gave it a shot but had trouble wrapping my head around it from what I can last remember. I did test the change though so I know it works. I asked if you have thoughts on how that line can be rewritten because I passed it through a converter. It sounds like we should be using |
|
Okay, I will have the PR tomorrow. |
This adds the sprockets-es6 gem so we can write our JS as ES6 and remove the coffeescript dependency. While converting the CoffeeScript to ES6 is easy enough, I wanted to add a quick proof of concept for replacing jQuery UI widgets with a standalone ones where possible. I've started with tabs as that was the easiest but also a big win. The tabs in jQuery UI are well over 900+ lines of code whereas this is just 200 and the same functionality. I challenged myself today to get this done in an hour and was successful.
I've since removed the 2 commits that had converted the tabs from jQuery UI to something that is standalone and working from this PR. I created a new branch from this one called add-tabs-from-bootstrap-v4 where I left that change in place to get it later. I will continue converting to ES6 in this PR.
Closes #5050