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

New hook : enable choosing the icon of an item in impact analysis #17141

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ArthurMinfotel
Copy link

Add a new hook to enable changing the icon of an item in the impact anlysis.

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets

Copy link
Contributor

@orthagh orthagh left a comment

Choose a reason for hiding this comment

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

Why not just completing/altering $CFG_GLPI["default_impact_asset_types"] ?
I'm not sure a hook is necessary here

@ArthurMinfotel
Copy link
Author

Why not just completing/altering $CFG_GLPI["default_impact_asset_types"] ? I'm not sure a hook is necessary here

It would be possible to change it in the plugin setup.php file by getting the request parameters, however I feel like having a dedicated hook make things clearer. Adding to that, I was thinking of modifying ajax/impact.php & impact.js so that the icons shown in the search result sidebar go through the same treatment, so that the search preview would match the actual icons which will be loaded.

@tsmr
Copy link
Collaborator

tsmr commented May 30, 2024

Why not just completing/altering $CFG_GLPI["default_impact_asset_types"] ? I'm not sure a hook is necessary here

Hello Alexandre. This hook permets to define icons for specific types (example : Firewall, Router, Wifi access point) and not only define icons for an global itemtype (as picture for models of objects)

@cedric-anne
Copy link
Member

Why not just completing/altering $CFG_GLPI["default_impact_asset_types"] ? I'm not sure a hook is necessary here

Hello Alexandre. This hook permets to define icons for specific types (example : Firewall, Router, Wifi access point) and not only define icons for an global itemtype (as picture for models of objects)

Indeed, it may permit to define a specific icon for each different item. As it introduces extra queries (each displayed item is loaded, and impact graph may contains many items, it would be preferable to pass the itemtype and the items_id of the item to the hook instead of loading it. Indeed, it is probable that in most cases, the loading of the item by the plugin would be required only on specific cases (also, the plugin may use a caching system to improve the performances).

@cedric-anne cedric-anne changed the base branch from 10.0/bugfixes to main May 30, 2024 09:17
@cedric-anne
Copy link
Member

I changed the target to main branch, as it introduces a new feature.

@cedric-anne cedric-anne self-requested a review May 30, 2024 09:51
@cedric-anne cedric-anne added this to the 11.0.0 milestone May 30, 2024
@ArthurMinfotel
Copy link
Author

Why not just completing/altering $CFG_GLPI["default_impact_asset_types"] ? I'm not sure a hook is necessary here

Hello Alexandre. This hook permets to define icons for specific types (example : Firewall, Router, Wifi access point) and not only define icons for an global itemtype (as picture for models of objects)

Indeed, it may permit to define a specific icon for each different item. As it introduces extra queries (each displayed item is loaded, and impact graph may contains many items, it would be preferable to pass the itemtype and the items_id of the item to the hook instead of loading it. Indeed, it is probable that in most cases, the loading of the item by the plugin would be required only on specific cases (also, the plugin may use a caching system to improve the performances).

Updated the code accordingly : the hook is moved with the ones expecting an array as parameters, and the array contains the keys 'itemtype' and 'items_id' (0 in case of the default icon for the sidebar).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants