resource-navigation-tab icon indicating copy to clipboard operation
resource-navigation-tab copied to clipboard

Hide/Show Tab

Open ErenPhayte opened this issue 3 years ago • 3 comments

Is there a way to hide/show tab based on rules i.e. permissions or any other rules based on the values of a Resource?

ErenPhayte avatar Feb 23 '21 10:02 ErenPhayte

You can always do something like this:

class ExampleNovaResource extends Resource {

    public function fields(Request $request)
    {
        if($request->user()->can(.....)) {
            return [
                ResourceNavigationTab::make([ 'label' => 'Only for admin' ]),
            ];
        }

        return [
            ResourceNavigationTab::make([ 'label' => 'Public' ]),
        ];
    }

}

milewski avatar Feb 23 '21 11:02 milewski

Thanks. But what if its needs to show or hide by Resource values I.e. I have Pages and you can clone them. Only for pages that have been cloned I want a tab that shows which pages were the clone (children parent relationship)

On Tue, 23 Feb 2021, 13:03 Rafael Milewski, [email protected] wrote:

You can always do something like this:

class ExampleNovaResource extends Resource {

public function fields(Request $request)
{
    if($request->user()->can(.....)) {
        return [
            ResourceNavigationTab::make([ 'label' => 'Only for admin' ]),
        ];
    }

    return [
        ResourceNavigationTab::make([ 'label' => 'Public' ]),
    ];
}

}

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dcasia/resource-navigation-tab/issues/35#issuecomment-784118214, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKWBB2XLECX3ZL65HA5WFLTAODO5ANCNFSM4YCH4NJQ .

ErenPhayte avatar Feb 23 '21 11:02 ErenPhayte

I think its still the same concept, you dynamically build the array of fields based on your condition.. if you need 3 tabs.. return 3 instances of ResourceNavigationTab .. so on..

milewski avatar Feb 23 '21 11:02 milewski