When you delete an entity and trash is support for the type, you now get a message that is translable, which is fine of course.
However, I wonder whether it might be interesting to only override the message when you actually have access to restore the trashed entity? It might be a bit confusing for someone to read 'You can restore it from the trash at a later date if necessary' and not having any clue what this trash is in fact.
Marking as minor, I'd be fine even if you would close this as a won't fix since I could easily swap the hook and do it myself :)
Comments
Comment #2
swentel commentedComment #3
amateescu commentedI think it makes perfect sense to only show the last part of the message ("You can restore them from the trash at a later date if necessary.") if the user has permission to restore entities of that type :)
We should also change the first part of the message and not link to the Trash page if the user doesn't have the
access trashpermission.Comment #4
swentel commentedPatch attached.
While the message is fine now in case you do not have any permissions at all for trash, it feels a bit weird when, say, you can restore, but not view the trash bin. Also, I'm not sure if this by design, you seem to need to have the 'View deleted entities' permission as well to be able to restore?
Feedback welcome!
Comment #5
amateescu commentedThis means that the message won't change if the user can't access trash or can't restore entities. I think we still need to let them know that the entity is going to the trash rather than being (permanently) deleted.
t()can't translate variables, we need to wrap each message above in t() calls :)Comment #6
swentel commentedI had no clue t couldn't do that, after 15 years I think, my god :)
Simplified the patch, no interdiff because it's totally different.
The permission now checks 'restore entity_type_id entities', 'access trash' and 'view deleted entities' because without those 3, it's not useful to link or have a message about restore.
Comment #7
swentel commentedCrap, forget one line to pass one $params
Comment #8
amateescu commentedTweaked the patch a bit to follow a "highest" to "lowest" access level:
- if the user has
restoreaccess, having "view deleted" is (logically) implied, so we show the full message- if the user has only
view trashaccess, we hide the "restore" part of the message and link to the trash page- if the user has no access, we don't link to the trash page anymore
Comment #9
amateescu commentedUpdated the permission needed for the second case.
Comment #11
amateescu commentedCommitted #9 to 3.x, thanks!