-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix For Issue:Incorrect redirect navigate on the review edit page #29318 #30436
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
base: 2.4-develop
Are you sure you want to change the base?
Changes from all commits
440a4cf
206335f
0a81ed8
c3f6365
2ded1c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,26 @@ | |
*/ | ||
class BackButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* @var Form | ||
*/ | ||
private $form; | ||
/** | ||
* @var \Magento\Framework\Url\DecoderInterface | ||
*/ | ||
private $decoder; | ||
|
||
public function __construct( | ||
\Magento\Framework\Url\DecoderInterface $decoder, | ||
\Magento\Customer\Block\Adminhtml\Edit\Form $form, | ||
\Magento\Backend\Block\Widget\Context $context, | ||
\Magento\Framework\Registry $registry | ||
) { | ||
parent::__construct($context, $registry); | ||
$this->form = $form; | ||
$this->decoder = $decoder; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
|
@@ -32,6 +52,12 @@ public function getButtonData() | |
*/ | ||
public function getBackUrl() | ||
{ | ||
if ($fromPath=$this->decoder->decode($this->form->getRequest()->getParam('fromPath'))) { | ||
return $this->getUrl( | ||
$fromPath, | ||
['id' => $this->form->getRequest()->getParam('review_id')] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we need a universal solution for similar cases instead of fixing particular places. We see the same situation when we go to the customer information page from the order view page. So, we may have a couple more places in the admin panel where we have the same issue with the back button. It would be great if we could find out how to solve this issue for all occurrences. Hope it makes sense There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello, @rogyar! I've done some investigation and I don't see the possibility to make a universal and reasonable solution for all "Back" buttons. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @engcom-Foxtrot. I've been reflected on that for some time and you are right. It's not an easy task unless we have the same name for an entity identifier. Anyway, thank you for checking! |
||
); | ||
} | ||
return $this->getUrl('*/*/'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> | ||
<actionGroup name="AdminOpenCustomerPageFromReviewActionGroup"> | ||
<annotations> | ||
<description>Open Customer Page of Review author.</description> | ||
</annotations> | ||
|
||
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="Edit Review" stepKey="assertOnReviewPage"/> | ||
<click selector="{{AdminReviewDetailsSection.authorName}}" stepKey="goToCustomerEditPage"/> | ||
<switchToNextTab stepKey="switchToNextTab"/> | ||
<waitForPageLoad stepKey="waitForCustomerEditPage"/> | ||
</actionGroup> | ||
</actionGroups> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> | ||
<page name="AdminEditReviewPage" url="review/product/edit/id/{{reviewId}}/" area="admin" module="Review" parameterized="true"> | ||
<section name="AdminReviewDetailsSection"/> | ||
</page> | ||
</pages> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> | ||
<section name="AdminReviewDetailsSection"> | ||
<element name="authorName" type="button" selector="//*[@id='customer']/a[1]"/> | ||
<element name="authorEmail" type="select" selector="//*[@id='customer']/a[2]"/> | ||
</section> | ||
</sections> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> | ||
<test name="AdminReviewCorrectBackButtonTest"> | ||
<annotations> | ||
<features value="Review"/> | ||
<stories value="Review By Customers"/> | ||
<title value="Admin review correct back button test"/> | ||
<description value="Verify 'Back' button redirects on correct page if Customer page opened from Review page."/> | ||
<severity value="MAJOR"/> | ||
<testCaseId value="MC-36271"/> | ||
</annotations> | ||
<before> | ||
<createData entity="SimpleSubCategory" stepKey="createCategory"/> | ||
<createData entity="SimpleProduct" stepKey="createProduct"> | ||
<requiredEntity createDataKey="createCategory"/> | ||
</createData> | ||
<createData entity="Simple_US_Customer" stepKey="createCustomer"/> | ||
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> | ||
</before> | ||
<after> | ||
<actionGroup ref="AdminOpenReviewsPageActionGroup" stepKey="openAllReviewsPage"/> | ||
<actionGroup ref="AdminDeleteReviewsByUserNicknameActionGroup" stepKey="deleteCustomerReview"/> | ||
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearNickNameReviewFilters"/> | ||
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> | ||
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/> | ||
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/> | ||
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> | ||
</after> | ||
<!-- Create Review on Storefront --> | ||
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="storefrontCustomerLogin"> | ||
<argument name="Customer" value="$$createCustomer$$"/> | ||
</actionGroup> | ||
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openStorefrontProductPage"> | ||
<argument name="productUrl" value="$$createProduct.custom_attributes[url_key]$$"/> | ||
</actionGroup> | ||
<actionGroup ref="StorefrontAddProductReviewActionGroup" stepKey="addReview"/> | ||
|
||
<!-- Grab Review's id --> | ||
<actionGroup ref="AdminOpenPendingReviewsPageActionGroup" stepKey="openReviewsPage"/> | ||
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilters"/> | ||
<actionGroup ref="AdminOpenReviewByUserNicknameActionGroup" stepKey="openFirstCustomerReviews"/> | ||
<grabFromCurrentUrl regex="~/id/(\d+)/~" stepKey="grabReviewId"/> | ||
|
||
<!-- Check if "Back" button works correctly if Customer page opened from Review page --> | ||
<actionGroup ref="AdminOpenCustomerPageFromReviewActionGroup" stepKey="openCustomerPageFromReview"/> | ||
<actionGroup ref="AdminClickBackButtonActionGroup" stepKey="clickBackToEditReviewPage"> | ||
<argument name="expectedPageUrl" value="{{AdminEditReviewPage.url('$grabReviewId')}}"/> | ||
</actionGroup> | ||
|
||
<!-- Check if "Back" button works correctly if Customer page opened not from Review page --> | ||
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="openCustomerEditPage"> | ||
<argument name="customerId" value="$$createCustomer.id$$"/> | ||
</actionGroup> | ||
<actionGroup ref="AdminClickBackButtonActionGroup" stepKey="clickBackToCustomerIndexPage"> | ||
<argument name="expectedPageUrl" value="{{AdminCustomerPage.url}}"/> | ||
</actionGroup> | ||
</test> | ||
</tests> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> | ||
<actionGroup name="AdminClickBackButtonActionGroup"> | ||
<annotations> | ||
<description>Click on 'Back' button. Validate correct page opened.</description> | ||
</annotations> | ||
<arguments> | ||
<argument name="expectedPageUrl" type="string"/> | ||
</arguments> | ||
|
||
<click selector="{{AdminGridMainControls.back}}" stepKey="clickBackButton"/> | ||
<waitForPageLoad stepKey="waitForPageLoad"/> | ||
<seeInCurrentUrl url="{{expectedPageUrl}}" stepKey="assertOnExpectedPage"/> | ||
</actionGroup> | ||
</actionGroups> |
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.
Instead of adding this parameter from the request, can't we use the
RedirectInterface
and the methodgetRefererUrl
? This should return the URL that the request came from.Uh oh!
There was an error while loading. Please reload this page.
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.
@gabrieldagama I don't think it's a good idea. This will cause redirect to any previously opened page and works as the 'back' button in the browser.