-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Seperate js out template to avoid render issue #32434
Seperate js out template to avoid render issue #32434
Conversation
Hi @mrtuvn. 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. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
89d8256
to
57c95bd
Compare
], function(jQuery, $t, confirm) { | ||
'use strict'; | ||
|
||
(function($) { |
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.
I have feeling that it should be inside the return function(config) { ...
. What do you thing?
app/code/Magento/Backend/view/adminhtml/web/js/store-switcher.js
Outdated
Show resolved
Hide resolved
app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml
Outdated
Show resolved
Hide resolved
app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml
Outdated
Show resolved
Hide resolved
"useConfirm": <?= /* @noEscape */ $block->getUseConfirm(); ?>, | ||
"isUsingIframe": <?= /* @noEscape */ $block->isUsingIframe(); ?>, | ||
"switchUrl": "<?= $block->escapeUrl($block->getSwitchUrl()); ?>", | ||
"storeId": <?= /* @noEscape */ $block->getStoreId(); ?> |
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.
I bevieve we should convert it to int before printing
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.
modified as your suggestion
57c95bd
to
87c98a9
Compare
@mrtuvn please add a reference to the following conversation c8a5013#commitcomment-48119352 in the description |
<arguments> | ||
<argument name="is_using_iframe" xsi:type="string">0</argument> | ||
</arguments> |
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.
Please explain why you did it?
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.
This variable not set anywhere in code-base so i think we should declare it here
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.
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Backend/Block/Store/Switcher.php#L614
But it called in this class
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.
Add default value here. Other modules core or 3rd-party providers extensions can easy override it via design area (adminhtml) by layout
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.
setUseConfirm is unneccesary because it's already set via Block
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.
It feels like it supposes to change the following flag:
https://github.com/magento/magento2/pull/32434/files#diff-5c07e420bed1b6e2edda1d6165e1ca2dc4eacaab999bf149eaffa4f53c3823afR47
87c98a9
to
1a8682e
Compare
confirm({ | ||
content: $t('Please confirm scope switching. All data that hasn\'t been saved will be lost.'), | ||
actions: { | ||
confirm: function () { | ||
reload(); | ||
}, | ||
cancel: function () { | ||
obj.value = config.storeId ? config.storeId : ''; | ||
} | ||
} | ||
}); |
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.
maybe that's a bit stupid question, but can we wrap it to require and load 'mage/translate'
and 'Magento_Ui/js/modal/confirm'
components when this really needed? It should a bit improve page load time
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.
updated
<arguments> | ||
<argument name="is_using_iframe" xsi:type="string">0</argument> | ||
</arguments> |
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.
It feels like it supposes to change the following flag:
https://github.com/magento/magento2/pull/32434/files#diff-5c07e420bed1b6e2edda1d6165e1ca2dc4eacaab999bf149eaffa4f53c3823afR47
119a2f1
to
80f6682
Compare
<arguments> | ||
<argument name="use_confirm" xsi:type="string">1</argument> | ||
<argument name="is_using_iframe" xsi:type="string">0</argument> | ||
</arguments> |
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.
Feels like it won't work, as we don't have this argument in constructor
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.
you can get it via Block class no problem by getData('variable')
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.
Looks good to me. Let's wait for the test results. |
80f6682
to
895a386
Compare
@magento create issue |
✔️ QA passed Was checked case from Manual testing scenarios
|
Hi @mrtuvn, thank you for your contribution! |
Description (*)
Main purpose of this PR to seperate js out of template avoid mix js-in-php
Previously if we set store to production with minify enabled. When access backend will raise error because phtml can't render properly
Browser screen return
"An error has happened during application run. See exception log for details."
Reference var/log/system.log
Here is the error log when we meet steps scenario
main.CRITICAL: ParseError: syntax error, unexpected '<<' (T_SL) in /var/www/html/var/view_preprocessed/pub/static/app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml:44
Stack trace:
0 /var/www/html/lib/internal/Magento/Framework/View/Element/Template.php(273): Magento\Framework\View\TemplateEngine\Php->render()
1 /var/www/html/generated/code/Magento/Backend/Block/Store/Switcher/Interceptor.php(428): Magento\Framework\View\Element\Template->fetchView()
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
bin/magento deploy:mode:set production
bin/magento config:set --lock-env dev/template/minify_html 1
Questions or comments
Contribution checklist (*)
Resolved issues: