-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Cleanup contact summary tabs code #12941
Conversation
(Standard links)
|
@colemanw I worked through this and it works fine but it alters the expectations for the hook a little. Notably the hook is 'used to' receiving an array with keys that can be referenced - e.g. I want to change the title of the events tab I can change $tabs['events']['title'] in my hook. You have changed them to be numerically indexed (presumably because you didn't think the keys were needed) but that would be a breaking change for the hook I also think there is an implication extension writers adding hooks would now set the id? This is the current docs for the hook & it should probably be updated if our best practice has changed https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_tabset/ |
@eileenmcnaughton Agree that different indexing would be a breaking change -- however, I think the indexing changes affects the internal structure ( To test this, I made a small test extension to capture the hook-data (before+after the patch): function _foobar_file($name) {
return __DIR__ . '/data/' . CRM_Utils_String::munge($name . '-' . date('Y-m-d-h-i-s'));
}
function foobar_civicrm_tabs() {
file_put_contents(_foobar_file('tabs'), json_encode(func_get_args(), JSON_PRETTY_PRINT));
}
function foobar_civicrm_tabset() {
file_put_contents(_foobar_file('tabset'), json_encode(func_get_args(), JSON_PRETTY_PRINT));
}
function foobar_civicrm_summary() {
file_put_contents(_foobar_file('summary'), json_encode(func_get_args(), JSON_PRETTY_PRINT));
} The content of The content of
{
"id": "summary",
"url": "#contact-summary",
"title": "Summary",
"weight": 0
}, |
Jenkins re test this please |
@totten - thanks for the thorough testing. To your points:
Correct - this PR does not break the hook contract.
Actually that depends on what components you have enabled. With all components enabled, the weights would be no different before/after this PR. This PR makes them more stable/predictable so they do not shift around when enabling/disabling a component.
You might have done the diff backwards :) Actually this PR adds it to the list, which makes the hook a little more robust -- now it's possible to change the weight of the summary tab and rename it via hook. This is necessary for civicrm/org.civicrm.contactlayout#39 to work. |
OK - I feel my concerns have been addressed by the above -merging |
Overview
This is code cleanup and function extraction which should have no impact on end-users or hooks.
Before
Contact summary tabs in hard-coded order.
After
Contact summary tabs still in the same hard-coded order, but extracted a couple functions to make it possible for the LayoutEditor extension to modify them.
Technical Details
This preserves the current order of tabs, but does slightly change the numeric weights of some of them. They were somewhat unpredictable before, now they all have fixed values.
Comments
Hoping to slip this into 5.7 to meet the Contact Layout Editor release schedule.