bolechen / nova-activitylog

A tool to activity logger to monitor the users of your Laravel Nova.
MIT License
94 stars 29 forks source link

Duplicate "Activity Logs" entry in the menu #40

Open brunocoelhosilva opened 11 months ago

brunocoelhosilva commented 11 months ago

Hi there,

In the documentation it only shows "Activity Logs" in the menu once, but in my case it also appears within Resources. Is this expected? I would like only the bottom one to appear. Thanks.

Screenshot 2023-11-24 at 09 24 41

robbanl commented 11 months ago

I am facing the same issue

bolechen commented 11 months ago

Whats laravel & nova version do you use?

robbanl commented 11 months ago

I'm using the most recent versions of each package:

Nova: 4.32.6 Laravel: 10.34.2

brunocoelhosilva commented 11 months ago

Nova:4.32.6 Laravel: 10.35.0

votkapower commented 11 months ago

Here is a fix:

  1. Create a new ActivityLog Resource and extend the original, and just disable the resources link

namespace App\Nova;

class Activitylog extends \Bolechen\NovaActivitylog\Resources\Activitylog { public static $displayInNavigation = false;

}



2.  Swap the model in the `nova-activitylog.php` config (publish it if you havent)
``` 'resource' => \App\Nova\ActivityLog::class,```
Now it will remove the link in the Resources section and only leave the link with the icon.

It worked for me. 
bolechen commented 11 months ago

Here is a fix:

  1. Create a new ActivityLog Resource and extend the original, and just disable the resources link

namespace App\Nova;

class Activitylog extends \Bolechen\NovaActivitylog\Resources\Activitylog
{
    public static $displayInNavigation = false;

}
  1. Swap the model in the nova-activitylog.php config (publish it if you havent) 'resource' => \App\Nova\ActivityLog::class, Now it will remove the link in the Resources section and only leave the link with the icon.

It worked for me.

I'm sorry for the inconvenience.For my own personal reasont, ican't have nova 4.x access, but thx for you help. I see the $displayInNavigation changed default to true by this PR #27 by @Kussie I want ask to Kussis, may I ask for your reasoning as to why you did what you did at the time?Does it need to be changed back?

Kussie commented 11 months ago

Here is a fix:

  1. Create a new ActivityLog Resource and extend the original, and just disable the resources link

namespace App\Nova;

class Activitylog extends \Bolechen\NovaActivitylog\Resources\Activitylog
{
    public static $displayInNavigation = false;

}
  1. Swap the model in the nova-activitylog.php config (publish it if you havent) 'resource' => \App\Nova\ActivityLog::class, Now it will remove the link in the Resources section and only leave the link with the icon.

It worked for me.

I'm sorry for the inconvenience.For my own personal reasont, ican't have nova 4.x access, but thx for you help. I see the $displayInNavigation changed default to true by this PR #27 by @Kussie I want ask to Kussis, may I ask for your reasoning as to why you did what you did at the time?Does it need to be changed back?

Without that change at the time it wouldn't appear at all if i recall. Given this hasnt been an issue until recently i wonder if there has been a change in Nova that has altered the behaviour. I no longer use Nova so i'm not sure

bolechen commented 11 months ago

thx @Kussie response. i change the flag default to false. Please try the latest version to see if it's working. Thanks to all for your help.

brunocoelhosilva commented 11 months ago

@bolechen Thanks for your help. However, when you set public static $displayInNavigation = false; both items in the menu disappear. My solution for now is to put public static $displayInNavigation = true; and remove new NovaActivitylog()from the tools method in NovaServiceProvider.php

bolechen commented 11 months ago

It looks like Nova 4 has refactored the Tools menu, since I personally don't have access to it, I'm hoping some kind soul can submit a PR, here's a link to the official instructions I found on it:

Customized Main Menu
If you have [customized Nova's main sidebar menu](https://nova.laravel.com/docs/menus.html#customizing-the-main-menu), a link to your tool will not automatically display in Nova's sidebar. You will need to manually define your tool's menu inside your custom Nova::mainMenu callback.

@ref https://nova.laravel.com/docs/customization/tools.html#navigation

Hide navigation link only in Resources and not everywhere: https://github.com/laravel/nova-issues/discussions/4368