Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title resources is showing even though no permissions #71

Open
TowlieeNetworks opened this issue Jun 21, 2022 · 1 comment
Open

Title resources is showing even though no permissions #71

TowlieeNetworks opened this issue Jun 21, 2022 · 1 comment

Comments

@TowlieeNetworks
Copy link

title resources is showing even though the user does not have any of the appropriate permissions set for the resource menu items.
This can be fixed with a simple if statement in the "vendor\orchid\crud\src\Arbitrator.php" @ "registerMenu"

`private function registerMenu(Resource $resource, int $key): Arbitrator
{
if (! $resource::displayInNavigation()) {
return $this;
}

    View::composer('platform::dashboard', function () use ($resource, $key) {
        
        if (user()->hasAnyAccess('manage-crud-resource-*')) {
            $title = Menu::make()
                ->canSee($key === 0)
                ->title(__('Resources'))
                ->sort($resource::sort());
            Dashboard::registerMenuElement(\Orchid\Platform\Dashboard::MENU_MAIN, $title);
        }

        $menu = Menu::make($resource::label())
            ->icon($resource::icon())
            ->route('platform.resource.list', [$resource::uriKey()])
            ->active($this->activeMenu($resource))
            ->permission($resource::permission())
            ->sort($resource::sort());
        Dashboard::registerMenuElement(\Orchid\Platform\Dashboard::MENU_MAIN, $menu);
    });

    return $this;
}`
@TowlieeNetworks TowlieeNetworks changed the title title resources is showing even though no permissions Title resources is showing even though no permissions Jun 21, 2022
@szonov
Copy link
Contributor

szonov commented Jul 29, 2022

Looks like proposed 'manage-crud-resource-*' is your application specific permissions, as well as user() function, and should not be part of library.
Just implement valid displayInNavigation() function in every resource (which can depends on your application logic/permissions) and title 'Resources' will disappear :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants