-
Notifications
You must be signed in to change notification settings - Fork 130
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
Replacing jQuery to Vanilla JavaScript #1388
Conversation
Refactored all jQuery from the templates, and fixed bootstrap collapse instance, |
DEV updated.
Not working:
Solved:
Working:
|
seems like one problem in the bootstrap collapse instance is making the script stop resulting is other problems, will have a look on how I can solve this |
Take your time, I know very little javascript so my help is limited to testing the PR. |
DEV updated. |
This throws error when not in homepage: const machinesButton = document.querySelector("#machines-button");
machinesButton?.addEventListener("click", (e) => { This throws error when in homepage: const tasksButton = document.querySelector("#tasks-button");
tasksButton?.addEventListener("click", (e) => { Commenting out the second one, and loading the homepage, the theme switch works fine. |
DEV updated, the In a test page (eg https://dfts-0.pigazzini.it/tests/view/62e0ba678e4fa6ae4726947e) there are 2 SyntaxErrors: |
DEV updated, I was able to submit a new SPRT test. |
DEV updated. In homepage the show/hide buttons are changing status, to load the table require a F5, though. |
I will try to fix that lastly as I'm thinking about using CSS classes and not using this bootstrap instance instead, will see, there are still some errors I still see jQuery even in the last commit and there are a couple of syntax errors, |
I'm thinking about this PR as a marathon, not a 100m dash. There are so much things to be well tested before the merge. Take your time. |
DEV updated. |
DEV updated. |
DEV updated |
Updated |
Updated and added by hand in <%
from fishtest.util import get_cookie
%> All show/hide buttons seems to work fine in a fast test. EDIT_000: all the show/hide button (but the "workers" one) have the label reversed (eg "show" when the table is already shown) |
The code for show/hide buttons was at first wrote in Please mind that the function |
Updated.
|
Pyramid works in this way. Please mind the last lines, where we read a cookie to set a variable used in the mako template. Here is some documentation about pyramid request, views etc. https://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#request-module Here is some doc about mako template (default template in Pyramid): To inspect the variables content in a page simply add a field in the mako template: <div>
some_variable = ${some_variable}
</div> EDIT_000: in a mako template we can set a javascript variable using the python variable, eg: |
DEV updated. |
Instead of using |
DEV updated. |
Updated:
I don't recall someone reporting the rate limit message in the diff window (hard to be ignored because the long one line message pushes the "Actions", "Stats", "Time" fields in the far right). I triggered the rate limit because I created a very high number of new runs to test the vanilla js code. |
What about checking if the user has reached its rate limit (or that it has enough left) before making a request? https://api.github.com/rate_limit |
Nice idea but IMO better to no add new features to this PR (BTW I started requesting new features so I'm to blame here :) ) |
Please notice that the jQuery Ajax solution(master) also has the same problem of 403 (the rate limit problem)with diff box, I have been experiencing it since a very long time, when you refresh enough times on a particular test diff doesn't show anymore, |
I do know, I wrote it in my old post. |
I think this should make it equivalent to master |
DEV Updated. Looks good to me! PROD updated by hand to test the PR with the sharks :) |
I will run PROD with this PR for few days to collects feedbacks from the users. @peregrineshahin please at your convenient time squash the commits or in one commit or in few logical commits, writing a/some final commit message/s (I use EDIT_000: we auto format the front end code with prettier, see #634 (comment):
I can do it during the merge, let me know. |
Very substantial PR! |
DEV updated, I submitted 11 tests in a row using the back button, it seems to work (with the previous code I got a random true/false value for |
Just for the record, I don't think you get random as garbage memory random before the fix, I think the randomity comes from if the back button triggered a full reload or rendered the cached page and that depends on how fast you click it - it seems (bc I'm still not able to reproduce it)- please @ppigazzini feel free to format the PR with Prettier when merging, and I think I can squash the commits after learning how git commands, tonight or tomorrow |
@peregrineshahin squashing to only one commit it's very easy, change all the "pick" to "squash" but the first one.
|
bd1f06f
to
c8baf67
Compare
I test the code on PROD for a few more hours to collect the users feedback. |
0380d38
to
7c356e2
Compare
6dc7403
to
bb76f53
Compare
Bootstrap v5.x has dropped the dependency from jQuery this PR includes: - converting all jQuery code to native JS including the abandonment of jQuery Cookie and jQuery Style functions - using the bootstrap data attribute for toggling and move toggling inside its fitting mako templates and updating bootstrap to the latest version, - use a proper naming convention and reformat old js code The format was made manually (Copy & Paste) using Prettier v2.7.1 on their website https://prettier.io/playground/, using Babel option using --print-width set to 80 (the default) it formats ```.js``` files and only the <script> tags inside the Mako templates
3c5a55f
to
05dc597
Compare
PROD and DEV updated. |
Merged, PROD updated, thank you @peregrineshahin :) |
Now that we don't need it in Bootstrap 5