- Issue created by @swentel
- 🇷🇴Romania amateescu
I 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 trash
permission. - Status changed to Needs review
12 months ago 1:23pm 22 December 2023 - 🇧🇪Belgium swentel
Patch 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 'View deleted entities' permission as well to be able to restore?
Feedback welcome!
- Status changed to Needs work
12 months ago 1:53pm 22 December 2023 - 🇷🇴Romania amateescu
-
+++ b/trash.module @@ -203,8 +203,13 @@ function trash_form_alter(&$form, FormStateInterface $form_state, $form_id) { + if (isset($form['description']['#markup']) && $form['description']['#markup'] instanceof TranslatableMarkup && ($has_trash_access || $has_restore_access)) {
This 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.
-
+++ b/trash.module @@ -212,12 +217,25 @@ function trash_form_alter(&$form, FormStateInterface $form_state, $form_id) { + $form['description']['#markup'] = t($entity_delete_label, $params); ... + $form['description']['#markup'] = t($entity_multiple_delete_label, $params);
t()
can't translate variables, we need to wrap each message above in t() calls :)
-
- Status changed to Needs review
12 months ago 2:37pm 22 December 2023 - 🇧🇪Belgium swentel
I 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. - 🇷🇴Romania amateescu
Tweaked the patch a bit to follow a "highest" to "lowest" access level:
- if the user has
restore
access, having "view deleted" is (logically) implied, so we show the full message
- if the user has onlyview deleted
access, 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 -
amateescu →
committed 19771aae on 3.x
Issue #3408762 by swentel, amateescu: Different message on delete form...
-
amateescu →
committed 19771aae on 3.x
- Status changed to Fixed
9 months ago 12:08pm 25 March 2024 Automatically closed - issue fixed for 2 weeks with no activity.