Skip to content

Commit

Permalink
Removed legacy page from sidebar nav
Browse files Browse the repository at this point in the history
  • Loading branch information
lindseydiloreto committed Mar 19, 2024
1 parent c1e8848 commit 438346f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 56 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

### Changed
- Removed legacy page from sidebar nav.

## 3.1.1 - 2023-10-26

### Changed
Expand Down
34 changes: 2 additions & 32 deletions src/Inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ class Inventory extends Plugin
*/
public static Plugin $plugin;

/**
* @var bool The plugin has its own section.
*/
public bool $hasCpSection = true;

/**
* @inheritdoc
*/
Expand All @@ -55,7 +50,7 @@ public function init(): void
]);

// Load class services
$inventoryService = Inventory::$plugin->inventoryService;
$inventoryService = self::$plugin->inventoryService;

// Set template hook
Craft::$app->getView()->hook('getFieldLayouts', [$inventoryService, 'getFieldLayouts']);
Expand All @@ -66,31 +61,6 @@ public function init(): void

// Redirect after plugin install
$this->_postInstallRedirect();

// Manage whether "Inventory" should appear in the sidebar
$this->_manageSidebarNav();
}

// ========================================================================= //

/**
* Manage whether "Inventory" should appear in the sidebar.
*/
private function _manageSidebarNav(): void
{
// If not a web request, bail
if (!Craft::$app->getRequest()->getIsCpRequest()) {
return;
}

// Whether a cookie has been set to hide "Inventory" from the sidebar
$hideFromSidebar = Craft::$app->getRequest()->getCookies()->getValue('hide-inventory-from-sidebar');

// If cookie exists
if ($hideFromSidebar) {
// Hide "Inventory" from the sidebar
$this->hasCpSection = false;
}
}

// ========================================================================= //
Expand Down Expand Up @@ -129,7 +99,7 @@ private function _registerCpRoutes(): void
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_CP_URL_RULES,
function (RegisterUrlRulesEvent $event) {
static function (RegisterUrlRulesEvent $event) {
$event->rules['utilities/inventory/<groupId:\d+>'] = ['template' => 'inventory/fields'];
}
);
Expand Down
11 changes: 0 additions & 11 deletions src/templates/index.twig

This file was deleted.

13 changes: 0 additions & 13 deletions src/templates/remove-from-sidebar.twig

This file was deleted.

0 comments on commit 438346f

Please sign in to comment.