chris-ware / nova-breadcrumbs

Breadcrumbs for Laravel Nova
152 stars 44 forks source link

Breadcrumbs empty in ressource Action Event (resources/action-events/937) #96

Closed issour closed 4 years ago

issour commented 4 years ago

it show Home / / Many thx !

chris-ware commented 4 years ago

Have you added the Breadcrumbs trait to the Resource class as per the documentation?

If not, I need more information.

issour commented 4 years ago

Hi, @chris-ware

The Breadcrumbs nova package is perfect !! is showing in all resource except the Action Log (url : .../action-events). In fact when you use the Actionable trait in User Model, Nova provide in left side barre Link to Action : Capture d’écran 2020-05-06 à 00 59 50

when you hit the link the Breadcrumbs is showing correctly : Capture d’écran 2020-05-06 à 01 02 14

But if you click in detail on each row the Breadcrumbs is showing : Capture d’écran 2020-05-06 à 01 02 25

Many Thx !!!

chris-ware commented 4 years ago

I've looked into this, and the reason for this, is exactly as I've said above. The Action resource provided by Nova by default doesn't extend your local Resource file but rather Nova's default one so the Breadcrumb trait isn't available on it. You need to extend the Action resource to add the Breadcrumbs trait.

issour commented 4 years ago

Thx for looking into this !! How i can extend Action resource without touching nova vendor folder?

gldrenthe89 commented 4 years ago

This issue now gives an error with version 2.0 not showing the breadcrumb is fine. but the red exception is not.

afbeelding

Please reopen!

chris-ware commented 4 years ago

I'm fairly certain there would be a way to extend the ActionResource and tell Nova to use your custom one instead of the default one.

I have no use of the ActionResource, so haven't come across this problem.

If you can't find a way to solve this, I'd suggest one of two things. Firstly, raise an issue on Nova as to why you can't extend the ActionResource. Secondly, if that isn't possible, I'd happily accept a PR that can solve this issue in a way that causes no issues with other use cases.

Failing all the above, provide an example project that replicates your issue, so that myself or someone else can try and come up with a solution for you. Just remeber to not commit Nova files as that is against their license

gldrenthe89 commented 4 years ago

I'm fairly certain there would be a way to extend the ActionResource and tell Nova to use your custom one instead of the default one.

I have no use of the ActionResource, so haven't come across this problem.

If you can't find a way to solve this, I'd suggest one of two things. Firstly, raise an issue on Nova as to why you can't extend the ActionResource. Secondly, if that isn't possible, I'd happily accept a PR that can solve this issue in a way that causes no issues with other use cases.

Failing all the above, provide an example project that replicates your issue, so that myself or someone else can try and come up with a solution for you. Just remeber to not commit Nova files as that is against their license

Hi Chris, It is actually very simple to recreate. If you create a resource named ActionEvent (it can point to a random model) the built in resource is activated. Nothing in the newly created ActionEvent resource does a thing. It completely ignores it.

Isnt there a way of disabling the breadcrumb for this given resource? the should be a way to check if the loaded resource is the ActionEvent resource.

As for a PR. i currently don't have the time available to take a deeper look in this. If i find the time i will do so.

Thanks for the quick response btw. very much appreciated

chris-ware commented 4 years ago

If you have a resource, then yes, just add a breadcrumbs method that returns false.

I'll add it so it checks if the bredcrumbs method exists on the resource, which would, I think, solve your issue with no code changes on your side. Not sure when I'll be able to do that, but I'll see what I can do.

gldrenthe89 commented 4 years ago

If you have a resource, then yes, just add a breadcrumbs method that returns false.

I'll add it so it checks if the bredcrumbs method exists on the resource, which would, I think, solve your issue with no code changes on your side. Not sure when I'll be able to do that, but I'll see what I can do.

That be a good solution to. I will also get in contact with Tayler and the Nova team about being able to extend the ActionResource file (which is actually loaded from vendor dir) so also other Nova customization options will become available

gldrenthe89 commented 4 years ago

I just found out there is actually a setting in the Nova.php file which let you set the ActionEvent resource:

/*
    |--------------------------------------------------------------------------
    | Nova Action Resource Class
    |--------------------------------------------------------------------------
    |
    | This configuration option allows you to specify a custom resource class
    | to use instead of the type that ships with Nova. You may use this to
    | define any extra form fields or other custom behavior as required.
    |
    */

    'actions' => [
        'resource' => ActionEvent::class,
    ],

I have my ActionEvent.php resource class extend to the original \Laravel\Nova\Actions\ActionResource This way i can even use the breadcrumbs.

it is set-up like this now:

<?php

namespace App\Nova;

use ChrisWare\NovaBreadcrumbs\Traits\Breadcrumbs;
use Illuminate\Http\Request;
use Laravel\Nova\Actions\ActionResource;

class ActionEvent extends ActionResource
{
    use Breadcrumbs;

    /**
     * The visual style used for the table. Available options are 'tight' and 'default'.
     *
     * @var string
     */
    public static $tableStyle = 'tight';

    /**
     * Whether to show borders for each column on the X-axis.
     *
     * @var bool
     */
    public static $showColumnBorders = true;

    /**
     * The logical group associated with the resource.
     *
     * @var string
     */
    public static $group = 'Logging';

    /**
     * Determine if this resource is available for navigation.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return bool
     */
    public static function availableForNavigation(Request $request)
    {
        return true;
    }
}

I hope this helps other people as well.