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

Fixed 24990: link doesn't redirect to dashboard #26100

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminClickLogoActionGroup">
<click selector="{{AdminMenuSection.logo}}" stepKey="clickLogoInAdmin"/>
<waitForPageLoad stepKey="waitForAdminDashboardPageLoaded"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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="AdminNavigateToSetupWizardPageActionGroup">
<annotations>
<description>Open Setup Wizard Page.</description>
</annotations>
<amOnPage url="{{AdminSetupWizardPage.url}}" stepKey="navigateToSetupWizardPage"/>
<waitForPageLoad stepKey="waitForSetupWizardPageLoaded"/>
</actionGroup>
</actionGroups>
12 changes: 12 additions & 0 deletions app/code/Magento/Backend/Test/Mftf/Page/AdminSetupWizardPage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?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="AdminSetupWizardPage" url="admin/backendapp/redirect/app/setup/" area="admin" module="Magento_Backend"/>
</pages>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminMenuSection">
<element name="logo" type="button" selector=".menu-wrapper a.logo"/>
<element name="catalog" type="button" selector="#menu-magento-catalog-catalog"/>
<element name="catalogProducts" type="button" selector="#nav li[data-ui-id='menu-magento-catalog-catalog-products']"/>
<element name="customers" type="button" selector="#menu-magento-customer-customer"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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="AdminRedirectToAdminPanelOnLogoClickFromWizardPageTest">
<annotations>
<features value="Backend"/>
<stories value="Navigate to dashboard from Setup Wizard Page"/>
<title value="Navigate to dashboard after click on logo on Setup Wizard Page"/>
<description value="Check navigate to dashboard after click on logo on Setup Wizard Page"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/>
</before>
<after>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
</after>

<actionGroup ref="AdminNavigateToSetupWizardPageActionGroup" stepKey="navigateToSetupWizardPage"/>
<actionGroup ref="AdminClickLogoActionGroup" stepKey="clickOnLogo"/>
<actionGroup ref="AssertAdminDashboardPageIsVisibleActionGroup" stepKey="checkTheDashboardPage"/>
</test>
</tests>
19 changes: 16 additions & 3 deletions setup/src/Magento/Setup/Controller/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\JsonModel;
use Laminas\View\Model\ViewModel;
use Magento\Backend\Model\UrlInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Setup\Model\Cron\Status;
use Magento\Setup\Model\Navigation as NavModel;
use Magento\Setup\Model\ObjectManagerProvider;

/**
* Navigation controller
Expand All @@ -32,13 +35,20 @@ class Navigation extends AbstractActionController
protected $view;

/**
* @param NavModel $navigation
* @param Status $status
* @var ObjectManagerInterface
*/
public function __construct(NavModel $navigation, Status $status)
private $objectManagerProvider;

/**
* @param NavModel $navigation
* @param Status $status
* @param ObjectManagerProvider $objectManagerProvider
*/
public function __construct(NavModel $navigation, Status $status, ObjectManagerProvider $objectManagerProvider)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you use ObjectManagerProvider instead of injecting just UrlInterface?

Copy link
Contributor Author

@Usik2203 Usik2203 Jan 8, 2020

Choose a reason for hiding this comment

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

I am getting such error "An error occurred during execution; please try again later" and status 500 while injecting UrlInterface directly in constructor of controller

{
$this->navigation = $navigation;
$this->status = $status;
$this->objectManagerProvider = $objectManagerProvider->get();
$this->view = new ViewModel();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you instantiating classes with new instead of using Factory or just Dependency Injection?

Copy link
Contributor Author

@Usik2203 Usik2203 Feb 3, 2020

Choose a reason for hiding this comment

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

I cannot create through Factory or Dependency Injection as usual I am getting such error
Screenshot 2020-02-18 at 10 28 44
Also I see a lot of cases in setup/src/Magento/Setup/Controller were these object was created with new

$this->view->setVariable('menu', $this->navigation->getMenuItems());
$this->view->setVariable('main', $this->navigation->getMainItems());
Expand Down Expand Up @@ -80,8 +90,11 @@ public function menuAction()
*/
public function sideMenuAction()
{
/** @var UrlInterface $backendUrl */
$backendUrl = $this->objectManagerProvider->get(UrlInterface::class);
$this->view->setTemplate('/magento/setup/navigation/side-menu.phtml');
$this->view->setVariable('isInstaller', $this->navigation->getType() == NavModel::NAV_INSTALLER);
$this->view->setVariable('backendUrl', $backendUrl->getRouteUrl('adminhtml'));
$this->view->setTerminal(true);
return $this->view;
}
Expand Down
8 changes: 5 additions & 3 deletions setup/view/magento/setup/navigation/side-menu.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
ng-show="<?= implode( '&&', $expressions) ?>"
>
<nav class="admin__menu" ng-controller="mainController">
<span class="logo logo-static" data-edition="Community Edition">
<img class="logo-img" src="<?= $this->basePath() ?>/pub/images/logo.svg" alt="Magento Admin Panel">
</span>
<a href="<?= $this->backendUrl ?>" class="logo" data-edition="Community Edition">
<span>
<img class="logo-img" src="<?= $this->basePath() ?>/pub/images/logo.svg" alt="Magento Admin Panel">
</span>
</a>
<ul id="nav" role="menubar">
<li class="item-home level-0" ng-class="{_active: $state.current.name === 'root.home'}">
<a href="" ui-sref="root.home">
Expand Down