Skip to content

Commit d0ccc01

Browse files
committed
Refactor dashboard cards to conditionally display admin resources
1 parent d322b98 commit d0ccc01

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

app/Nova/Dashboards/Main.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public function cards()
3737
}, session('role'));
3838

3939
$quotes = Inspiring::show();
40-
41-
return [
40+
$cards = [
4241
Greeter::make()
4342
->user(name: Auth::user()->name, title: Auth::user()->email)
4443
->message(text: __('Welcome Back!'))
@@ -51,18 +50,6 @@ public function cards()
5150
->verified(text: $quotes['author'])
5251
->avatar(url: Storage::disk('images')->url('quotes.svg'))
5352
->width('1/2'),
54-
ServerResource::make()
55-
->width('1/2')
56-
->canSee(fn () => Policy::make()->allowedFor('admin')->get()),
57-
ServerResource::make('inode')
58-
->width('1/2')
59-
->canSee(fn () => Policy::make()->allowedFor('admin')->get()),
60-
Issues::make('outdated')
61-
->width('1/2')
62-
->canSee(fn () => Policy::make()->allowedFor('admin')->get()),
63-
Issues::make()
64-
->width('1/2')
65-
->canSee(fn () => Policy::make()->allowedFor('admin')->get()),
6653
Welcome::make()
6754
->title('Permulaan') // optional
6855
->description('Selamat datang di Aplikasi Simpede. Berikut adalah fitur-fitur yang tersedia:') // optional
@@ -79,5 +66,21 @@ public function cards()
7966
->addItem(icon: 'calendar', title: 'Kalender Kegiatan', content: 'Fitur yang menampilkan kalender kegiatan,deadline dan tanggal penting lainnya. Selain itu juga mengirimkan reminder deadline kegiatan melalui Whatsapp (Aktualisasi Latsar Ilman Mimin Maulana)')
8067
->addItem(icon: 'document-chart-bar', title: 'Pengelolaan SAKIP', content: 'Fitur untuk pencatatan realisasi kinerja, kendala dan solusi, rencana dan pelaksanaan tindak lanjut dalam rangka pencapaian target kinerja.'),
8168
];
69+
if (Policy::make()->allowedFor('admin')->get()) {
70+
$cards[] = ServerResource::make()
71+
->width('1/2');
72+
73+
$cards[] = ServerResource::make('inode')
74+
->width('1/2');
75+
76+
$cards[] = Issues::make('outdated')
77+
->width('1/2');
78+
79+
$cards[] = Issues::make()
80+
->width('1/2');
81+
82+
}
83+
84+
return $cards;
8285
}
8386
}

0 commit comments

Comments
 (0)