log-viewer icon indicating copy to clipboard operation
log-viewer copied to clipboard

Does not properly load its API inside Laravel Nova

Open dm-pf opened this issue 2 years ago • 3 comments

Hi, thanks for this awesome package ❤️ .

I've tried using it inside my Laravel Nova project - and the way Nova loads external-to-nova URIs is by loading them in a dialog window through an

image

It seems that because the /log-viewer is loaded through an iframe - it loses track of the correct URI path to load its api/folders.

dm-pf avatar Apr 13 '23 16:04 dm-pf

Hey @dm-pf can you share how you've added a link to the Log Viewer?

I'm not a Nova user, but I think what you're looking for is this:

use Laravel\Nova\Menu\MenuItem;

MenuItem::externalLink('Log Viewer', route('log-viewer.index'))

This is taken from Nova v4 docs btw:

https://nova.laravel.com/docs/4.0/customization/menus.html#menu-items

arukompas avatar Apr 14 '23 03:04 arukompas

Hi @arukompas - using MenuItem::externalLink() (or MenuItem::path()->external() in my case) redirects to that URL which is exactly what I did after stumbling upon the above issue. Ideally, I would like to use it this way instead:

MenuSection::make('Log Viewer')
    ->path('/log-viewer')
    ->icon('lightning-bolt'),

Because that way I don't need to "get out" of my Dashboard and I can just load external tools in a dialog window. E.g. Laravel Horizon works fine this way.

Even though my use case is a bit particular (I doubt many people are using Nova) - I thought that reporting this would be a good idea because the issue itself could be triggered in other similar situations if not handled properly.

Thanks.

dm-pf avatar Apr 14 '23 11:04 dm-pf

Screenshot 2023-06-12 at 17 33 35

how can i use log-viewer in laravel nova. v1.9.1 is working but 2.* is not working

asad6ek avatar Jun 12 '23 12:06 asad6ek

@arukompas Something has been changed i think.

Depending where you are in nova the url of the menu item is for correct for example `https://dashboard.test/log-viewer' The moment you click the log-viewer menu item the internal path changes to where you are. log-viewer is resolving the route as relative path within its own dashboard API (dashboards/main/api/folders) or (resources/applications/api/folders)

//NovaServiceProvider.php
MenuItem::link(__('Logs'), '/log-viewer'),

whitespacecode avatar Jan 31 '25 09:01 whitespacecode