Closed ryangjchandler closed 3 years ago
Another idea I had for this was also having permission checks for pages. I'm a big fan of the Nova API for this:
'pages' => [
(new ExamplePage)->canSee(function (Request $request) {
return false;
})
]
Then, inside of Nebula's PageController
, simply run that function and pass the current request through. If it returns false, then throw an AuthorizationException
.
I've just added support for NebulaPage::canSee()
. It works exactly like the example above, allowing users to check the user, do permission checks, etc. It throws an AuthorizationException
when the callback returns false
.
The only thing I'm not sure about it having the Pages
label in the menu, because the archetype is a page, but the actual usage of them might not be. This would also make it harder for developers to group multiple pages together (perhaps another future feature..)
This PR enables users to build and register custom pages within the Nebula panel.
It introduces a new
php artisan nebula:page
command that will generate a new class inapp/Nebula/Pages
, as well as a view underresources/views/nebula/pages
.To register a new page, you follow the same pattern as the dashboards and resources, adding
new PageClass
under thenebula.pages
configuration option.The idea for these pages is similar to Laravel Nova's custom tools. Have a uniform API that allows developers to build third-party extensions for Nebula.
I've named them pages because using the term Tool felt too similar to Nova, but I'm happy to change this.
It's also worth noting that the developer doesn't need to use the
nebula::layouts.shell
view in their pages view, since it will automatically be wrapped in it. Instead, they only need to worry about what their page will display.The page also moves away from the
singularName()
andpluralName()
pattern that the resources & dashboards follow because it didn't make much sense here. Instead theNebulaPage::name()
method will be used for displaying the menu item and the page title.For the URL slug / route binding, a new
NebulaPage::slug()
method has been introduced which will be used to match the page.Happy to hear thoughts and ideas on this - this was the simplest implementation after all. 🤗