nova-telescope
nova-telescope copied to clipboard
Sidebar link does not respect the viewTelescope Gate
Thank you for the package, it works really well.
As mentioned in the title, the sidebar link does not respect the viewTelescope Gate and is shown permanently.
For example:
// App\Providers\TelescopeServiceProvider
Gate::define('viewTelescope', function ($user) {
// return in_array($user->email, [
'[email protected]'
// ]);
});
When a user logs in on the production environment with a non-whitelisted email they still see the "Telescope" link in the sidebar. When clicking the link it 403's as expected though.
Would it be possible to show/ hide this link based on the gate result?
----EDIT----
Or maybe the navigation.blade.php
view can be made publishable so users can modify themselves. This would also allow users to change the text/ styling etc.
Hi @atmediauk, thanks for writing in! This looks like a compelling feature. I haven't run into the problem, because I have been handling permissions differently: namely by conditionally adding the tool in Nova, depending on user role.
What you suggest makes a lot of sense. If you can get a PR in, I will be happy to look at it. I can't promise how fast I can get to adding this myself. :)
Thanks for the speedy reply. Sure, I'll have a go now 🙌
Pull request here 😊 https://github.com/GeneaLabs/nova-telescope/pull/10
You can also register the tool like this, and it will respect the viewTelescope
ability.
/**
* Get the tools that should be listed in the Nova sidebar.
*
* @return array
*/
public function tools()
{
return [
(new NovaTelescope)->canSeeWhen('viewTelescope'),
];
}
@madsem Thanks for supplying that alternative solution. I like that. I'll update the documentation.