Skip to content

Commit

Permalink
Hide Addons connect toolbar in ModuleManager when ps_accounts is enab…
Browse files Browse the repository at this point in the history
…led (#695)
  • Loading branch information
sowbiba authored Dec 5, 2023
1 parent 81910d9 commit 711f711
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
10 changes: 9 additions & 1 deletion ps_mbo.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use PrestaShop\Module\Mbo\Helpers\Config;
use PrestaShop\Module\Mbo\Tab\TabCollectionProvider;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PsAccountsInstaller\Installer\Installer;
use Ramsey\Uuid\Uuid;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Dotenv\Dotenv;
Expand Down Expand Up @@ -506,7 +507,14 @@ protected function loadMediaForAdminControllerSetMedia()
$this->context->controller->addJs('/js/jquery/plugins/growl/jquery.growl.js?v=' . $this->version);
$this->context->controller->addCSS($this->getPathUri() . 'views/css/module-catalog.css');
}
if ('AdminPsMboModule' === Tools::getValue('controller')) {

$accountsInstaller = $this->get('mbo.ps_accounts.installer');
$isPsAccountsEnabled = ($accountsInstaller instanceof Installer) && $accountsInstaller->isModuleEnabled();

if (
('AdminPsMboModule' === Tools::getValue('controller')) // Module catalog / Marketplace
|| $isPsAccountsEnabled // For Module manager
) {
$this->context->controller->addCSS($this->getPathUri() . 'views/css/connection-toolbar.css');
}
$this->loadCdcMedia();
Expand Down
14 changes: 9 additions & 5 deletions src/Controller/Admin/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ public function catalogAction()
$accountsFacade = $this->get('mbo.ps_accounts.facade');
$accountsService = $accountsFacade->getPsAccountsService();
$this->ensurePsAccountIsEnabled();
} catch (\PrestaShop\PsAccountsInstaller\Installer\Exception\InstallerException $e) {
$accountsInstaller = $this->get('mbo.ps_accounts.installer');
$accountsInstaller->install();
$accountsFacade = $this->get('mbo.ps_accounts.facade');
$accountsService = $accountsFacade->getPsAccountsService();
} catch (Exception $e) {
try {
$accountsInstaller = $this->get('mbo.ps_accounts.installer');
$accountsInstaller->install();
$accountsFacade = $this->get('mbo.ps_accounts.facade');
$accountsService = $accountsFacade->getPsAccountsService();
} catch (Exception $e) {
$accountsFacade = $accountsService = null;
}
}

if (null !== $accountsFacade && null !== $accountsService) {
Expand Down
5 changes: 4 additions & 1 deletion views/css/connection-toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
.header-toolbar .container-fluid, .header-toolbar .page-head-tabs {
.adminpsmbomodule .header-toolbar .container-fluid,
.adminpsmbomodule .header-toolbar .page-head-tabs,
.adminmodulesmanage #page-header-desc-configuration-addons_connect,
.adminmodulesmanage #page-header-desc-configuration-addons_logout {
display: none;
}

0 comments on commit 711f711

Please sign in to comment.