-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Add a head.additional block to adminhtml layout #28389
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
Add a head.additional block to adminhtml layout #28389
Conversation
Hi @gsomoza. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. |
Note1: this probably shouldn't have the |
@magento run all tests |
Hi @ihor-sviziev, thank you for the review. |
Done! |
@magento create issue |
✔️ QA Passed Manual testing scenario:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceBlock name="head.additional">
<block class="Magento\Framework\View\Element\Template" name="test"
template="Magento_Backend::page/copyright.phtml"/>
</referenceBlock>
</page>
Before: ✖️ no copyright text in the After: ✔️ The copyright text rendered within any admin page's area |
@sidolov could you explain why this PR was moved to "pending review" without any comment? Were the additional tests executed? What their result?Can I approve it? |
@ihor-sviziev I don't see any reason to hold it, I agree with @naydav, additional cases should be verified but we can do that on the QA stage. |
Hi @ihor-sviziev, thank you for the review. |
Dev experience is required for testing this PR. Please note that Manual testing has not been performed. |
@magento run all tests |
Hi @ihor-sviziev, thank you for the review. |
Hi @gsomoza, thank you for your contribution! |
Module developers are currently able to add external JS files to the admin area's
<head>
section, but adding inline scripts is not as straightforward as it is in the Frontend area because the admin layout doesn't define thehead.additional
block. In fact, I couldn't find a way to add inline scripts to the head in a way that's not "hackish" and remains compatible with other modules. The mechanism to do this easily is simply missing.This PR addresses the mechanism issue: once this block is added
\Magento\Framework\View\Result\Page
will make sure allhead.additional
child blocks are rendered, mirroring the functionality in the Frontend area.Description (*)
This PR simply adds a
head.additional
block of type\Magento\Framework\View\Element\Text\ListText
to the Adminhtml'sdefault
layout (viamagento2/module-base
).Related Pull Requests
None
Fixed Issues (if relevant)
I couldn't find any.
Manual testing scenarios (*)
adminhtml
area:<head>
area.(which is invalid HTML but should work as a quick test)
Other / Reasoning
Why a
ListText
block?container
renders its children within a tag, and we don't want that insidehead
.Template
block with acontainer.phtml
template is used, but that template doesn't exist in the adminhtml area.ListText
simply gets the job done exactly as it's supposed to and without any side-effects.Backwards Compatibility
This change adds a new block to an existing layout and therefore shouldn't break backwards compatibility with any existing code.
Automated tests?
I'd be happy to create them if you really think it's necessary but I'll need a bit of guidance. However, I also doubt this is the kind of things we're testing, because existing tests for
\Magento\Framework\View\Result\Page
and\Magento\Framework\View\Result\Page
would essentially cover most (if not all) requirements for this functionality.Contribution checklist (*)
Resolved issues: