File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed
demo/app/Sharp/Dashboard/Commands Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,11 @@ public function buildFormFields(FieldsContainer $formFields): void
3838 );
3939 }
4040
41+ public function authorize (): bool
42+ {
43+ return auth ()->user ()->isAdmin ();
44+ }
45+
4146 public function execute (array $ data = []): array
4247 {
4348 $ this ->validate ($ data , [
Original file line number Diff line number Diff line change @@ -38,18 +38,14 @@ export class Dashboard {
3838 }
3939
4040 get visibleCommands ( ) : ConfigCommandsData {
41- if ( this . hiddenCommands ) {
42- return Object . fromEntries (
43- Object . entries ( this . config . commands ?? { } ) . map ( ( [ key , commands ] ) => [
44- key ,
45- commands . map ( group => group . filter ( command => {
46- return ! this . hiddenCommands . includes ( command . key ) ;
47- } ) )
48- ] )
49- ) ;
50- }
51-
52- return this . config . commands ;
41+ return Object . fromEntries (
42+ Object . entries ( this . config . commands ?? { } ) . map ( ( [ key , commands ] ) => [
43+ key ,
44+ commands . map ( group => group . filter ( command => {
45+ return command . authorization && ! this . hiddenCommands ?. includes ( command . key ) ;
46+ } ) )
47+ ] )
48+ ) ;
5349 }
5450
5551 sectionVisibleFilters ( section : DashboardLayoutSectionData ) {
You can’t perform that action at this time.
0 commit comments