Skip to content

Commit 47dc286

Browse files
committed
Timesheet permissions
1 parent 3b7fe54 commit 47dc286

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

app/Filament/Pages/TimesheetDashboard.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ class TimesheetDashboard extends Page
1111
{
1212
protected static ?string $slug = 'timesheet-dashboard';
1313

14-
protected static ?int $navigationSort = 1;
14+
protected static ?int $navigationSort = 2;
1515

1616
protected static string $view = 'filament::pages.dashboard';
1717

18-
protected static bool $shouldRegisterNavigation = false;
19-
2018
protected function getColumns(): int | array
2119
{
2220
return 6;
@@ -32,6 +30,11 @@ protected static function getNavigationGroup(): ?string
3230
return __('Timesheet');
3331
}
3432

33+
protected static function shouldRegisterNavigation(): bool
34+
{
35+
return auth()->user()->can('View timesheet dashboard');
36+
}
37+
3538
protected function getWidgets(): array
3639
{
3740
return [

app/Filament/Resources/TimesheetResource.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class TimesheetResource extends Resource
2323

2424
protected static ?int $navigationSort = 4;
2525

26-
protected static bool $shouldRegisterNavigation = false;
27-
2826
protected static function getNavigationLabel(): string
2927
{
3028
return __('Timesheet');
@@ -40,6 +38,11 @@ protected static function getNavigationGroup(): ?string
4038
return __('Timesheet');
4139
}
4240

41+
protected static function shouldRegisterNavigation(): bool
42+
{
43+
return auth()->user()->can('List timesheet data');
44+
}
45+
4346
public static function form(Form $form): Form
4447
{
4548
return $form

database/seeders/PermissionsSeeder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class PermissionsSeeder extends Seeder
2626
];
2727

2828
private array $extraPermissions = [
29-
'Manage general settings', 'Import from Jira'
29+
'Manage general settings', 'Import from Jira',
30+
'List timesheet data', 'View timesheet dashboard'
3031
];
3132

3233
private string $defaultRole = 'Default role';

0 commit comments

Comments
 (0)