Problem/Motivation
The comments attached to the entity has the attributes 'status' which controls whether comments can be seen/posted. But seems like no possibility to show that status in the views and not possibility to filter on that status.
P.S. It's very strange that I cannot find the issue related to this. Maybe I'm missing something.
Testing steps
- Apply the patch.
- Clear cache.
- Add/Edit the comment field of node.
- On Node Manage Display for the Comment field a new formatter should be available in the select list ("Comment Status").
- On selecting and saving the settings, this should show the comment status for each of the comment.
Proposed resolution
Seems like the filter plugin is already created but is not used anywhere. I propose to create field plugin which displays that status and add both plugins (field and filter) to field_views_data.
Seems like InOperator plugin feels very bad when options are instances of TranslatableMarkup. So for now I'm casting options to string. Maybe in the future it will be possible to find better solution.
Remaining tasks
Reviews needed.
User interface changes
None.
API changes
None.
Data model changes
None.

| Comment | File | Size | Author |
|---|---|---|---|
| #25 | Manage display _ TestSite.mp4 | 6.48 MB | deepalij |
| #25 | error.png | 742.31 KB | deepalij |
| #25 | php-error1.png | 726.33 KB | deepalij |
| #25 | 500 error.png | 33.83 KB | deepalij |
| #25 | after_patch.png | 148.84 KB | deepalij |
Comments
Comment #2
mpolishchuck commentedAdding the patch.
Comment #3
mpolishchuck commentedComment #6
kristen polNot sure if this should be considered for core, but patch applies cleanly to 9.1.x.
Comment #10
harlor commentedWell #2 breaks the current behavior of the comment field. Instead of the list of comments one only gets the comment status in views.
Can't we just add a field formatter as an alternative to CommentDefaultFormatter to show the comment status?
Comment #11
harlor commentedSorry I just uploaded an incorrect patch.
Comment #12
kristen polTagging for testing.
Comment #13
kristen polI reviewed the code and it looks very clean :)
Comment #14
joshua1234511Thank you @harlor, On reviewing the code found the below issue.
Patch being applied at incorrect location.
Should be a/core/modules/comment/src/....
Updated the patch to apply at correct path location.
Manually tested the patch, works as expected.
Comment #15
kristen polThanks @joshua1234511 for updating the patch. If someone uploads a patch, then they aren't supposed to RTBC the patch so I'm moving back to needs review so we can get other eyes. I might be able to review today.
Comment #16
kristen polTo review the code more carefully, I wanted to see how status is handle in views for other things and here's some things I found:
class Status extends InOperatorclass Status extends FilterPluginBaseclass NodeViewsData extends EntityViewsDataclass Status extends FilterPluginBaseclass UserViewsData extends EntityViewsDataIn the comment module currently, there are these filters:
NodeComment,StatisticsLastUpdated, andUserUidwhereNodeCommentis currently dealing with status:The patch adds a
FieldFormatter(CommentStatusFormatter). I don't see a similar pattern for theFile,Media, orNodeentities, so I'm not clear this approach would be accepted into core.Comment #17
kristen pol@joshua1234511 Would you please update the issue summary with steps to test this?
Comment #18
joshua1234511I updated the issue summary with testing instructions.
Comment #19
joshua1234511@mpolishchuck thinking of the use case, the patch provided adds a new field formatter, that only displays the status and not all details. As far as views are concerned a status field can be easily added to views and the filters can be obtained. the default views show only enabled comments and un approved comments are shown in another tab view.
as the status will be available only for admin, don't see its use for regular users.
and comments are already filters in
.../admin/content/comment
.../admin/content/comment/approval
Comment #20
kristen polThanks for the clarification @joshua1234511. Since the title and issue summary mentions views, I assumed that the patch would be updating the views filter or field.
Tagging for updating the issue summary to clarify what this new feature really should be.
Comment #21
kristen polMoved the testing steps higher up on issue summary so they are easier to find.
Comment #23
deepalij commentedComment #24
anchal_gupta commentedI have applied Patch #14, it was successfully applied and working fine.
Comment #25
deepalij commentedSuccessfully applied the patch #14.
Testing Steps followed:
1. Applied the patch
2. Cleared cache
3. Go to /admin/structure/types/manage/article/display
4. Ensure the Comment field options -> Select "comment status" -> Save
5. Now, create content of type Article (for checking the comment status) by visiting /node/add/article
6. Fill up mandatory fields -> Save
7. Observe the error message
8. Go to the Recent log messages and check the error
Expected Result:
Selecting and saving the settings should show the comment status for each comment
Actual Result:
Comment status is available in the manage field
But, to check the comment status on comments when trying to create a node, it's giving the 500 error message as shown in the attached video and in the screenshots
Hence, moving to needs work.
Comment #27
bobooon commented+1 RTBC for #14 on Drupal 9.5.x. Previously reported errors appear to be related to using the new Olivero theme. Not this patch.
Comment #28
smustgrave commentedWas tagged in issue summary in #20 which still needs to happen.