Show infolist conditionally based on user role
On the Admin Panel if a particular resource has an infolist instead of the View page, is there a way enable access to the infolist only for a specific user role?
Passing an empty array for an infolist doesn't help as the table rows of the resource is still clickable. Any way to disable row clicks based on user role as an alternative?
13 Replies
You can use the recordAction() method on the table to override what action it runs when clicked (it accepts a callback so you can add in your logic there)
what would I do to disable the action for a certain user role?
so I use that for the recordAction ?
So let's say the role is "admin"
So when a user with the admin role clicks on the row, it'll open the infolist. If they don't it does nothing
tried that, that din't help, it still allows to click and goes to the infolist
Still not sure how to do this to give it a try
Oh wait I was being dumb, it's a different page isn't it. Not a modal?
correct
should I use recordUrl?
ya, that worked
Yeah, instead of passing the string 'view' you'll want to inject $record and use the getUrl method
Ah cool
Guess the string does work
so, I had to do this
Solution
Personally instead of typing out the url, do this:
Generates the URL properly as if you were using the route() helper
ok, let me try that
That works. thanks