ideas icon indicating copy to clipboard operation
ideas copied to clipboard

CP: Possiblity to add a Custom Asset Policy for hiding Assets under certain conditions

Open daerentis opened this issue 1 year ago • 4 comments

I tried adding an AssetPolicy class and binding it in my ServiceContainer.

$this->app->bind(\Statamic\Policies\AssetPolicy::class, AssetPolicy::class);

Unfortunately that does not work when returning false in the view() method.

daerentis avatar Oct 25 '24 12:10 daerentis

Are you logged in as a super user?

jasonvarga avatar Oct 25 '24 13:10 jasonvarga

No, i tested it for a non-super user.

daerentis avatar Oct 25 '24 14:10 daerentis

Looks like you're right. Some actions get disabled but you can still open up the editor and look at it.

Even if it worked, it wouldn't hide from listings. It would only prevent you from opening the editor. We'd need to introduce https://github.com/statamic/cms/pull/10479 but for assets.

But, if you customize edit to return false, it does at least stop you from saving the asset.

jasonvarga avatar Oct 25 '24 14:10 jasonvarga

A query hook for the assets would be really helpful in my case. 👌🏼

daerentis avatar Oct 26 '24 21:10 daerentis