Comments (11)
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.
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.
@fbingha fixed on version v0.1.9
from collapsible-resource-manager.
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.
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.
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.
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.
@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.
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.
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.
@fbingha the new version supports everything you were trying to do on your branch v1.0.0 🎉
from collapsible-resource-manager.
Related Issues (20)
- Incorrect path MenuSection HOT 6
- Fix design issue
- Feature request: Ability to keep default notification & logout & theme
- Dashboards link doesn't works HOT 3
- There is an extra space between resources and menu not sure why? HOT 1
- Features request: nested navigation and panel width
- Menu doesn't scroll on mobile device HOT 6
- Iconset for menu? HOT 1
- Menu issue on mobile devices HOT 5
- Breaking word to a new line if menu item is too long HOT 2
- Collapsing doesn't work after release v2.0.5 HOT 1
- New feature: close side panel manually HOT 9
- Enable/Disable Toggle Switch HOT 3
- Collapse menu after refresh HOT 1
- Markdown field width split when attribute name is `content`
- Scroll is necesary for desktop too
- Page doesn't scroll when Menu is opened HOT 4
- Cannot read properties of undefined (reading 'isMobile') HOT 4
- Keep menu open by default
- Fixed Header and Sidebar HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from collapsible-resource-manager.