-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Do not attempt to rebuild modules list if missing data #33643
Conversation
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.
Thanks @matks
Automated tests https://github.com/matks/ga.tests.ui.pr/actions/runs/5892413280 |
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.
Hello @matks
Untitled_.Aug.17.2023.6_19.PM.webm
automated tests : OK (https://github.com/djoelleuch/ga.tests.ui.pr/actions/runs/5892277931)
It's QA approved ✔️
Thank you 🚀
QA approved, well done! Message to the maintainers: do not forget to milestone it before the merge. |
thanks @matks |
Thanks @matks ! |
Explanation of the problem behind #33629
In PR #31285 the following code has been added:
The event is then catched in line 229 which calls
installHandler(event)
which callsupdateModuleStatus(event)
Function
updateModuleStatus()
is supposed to update the object modulesList which model the modules listing in the BO page. As you can see on lines 245, 246... it attempts to extract many data properties from thisevent
input:The problem is that the input does not contain these data properties. It only contains one:
tech-name
. Noid
,name
,version
...So we have a JavaScript error
Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase')
and the page JS crashes. The page remains stuck, no JS action works anymore and the user cannot close the modal window.Explanation of the fix
In my PR I simply modify function
updateModuleStatus()
and, before the moduleList is being updated, I verify the expected data is provided. I added a check(moduleElement.data('version') !== undefined)
which will be triggered in the usecase above. Ifevent
only containstech-name
and noid
,name
,version
... it will not enter the loop.This is a quick fix that absolutely does not solve the root problem.
Why I did not fix the root problem
At first I thought the root problem was that
event
was not correct. It should containid
,name
,version
... and I thought the right fix was to provide these informations in line 748.However then I had a look at the other places in the code where the event (or another that triggers
updateModuleStatus()
) is being thrown. You can see them here or here.Did you notice? When
Module installed
event is thrown, the code passes the jQuery elementjqElementObj.closest(".${alteredSelector}");
. This element containsid
,name
,version
asdata
attribute. This is the data I need for my usecase. But where does it come from? When was provided thisdata
?This
data
was actually provided from the start, when the page was loaded first. It was there since the beginning. It was not provided by an ajax call. Looking more precisely, I realized that this back-office page does NOT handle the usecase "if I add a module, the module list gets populated".Modules that are already present on the disk already belong to this list so their
data
attribute is populated. They do not get "added" to the list. The problem is when BO user uses the dropzone to add a new module. It is not added to the list (and consequently it does not have thedata
I need). Right: today, as a back-office user, if you use the dropzone to add a new module to the list, the interface tells you "youhou! install was successfull!" you close the modal window and... the list has not changed. You need to refresh the page to see your new module appear.As of today, the modules listing on the back-office page is not capable of adding new items. You can modify items, you can delete some... but it does not support adding new items. You need to refresh the web page to see your new module appear in the list, when the list is rebuild from scratch. So the
data
is never added if you upload a new module. So I will never be able to grab mydata
and send them toupdateModuleStatus()
: it's not even here from the start!And this is the real problem. The behavior of this modules listing on this back-office page, the behavior of this
modulesList
object is missing one usecase: how to handle "adding a module via the dropzone". It was simply not implemented 😁 the code was never written. And that is why I don't have thedata
I need for the functionWhen someone does a PR to correctly handle the "adding a module via the dropzone" usecase, he will properly fetch the new module data, populate the modulesList and the DOM. That will probably solve the issue naturally.
This PR is a simple workaround to avoid blocking the modal window. It will allow users to use the back-office page but the underlying problem remains: "adding a module via the dropzone" on this back-office page is not handled properly. The modules listing is not updated, the user needs to refresh the page. When this usecase is solved, the issue #33629 will be really solved.