Giter VIP home page Giter VIP logo

Comments (11)

milewski avatar milewski commented on September 27, 2024 1

With this approach would also allow users to create internal links that don't go to index listing page but perhaps detail, or edit.

'resources' => [
    \App\Nova\Page::class, 
    'Internal Link' => '/custom/route',
    'Resource Label' => [
        'resource' => ResourceName::class,
        'params' => [ 'resourceName' => ResourceName::uriKey(), 'id' => 3 ] ,
        'name' => 'detail'
     ]
],

It`s a bit verbose and requires the user knowing all the underlying params but given enough examples one could find a way around it ...

from collapsible-resource-manager.

milewski avatar milewski commented on September 27, 2024

Just tried and yeah its a regression, this is how it should work:

[
    'title'     => 'Menu Item',
    'expanded'  => false,
    'resources' => [
        'Internal' => '/item', // this opens on the same tab, and no icon is added
        'External' => 'https://...' // this add an extra icon beside the link and opens in a new tab
    ]
],

I will look into it see what went wrong on the latest version

from collapsible-resource-manager.

milewski avatar milewski commented on September 27, 2024

@fbingha fixed on version v0.1.9

from collapsible-resource-manager.

fbingha avatar fbingha commented on September 27, 2024

Okay it is working now but one more request. I want to use the link to a Nova tool, so I put the path and it works but the browser page reloads since it isn't using the internal vue route to open the tool. Can you add an option to use a vue route so the single page app isn't broken when following the link?

from collapsible-resource-manager.

fbingha avatar fbingha commented on September 27, 2024

Looking at the code, going to be a bit more complicated to add links to tools as they will also need to respect permissions. The goal is to remove the links that tools add and just have navbar entries from this tool. If the config could support (a) being told what permission(s) to check and (b) what vue route to load then I think it could be done without knowing anything specific about the tool being linked to.

from collapsible-resource-manager.

fbingha avatar fbingha commented on September 27, 2024

Another way to do this requires changing nothing in the config.

I created resources for each of my tools so that permissions and uriKey could be utilized. The only issue is in ResourceList.vue. When a resource is found, it is assumed the the 'index' route is to be used for the resource.route. So just need away to have the :to{} params name and params links be read from the resource object.

:to="{ name: resource.link , params: resource.params }

from collapsible-resource-manager.

fbingha avatar fbingha commented on September 27, 2024

I made some quick hacks to my branch https://github.com/fbingha/collapsible-resource-manager

Here, I already had "fake" resources for my Tools as I was already putting them into the sidebar along with other resources that they grouped with. I use view overrides to remove the normal navigation links that tools put into the sidebar.

So in my "fake" resources, I added a two class variables:

public static $nonIndex = true;

public static $params = [];

The first tells your tool not to use the index route, instead use the urikey as the route and second a params in the event the route has params, which some of mine do.

With this, I now have all of the tools in the menu where they belong.

Using the fake resource also allows me to use the existing permissions check.

I still think it would probably be easier for you to adjust your config so that with the resource group one could provide the route name, the params, and the permissions to check and not create a fake resource as I have done.

from collapsible-resource-manager.

milewski avatar milewski commented on September 27, 2024

@fbingha Im looking into your fork, I am not sure why you changed this if condition with index/params: https://github.com/fbingha/collapsible-resource-manager/blob/master/src/CollapsibleResourceManager.php#L111

The way im seeing it working would be something along this line:

'resources' => [
    \App\Nova\Page::class, 
    'Internal Link' => '/custom/route',
    'Tool' => [
        'params' => [ 'a' => '123'] ,
        'name' => 'yyy'
     ]
],

which would then be given to the route-link like this:

<router-link :to="{ name: resource.name, params: resource.params }"/>

But what im unsure is how a user would know the route name/params of a tool without digging up the package and figuring it out on their own?

from collapsible-resource-manager.

milewski avatar milewski commented on September 27, 2024

And the permission could also be solved by perhaps sending the tool class itself to the config:

'resources' => [
    \App\Nova\Page::class, 
    'Internal Link' => '/custom/route',
    'Tool Label' => [
        'tool' => ToolName::class,
        'params' => [ 'a' => '123'] ,
        'name' => 'yyy'
     ]
],

and somewhere before sending the response back to client call authorizedToSee() on that ToolName::class to remove itself from the response

from collapsible-resource-manager.

fbingha avatar fbingha commented on September 27, 2024

Looks good to me.

I have alot of custom tools that I’ve written so I know the route names and params. Adding authorizeToSee on the tool class is a good solution to the permissions problem.

from collapsible-resource-manager.

milewski avatar milewski commented on September 27, 2024

@fbingha the new version supports everything you were trying to do on your branch v1.0.0 🎉

from collapsible-resource-manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.