Replace Fancytree with Vue component in Entity Selector#16617
Replace Fancytree with Vue component in Entity Selector#16617cconard96 wants to merge 7 commits intoglpi-project:mainfrom
Conversation
Should be redone entirely anyway but that's a topic for another day. |
In what way should the KB be redone? Probably relevant now since I just started the KB UI migration to Twig today. One thing I already had in mind is streamlining the view and edit views depending on complexity. I seem to remember a very old issue or note somewhere about that. |
There was a problem hiding this comment.
- having dedicated icon for expanding/collpasing is mandatory
- file icon for entity name is not the better choice (and due to the tree lib) but having none feel empty for the list. Maybe we can reuse stack icon (icon of Entity). Folder icon could maybe use stack-2 icon.
- folders was displayed bold, not mandatory but it helps identifying them
I broke scrolling directly in 5s (just scrolling down a medium list):

I will probably have more to say, but a first pass is required.
A lot of things and difficult to be exhaustive but here is a list of issues: |
|
It's better but I still have some issues with virtual dom Capture.video.du.07-03-2024.15.46.16.webm |
I'm not seeing that issue and I'm not sure why the rendering would be so slow for you. |
|
The repaint matches my mouse scroll speed. I try to redo a test soon. |
I can only recreate if I don't do a |
dae5cc2 to
499b40b
Compare
cedric-anne
left a comment
There was a problem hiding this comment.
Seems OK. I rebased to ensure that it passes an up-to-date test suite.
|
Seems cache related. |
|
Ok I have another annoying special case . Within your tree, you must have an entity:
After unfolding the entity under the root section, the scroll start to behave wrongly (see my previous comment: #16617 (comment)) |
f68b1cd to
bbd58a6
Compare
There was a problem hiding this comment.
There are a few remaining quircks:
-
Active entity is not highlighted anymore in the tree
-
more complex but everyone misses this feature of active entity. You may have several entities in your rights. One could be a subset of another:

In this case, interacting firstly within the Root tree on the duplicated children and then in the children tree lead to very strange behavior

This is working in 10.0.x
The weird behavior is because there are nodes with duplicate keys in this case. Expanding the node for an Entity "fill entity" for example will expand every instance of it in the tree display. Is the ideal display still how it was before or should we take the opportunity to change it? For example, if I have rights on the root entity recursively and a sub entity, is anything really gained by having that sub entity listed twice? |
Probably that. The case I showed you is not that useful; it's just typical and clear. A real case could be someone without rights on the root entity but several on different entities. I don't know if it triggers strange behavior in this case, but I think it's safer to consider unique, identical nodes present in different branches. |
|
Should it be included in version 11.0 or postponed? |
|
I will not push for it myself. If we can fix the remaining issues and making some extensive functional tests (by hand I mean); I would be OK. |
|
I'm OK with delaying this PR. I don't see a huge need to rush it for 11.0. |
|
This PR has been restarted nearly from scratch.
If there are any desired design changes to this feature, now may be the time to discuss them/tell me. |
6cf3592 to
e3444f9
Compare
|
I will a busy week , but I'll try to make a checkout asap and give my opinion about the current state |
Current state is UI/performance work only. I may work on the form actions later today. |
| Html::header_nocache(); | ||
|
|
||
| echo json_encode(Entity::getEntitySelectorTree((int) ($_GET['rand'] ?? 0))); | ||
| //echo json_encode(Entity::getEntitySelectorTree((int) ($_GET['rand'] ?? 0))); |
There was a problem hiding this comment.
The below code should probably be in getEntitySelectorTree method
There was a problem hiding this comment.
Leaving that for last. If this PR is OK, getEntitySelectorTree will be rewritten and the code for the API endpoint can be changed to call it. The temporary code in the AJAX script is the same as what the API uses currently.
|
It's difficult to check raw client performance on my side, but here are a few things noted:
On UI, even you said it's currently still in progress, another set of remarks:
|
32x less data being sent is huge for mobile/wifi users.
Someone literally just commented about in on the forum yesterday, calling it "weird" and I tend to agree. The way a user is granted permission on an entity shouldn't matter to them. If they are given direct permissions on Entity B and Entity C or granted permissions indirectly on B and directly on C, they should still show in the same way:
The only reason for it to be different is if permissions are granted directly on both B and C, making them both "roots".
Anyways, I'll check different entity assignments later.
done
This is redundant with the arrow icons, but I restored the stack icons that were decided on as replacements for the folder icon the last time.
done
done |
|
A last few things;
Regarding icons, it's ok now, but I find it a bit busy. Maybe we can remove icons from no-children entries.
It was more about a weird bug appearing previously, it's OK now for me.
Note, I find it odd also, but this is kind of changes I'm not willing to make. |
Be aware that these buttons would no longer meet WCAG AA requirements for minimum target size. The button would have a clickable area of 17x21 pixels instead of 25x25. The minimum for WCAG AA is 24x24 pixels. Especially because it is right next to another interactable element, I don't believe it q2ualifies under any of the exemptions for the guideline.
done
done Just FYI, I was thinking yesterday about a favorites feature for entities. That would entail having a star icon button next to each entity in the list which would add/remove it from the favorites. Favorite entities would show up above the normal tree in a flat list. Another button would show in the selector to favorite/unfavorite the current entity. In cases where a user has access to hundreds or thousands of entities, odds are they only need to change to a few for 90% of their work. We could also have it show only the favorites by default if they are available and there are a lot of entities to avoid needing to load the entire entity tree for the user if they just want to use their favorites list. |
|
An important point I would like to discuss, if the tree traversal (parent nodes opening) doesn't trigger ajax calls, it's useless imo.
|
With 100,000 entities and GLPI in production mode (no debug mode or xdebug either), the AJAX call when the selector is opened takes 800-1000ms for me and the tree is displayed shortly after (half a second maybe). No data is fetched until the selector is opened. If we add caching so that the clients with huge numbers of entities don't need to transfer so much over the network or have better performance, we need to think about it a little more than just dumping the data in the sessionStorage/localStorage as there is a 5MB limit and the uncompressed entity tree data from GLPI for my 100k entities is 5.7MB. To cache it locally, across pages would mean using indexDB. I don't think there is any reason we couldn't use it though. The reason I didn't have it load data when each entity node is expanded is because of the added complexity on the server and the search functionality. Additionally, the data is cached on the server in the |
|
I looked more at using IndexedDB for caching the entity tree client-side but I don't think there is enough information on the client-side currently to know when the cache data can be used or if it needs invalidated. |








Sort of a proof of concept for replacing the Fancytree library since the entity selector was the most complex case with DOM recycling (only the visible options are in the DOM and the data is swapped out as the user scrolls). Since Vue already handles this functionality natively, it is not a difficult thing to migrate. The only difficulty I had was minor and involved handling auto-expand of the entity "folders" to display the entities that matched the search while also keeping good performance. In the end, performance seems at least as good as Fancytree when I tested with tens of thousands of entities.
The remaining uses for this library are the Browse view on various search pages and the Browse view in the knowledgebase. Neither case restricts the elements added to the DOM to only what is visible to the user at the time.