This is a child issue of #2906470: Orphan comments and entries in comment_entity_statistics after comment field instance has been deleted. Based on the recommendation by @andypost and @larowlan, this UI part should be handled as a separate child issue.
Problem/Motivation
When a comment field instance is deleted for example from a node content type, we are currently showing the warning below.
The site builder is currently not being explicitly warned that deleting the comment field will also delete all the comments of that comment field instance.
Proposed resolution
In addition to the current "Are you sure you want to delete the field {Comment field name}? This action cannot be undone." warning, the site builder should be shown a message: All comments of this comment field will be deleted.
If we want to make this more generic and to improve the site builder UX for all field deletions, we could re-phrase the This action cannot be undone warning as All content of this field will be permanently deleted. This action cannot be undone.
Remaining tasks
- Decide if we want to make Comment module specific warning or improve this so that the same warning will be shown for all field deletions.
- Patch
- Review
- Commit
User interface changes
Yes, see proposed resolution above.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#23 | interdiff_8-21.txt | 655 bytes | bhanuprakashnani |
#21 | comment-field-delete-form-warning-2908607-21.patch | 661 bytes | msankhala |
#16 | field-delete-warning-message.png | 217.75 KB | msankhala |
#9 | show-warning-field-deleted-2908607-8.patch | 623 bytes | msankhala |
Comments
Comment #2
masipila CreditAttribution: masipila as a volunteer commentedComment #3
andypostComment #5
dillix CreditAttribution: dillix commentedIs this issue actual?
Comment #6
andypostYes, it still makes sense to warn user about deletion of all comments the deleted field provides
Comment #7
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commented@masipila I think to make a generic deletion message for all fields make more sense and easiest to do. Deletion question is coming
from Drupal/Core/Entity/EntityDeleteFormTrait::getQuestion()
and description is coming fromDrupal/Core/Entity/EntityConfirmFormBase::getDescription()
We can simply change getDescription to return warning as well.To make Comment module specific warning will require more work and testing. Thoughts?
Comment #8
masipila CreditAttribution: masipila as a volunteer commentedThe more generic approach sounds like a plan to me!
Comment #9
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedSimplest possible solution.
Comment #10
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedComment #11
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedThe patch applies cleanly. The changes made are sufficient.
Comment #12
andypostno-go for global override, probably comment module should alter
\Drupal\field_ui\Form\FieldConfigDeleteForm
when comment field is deletedComment #13
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedComment #14
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commented@andypost This is not a global override. We are modifying the global field delete message and adding a warning to the message, which kind of make sense to show a warning that If you delete this field all the content of this field are going to be deleted permanently. Thoughts?
Can you please give input on how can comment module alter
\Drupal\field_ui\Form\FieldConfigDeleteForm
if comment field is being deleted. There is a\Drupal\comment\Form\CommentTypeDeleteForm
but this is for comment type deletion.Comment #15
andypostComment #16
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedScreenshot after applying this patch.
Comment #17
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedComment #18
andypost@msankhala thanx, now check delete form for any other field...
That's why I suggest to override comment delete form only to point that only comments from this field will be deleted
Basically not every field will delete some entities - guess paragraphs will need that as well)
what is "All the contents" means in scope of any field?
Comment #19
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commented@andypost I think 'All the contents' is not that confusing because if you are deleting a field then definitely all the contents of that field are going to be deleted, no matter what kind of field is that.
But I am happy to override this message only for comment field. I'll need your help in this. Do we need a new class something like
\Drupal\comment\Form\CommentFeildConfigDeleteForm
which will extend\Drupal\Core\Entity\EntityDeleteForm
? or there is any better approach?Comment #20
andypost@msankhala I think better to add hook form_id alter cos you need to change only a message for specific condition
Comment #21
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedHere is a new patch to display warning message specific to comment field deletion. Do we really need a test for this? We can create another issue to test this.
Comment #22
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commentedComment #23
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedI made the interdiff for the patches 8 and 21.
Comment #24
dravenk@msankhala
I was test patch #21 , It is little confused
1. create a article and submit comment
2. git apply comment-field-delete-form-warning-2908607-21.patch
3. delete field comment from article type
4. goto comment manager page /admin/content/comment
You will see the comment still here but clicking the comment link leads to errors. The actual situation is inconsistent with the description.
Comment #25
masipila CreditAttribution: masipila as a volunteer commentedRe #24: that's because the parent issue has not landed yet.
Postponing this on #2906470: Orphan comments and entries in comment_entity_statistics after comment field instance has been deleted.
Comment #26
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commented@dravenk Thanks for reviewing. Yes as @masipila mentioned actual comment not being deleted is related to another issue. The scope of this issue is only showing the proper warning message on comment field delete form.
Comment #27
dravenk@masipila
Thank you for finding the reason. Now that looks good.
Comment #28
masipila CreditAttribution: masipila as a volunteer commentedThanks for taking the time to review and test @dravenk! I'm changing the status back to 'Postponed' so that this won't be accidentally committed before the parent issue lands.
Comment #29
msankhala CreditAttribution: msankhala as a volunteer and at Srijan | A Material+ Company commented@masipila I think this has no dependency on the related issue, this is only about showing the warning. I think this can be committed. No?
Comment #30
masipila CreditAttribution: masipila as a volunteer commentedWell to me it would be confusing to the max to show an explicit warning in the UI that 'comments will be deleted if you proceed' and then leave orphans to the database.
It already confused a contributor in #24 so I can only imagine the amount of confusion it would create in an average site builder.
I'll leave the decision to the comment module maintainers and core committers, this is just my 2 cents.
Cheers,
Markus