Skip to content

Commit

Permalink
Refactor AdminMenu support to match changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksip committed Nov 27, 2024
1 parent 344449b commit f5d2ddc
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 64 deletions.
55 changes: 30 additions & 25 deletions config/vufind/AdminMenu.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# If this file is empty or missing, default settings will be used, matching
# the examples provided below. The format of this configuration is as follows:
# array keys for every menu item could be:
# the examples provided below.
#
# Please note that the current implementation of AdminMenu only supports a subset of
# the options supported by AccountMenu.
#
# Array keys for every menu item could be:
# - name: name of an item
# - label: the text shown as link, will be translated - required
# - route: route name used to generate link target - required
Expand All @@ -11,32 +15,33 @@
# a check whether to show the item. If omitted, item will always display.
# - status: whether to show status label, defaults to false

MenuItems:
- name: home
label: Home
route: admin
Admin:
MenuItems:
- name: home
label: Home
route: admin

- name: socialstats
label: Social Statistics
route: admin/social
- name: socialstats
label: Social Statistics
route: admin/social

- name: config
label: Configuration
route: admin/config
- name: config
label: Configuration
route: admin/config

- name: maintenance
label: System Maintenance
route: admin/maintenance
- name: maintenance
label: System Maintenance
route: admin/maintenance

- name: tags
label: Tag Maintenance
route: admin/tags
- name: tags
label: Tag Maintenance
route: admin/tags

- name: feedback
label: Feedback Management
route: admin/feedback
- name: feedback
label: Feedback Management
route: admin/feedback

- name: overdrive
label: od_admin_menu
route: admin/overdrive
checkMethod: checkShowOverdrive
- name: overdrive
label: od_admin_menu
route: admin/overdrive
checkMethod: checkShowOverdrive
4 changes: 2 additions & 2 deletions module/VuFind/src/VuFind/Navigation/AbstractMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public function getMenu(): array
$menu = $this->config;
if (!$menu) {
$menu = $this->getDefaultMenu();
} elseif ($menu['MenuItems'] ?? false) {
// backward compatibility for outdated configurations
} elseif ($this instanceof AccountMenu && $menu['MenuItems']) {
// backward compatibility for outdated AccountMenu configurations
$default = $this->getDefaultMenu();
$default['Account']['MenuItems'] = $menu['MenuItems'];
$menu = $default;
Expand Down
76 changes: 40 additions & 36 deletions module/VuFind/src/VuFind/Navigation/AdminMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,44 +58,48 @@ public function __construct(
*
* @return array
*/
protected function getDefaultItems(): array
protected function getDefaultMenu(): array
{
return [
[
'name' => 'home',
'label' => 'Home',
'route' => 'admin',
],
[
'name' => 'socialstats',
'label' => 'Social Statistics',
'route' => 'admin/social',
],
[
'name' => 'config',
'label' => 'Configuration',
'route' => 'admin/config',
],
[
'name' => 'maintenance',
'label' => 'System Maintenance',
'route' => 'admin/maintenance',
],
[
'name' => 'tags',
'label' => 'Tag Maintenance ',
'route' => 'admin/tags',
],
[
'name' => 'feedback',
'label' => 'Feedback Management',
'route' => 'admin/feedback',
],
[
'name' => 'overdrive',
'label' => 'od_admin_menu',
'route' => 'admin/overdrive',
'checkMethod' => 'checkShowOverdrive',
'Admin' => [
'MenuItems' => [
[
'name' => 'home',
'label' => 'Home',
'route' => 'admin',
],
[
'name' => 'socialstats',
'label' => 'Social Statistics',
'route' => 'admin/social',
],
[
'name' => 'config',
'label' => 'Configuration',
'route' => 'admin/config',
],
[
'name' => 'maintenance',
'label' => 'System Maintenance',
'route' => 'admin/maintenance',
],
[
'name' => 'tags',
'label' => 'Tag Maintenance ',
'route' => 'admin/tags',
],
[
'name' => 'feedback',
'label' => 'Feedback Management',
'route' => 'admin/feedback',
],
[
'name' => 'overdrive',
'label' => 'od_admin_menu',
'route' => 'admin/overdrive',
'checkMethod' => 'checkShowOverdrive',
],
],
],
];
}
Expand Down
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/View/Helper/Root/AdminMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function render(?string $activeItem = null, string $idPrefix = ''): strin
return $this->getView()->render(
'admin/menu.phtml',
[
'items' => $this->getItems(),
'items' => $this->getMenu()['Admin']['MenuItems'],
]
);
}
Expand Down

0 comments on commit f5d2ddc

Please sign in to comment.