Skip to content

Commit 7242752

Browse files
committed
Migrate main menu to configuration file
1 parent e16184f commit 7242752

3 files changed

Lines changed: 180 additions & 132 deletions

File tree

app/View/Components/MainMenu.php

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -16,113 +16,7 @@ class MainMenu extends Component
1616
*/
1717
public function __construct()
1818
{
19-
/**
20-
* Menu array definition
21-
*
22-
* 'route name' => 'menu item label'
23-
*/
24-
$this->menu = [
25-
'home' => [
26-
'title' => 'Overview',
27-
'icon' => 'fa-table-columns',
28-
'always_shown' => true,
29-
'show_notification_indicator' => false,
30-
'permissions' => ['']
31-
],
32-
'analytics' => [
33-
'title' => 'Analytics',
34-
'icon' => 'fa-chart-bar',
35-
'always_shown' => false,
36-
'show_notification_indicator' => false,
37-
'permissions' => ['Can view Analytics page']
38-
],
39-
'tickets' => [
40-
'title' => 'Tickets',
41-
'icon' => 'fa-ticket',
42-
'always_shown' => false,
43-
'show_notification_indicator' => false,
44-
'permissions' => ['Can view Tickets page']
45-
],
46-
'kanban' => [
47-
'title' => 'Kanban Board',
48-
'icon' => 'fa-clipboard-check',
49-
'always_shown' => false,
50-
'show_notification_indicator' => false,
51-
'permissions' => ['Can view Kanban page']
52-
],
53-
'administration' => [
54-
'title' => 'Administration',
55-
'icon' => 'fa-cogs',
56-
'always_shown' => false,
57-
'show_notification_indicator' => false,
58-
'permissions' => [
59-
'View all users', 'View company users',
60-
'View all companies', 'View own companies',
61-
'Manage ticket statuses',
62-
'Manage ticket types',
63-
'Manage ticket priorities',
64-
'View activity log'
65-
],
66-
'children' => [
67-
[
68-
'title' => 'Manage companies',
69-
'route' => 'administration.companies',
70-
'icon' => 'fa-building',
71-
'always_shown' => false,
72-
'permissions' => ['View all companies', 'View own companies']
73-
],
74-
[
75-
'title' => 'Manage users',
76-
'route' => 'administration.users',
77-
'icon' => 'fa-users',
78-
'always_shown' => false,
79-
'permissions' => ['View all users', 'View company users']
80-
],
81-
[
82-
'title' => 'Manage user roles',
83-
'route' => 'administration.roles',
84-
'icon' => 'fa-user-lock',
85-
'always_shown' => false,
86-
'permissions' => ['Manage user roles']
87-
],
88-
[
89-
'title' => 'Manage statuses',
90-
'route' => 'administration.ticket-statuses',
91-
'icon' => 'fa-square-check',
92-
'always_shown' => false,
93-
'permissions' => ['Manage ticket statuses']
94-
],
95-
[
96-
'title' => 'Manage types',
97-
'route' => 'administration.ticket-types',
98-
'icon' => 'fa-copy',
99-
'always_shown' => false,
100-
'permissions' => ['Manage ticket types']
101-
],
102-
[
103-
'title' => 'Manage priorities',
104-
'route' => 'administration.ticket-priorities',
105-
'icon' => 'fa-arrow-up',
106-
'always_shown' => false,
107-
'permissions' => ['Manage ticket priorities']
108-
],
109-
[
110-
'title' => 'Activity logs',
111-
'route' => 'administration.activity-logs',
112-
'icon' => 'fa-bell',
113-
'always_shown' => false,
114-
'permissions' => ['View activity log']
115-
]
116-
]
117-
],
118-
'notifications' => [
119-
'title' => 'Notifications',
120-
'icon' => 'fa-bell',
121-
'always_shown' => true,
122-
'show_notification_indicator' => true,
123-
'permissions' => ['']
124-
],
125-
];
19+
$this->menu = config('system.main_menu');
12620
}
12721

12822
/**

config/system.php

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,156 @@
1515
'fr' => 'Français'
1616
],
1717

18+
/*
19+
|--------------------------------------------------------------------------
20+
| Main menu configuration
21+
|--------------------------------------------------------------------------
22+
|
23+
| This value is the definition of the application main menu
24+
| Used in the 'App\View\Components\MainMenu' blade component
25+
|
26+
| Parameters:
27+
| -----------
28+
| - 'title' The translatable title of the menu
29+
|
30+
| - 'route' The menu route name
31+
|
32+
| - 'icon' The Fontawesome icon class
33+
| (icons list: http://fontawesome.io/icons/)
34+
|
35+
| - 'always_shown' If equals to "true" the menu is always shown without
36+
| checking permissions, if "false" the 'permissions' parameter
37+
| is used to show or not the menu item
38+
|
39+
| - 'show_notification_indicator' If equals to "true" the menu item will
40+
| show an indicator if there is notifications not read
41+
|
42+
| - 'permissions' The permissions used to show or not the menu item
43+
|
44+
| - (Optional) 'children' The sub menu items
45+
| - 'children.title' The translatable title of the sub menu
46+
|
47+
| - 'children.route' The sub menu route name
48+
|
49+
| - 'children.icon' The Fontawesome icon class
50+
| (icons list: http://fontawesome.io/icons/)
51+
|
52+
| - 'children.always_shown' If equals to "true" the menu is always
53+
| shown without checking permissions, if "false"
54+
| the 'permissions' parameter is used to show or not
55+
| the menu item
56+
|
57+
| - 'children.permissions' The permissions used to show or not
58+
| the menu item
59+
|
60+
*/
61+
'main_menu' => [
62+
[
63+
'title' => 'Overview',
64+
'route' => 'home',
65+
'icon' => 'fa-table-columns',
66+
'always_shown' => true,
67+
'show_notification_indicator' => false,
68+
'permissions' => ['']
69+
],
70+
[
71+
'title' => 'Analytics',
72+
'route' => 'analytics',
73+
'icon' => 'fa-chart-bar',
74+
'always_shown' => false,
75+
'show_notification_indicator' => false,
76+
'permissions' => ['Can view Analytics page']
77+
],
78+
[
79+
'title' => 'Tickets',
80+
'route' => 'tickets',
81+
'icon' => 'fa-ticket',
82+
'always_shown' => false,
83+
'show_notification_indicator' => false,
84+
'permissions' => ['Can view Tickets page']
85+
],
86+
[
87+
'title' => 'Kanban Board',
88+
'route' => 'kanban',
89+
'icon' => 'fa-clipboard-check',
90+
'always_shown' => false,
91+
'show_notification_indicator' => false,
92+
'permissions' => ['Can view Kanban page']
93+
],
94+
[
95+
'title' => 'Administration',
96+
'route' => 'administration',
97+
'icon' => 'fa-cogs',
98+
'always_shown' => false,
99+
'show_notification_indicator' => false,
100+
'permissions' => [
101+
'View all users', 'View company users',
102+
'View all companies', 'View own companies',
103+
'Manage ticket statuses',
104+
'Manage ticket types',
105+
'Manage ticket priorities',
106+
'View activity log'
107+
],
108+
'children' => [
109+
[
110+
'title' => 'Manage companies',
111+
'route' => 'administration.companies',
112+
'icon' => 'fa-building',
113+
'always_shown' => false,
114+
'permissions' => ['View all companies', 'View own companies']
115+
],
116+
[
117+
'title' => 'Manage users',
118+
'route' => 'administration.users',
119+
'icon' => 'fa-users',
120+
'always_shown' => false,
121+
'permissions' => ['View all users', 'View company users']
122+
],
123+
[
124+
'title' => 'Manage user roles',
125+
'route' => 'administration.roles',
126+
'icon' => 'fa-user-lock',
127+
'always_shown' => false,
128+
'permissions' => ['Manage user roles']
129+
],
130+
[
131+
'title' => 'Manage statuses',
132+
'route' => 'administration.ticket-statuses',
133+
'icon' => 'fa-square-check',
134+
'always_shown' => false,
135+
'permissions' => ['Manage ticket statuses']
136+
],
137+
[
138+
'title' => 'Manage types',
139+
'route' => 'administration.ticket-types',
140+
'icon' => 'fa-copy',
141+
'always_shown' => false,
142+
'permissions' => ['Manage ticket types']
143+
],
144+
[
145+
'title' => 'Manage priorities',
146+
'route' => 'administration.ticket-priorities',
147+
'icon' => 'fa-arrow-up',
148+
'always_shown' => false,
149+
'permissions' => ['Manage ticket priorities']
150+
],
151+
[
152+
'title' => 'Activity logs',
153+
'route' => 'administration.activity-logs',
154+
'icon' => 'fa-bell',
155+
'always_shown' => false,
156+
'permissions' => ['View activity log']
157+
]
158+
]
159+
],
160+
[
161+
'title' => 'Notifications',
162+
'route' => 'notifications',
163+
'icon' => 'fa-bell',
164+
'always_shown' => true,
165+
'show_notification_indicator' => true,
166+
'permissions' => ['']
167+
],
168+
],
169+
18170
];

0 commit comments

Comments
 (0)