decidim-comments 0.23.6 → 0.24.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
  3. data/app/assets/javascripts/decidim/comments/comments.component.js.es6 +292 -0
  4. data/app/assets/javascripts/decidim/comments/comments.component.test.js +581 -0
  5. data/app/assets/javascripts/decidim/comments/comments.js.erb +1 -1
  6. data/app/cells/decidim/comments/comment/actions.erb +7 -0
  7. data/app/cells/decidim/comments/comment/alignment_badge.erb +4 -0
  8. data/app/cells/decidim/comments/comment/author.erb +1 -0
  9. data/app/cells/decidim/comments/comment/show.erb +40 -0
  10. data/app/cells/decidim/comments/comment/utilities.erb +13 -0
  11. data/app/cells/decidim/comments/comment/votes.erb +25 -0
  12. data/app/cells/decidim/comments/comment_card_cell.rb +22 -0
  13. data/app/cells/decidim/comments/comment_cell.rb +142 -8
  14. data/app/cells/decidim/comments/comment_form/comment_as.erb +10 -0
  15. data/app/cells/decidim/comments/comment_form/show.erb +24 -0
  16. data/app/cells/decidim/comments/comment_form_cell.rb +94 -0
  17. data/app/cells/decidim/comments/comment_m/top.erb +1 -1
  18. data/app/cells/decidim/comments/comment_thread/show.erb +6 -0
  19. data/app/cells/decidim/comments/comment_thread/title.erb +3 -0
  20. data/app/cells/decidim/comments/comment_thread_cell.rb +30 -0
  21. data/app/cells/decidim/comments/comments/add_comment.erb +30 -0
  22. data/app/cells/decidim/comments/comments/blocked_comments_warning.erb +3 -0
  23. data/app/cells/decidim/comments/comments/order_control.erb +37 -0
  24. data/app/cells/decidim/comments/comments/show.erb +32 -0
  25. data/app/cells/decidim/comments/comments/single_comment_warning.erb +9 -0
  26. data/app/cells/decidim/comments/comments/user_comments_blocked_warning.erb +3 -0
  27. data/app/cells/decidim/comments/comments_cell.rb +134 -0
  28. data/app/commands/decidim/comments/vote_comment.rb +34 -10
  29. data/app/controllers/decidim/comments/application_controller.rb +16 -0
  30. data/app/controllers/decidim/comments/comments_controller.rb +122 -0
  31. data/app/controllers/decidim/comments/votes_controller.rb +41 -0
  32. data/app/events/decidim/comments/comment_created_event.rb +1 -1
  33. data/app/events/decidim/comments/comment_downvoted_event.rb +8 -0
  34. data/app/events/decidim/comments/comment_upvoted_event.rb +8 -0
  35. data/app/events/decidim/comments/comment_voted_event.rb +26 -0
  36. data/app/forms/decidim/comments/comment_form.rb +6 -2
  37. data/app/models/decidim/comments/comment.rb +22 -8
  38. data/app/models/decidim/comments/seed.rb +1 -1
  39. data/app/permissions/decidim/comments/permissions.rb +59 -0
  40. data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +2 -2
  41. data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +5 -6
  42. data/app/queries/decidim/comments/sorted_comments.rb +18 -14
  43. data/app/views/decidim/comments/comments/_comment.html.erb +5 -0
  44. data/app/views/decidim/comments/comments/_comments.html.erb +1 -0
  45. data/app/views/decidim/comments/comments/create.js.erb +16 -0
  46. data/app/views/decidim/comments/comments/error.js.erb +1 -0
  47. data/app/views/decidim/comments/comments/index.js.erb +24 -0
  48. data/app/views/decidim/comments/comments/reload.js.erb +21 -0
  49. data/app/views/decidim/comments/votes/create.js.erb +23 -0
  50. data/app/views/decidim/comments/votes/error.js.erb +1 -0
  51. data/config/locales/ar.yml +0 -2
  52. data/config/locales/ca.yml +7 -2
  53. data/config/locales/cs.yml +24 -7
  54. data/config/locales/de.yml +17 -2
  55. data/config/locales/el.yml +0 -2
  56. data/config/locales/en.yml +17 -2
  57. data/config/locales/es-MX.yml +7 -2
  58. data/config/locales/es-PY.yml +7 -2
  59. data/config/locales/es.yml +7 -2
  60. data/config/locales/eu.yml +0 -2
  61. data/config/locales/fi-plain.yml +17 -2
  62. data/config/locales/fi.yml +17 -2
  63. data/config/locales/fr-CA.yml +17 -2
  64. data/config/locales/fr.yml +17 -2
  65. data/config/locales/gl.yml +7 -2
  66. data/config/locales/hu.yml +0 -2
  67. data/config/locales/id-ID.yml +0 -2
  68. data/config/locales/is-IS.yml +0 -1
  69. data/config/locales/it.yml +4 -2
  70. data/config/locales/ja.yml +8 -4
  71. data/config/locales/lv.yml +0 -2
  72. data/config/locales/nl.yml +0 -2
  73. data/config/locales/no.yml +0 -2
  74. data/config/locales/pl.yml +19 -2
  75. data/config/locales/pt-BR.yml +0 -2
  76. data/config/locales/pt.yml +0 -2
  77. data/config/locales/ro-RO.yml +0 -3
  78. data/config/locales/ru.yml +0 -2
  79. data/config/locales/sk.yml +0 -2
  80. data/config/locales/sv.yml +7 -2
  81. data/config/locales/tr-TR.yml +7 -2
  82. data/config/locales/uk.yml +0 -1
  83. data/config/locales/zh-CN.yml +0 -2
  84. data/lib/decidim/api/add_comment_type.rb +13 -0
  85. data/lib/decidim/api/comment_mutation_type.rb +22 -0
  86. data/lib/decidim/api/comment_type.rb +89 -0
  87. data/lib/decidim/api/commentable_interface.rb +50 -0
  88. data/lib/decidim/api/commentable_mutation_type.rb +30 -0
  89. data/{app/types/decidim/comments → lib/decidim/api}/commentable_type.rb +2 -5
  90. data/lib/decidim/comments/api.rb +12 -0
  91. data/lib/decidim/comments/comments_helper.rb +10 -52
  92. data/lib/decidim/comments/engine.rb +9 -7
  93. data/lib/decidim/comments/mutation_extensions.rb +22 -22
  94. data/lib/decidim/comments/query_extensions.rb +12 -14
  95. data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +65 -0
  96. data/lib/decidim/comments/test.rb +1 -0
  97. data/lib/decidim/comments/version.rb +1 -1
  98. data/lib/decidim/comments.rb +1 -3
  99. metadata +67 -66
  100. data/app/assets/javascripts/decidim/comments/bundle.js +0 -268
  101. data/app/frontend/application/apollo_client.ts +0 -12
  102. data/app/frontend/application/application.component.test.tsx +0 -23
  103. data/app/frontend/application/application.component.tsx +0 -35
  104. data/app/frontend/application/icon.component.test.tsx +0 -38
  105. data/app/frontend/application/icon.component.tsx +0 -46
  106. data/app/frontend/comments/add_comment_form.component.test.tsx +0 -265
  107. data/app/frontend/comments/add_comment_form.component.tsx +0 -482
  108. data/app/frontend/comments/comment.component.test.tsx +0 -490
  109. data/app/frontend/comments/comment.component.tsx +0 -677
  110. data/app/frontend/comments/comment_order_selector.component.test.tsx +0 -29
  111. data/app/frontend/comments/comment_order_selector.component.tsx +0 -106
  112. data/app/frontend/comments/comment_thread.component.test.tsx +0 -82
  113. data/app/frontend/comments/comment_thread.component.tsx +0 -81
  114. data/app/frontend/comments/comments.component.test.tsx +0 -150
  115. data/app/frontend/comments/comments.component.tsx +0 -289
  116. data/app/frontend/comments/down_vote_button.component.test.tsx +0 -59
  117. data/app/frontend/comments/down_vote_button.component.tsx +0 -133
  118. data/app/frontend/comments/up_vote_button.component.test.tsx +0 -59
  119. data/app/frontend/comments/up_vote_button.component.tsx +0 -133
  120. data/app/frontend/comments/vote_button.component.tsx +0 -50
  121. data/app/frontend/comments/vote_button_component.test.tsx +0 -64
  122. data/app/frontend/entry.ts +0 -38
  123. data/app/frontend/entry_test.ts +0 -6
  124. data/app/frontend/fragments/add_comment_form_commentable.fragment.graphql +0 -4
  125. data/app/frontend/fragments/add_comment_form_session.fragment.graphql +0 -6
  126. data/app/frontend/fragments/comment.fragment.graphql +0 -14
  127. data/app/frontend/fragments/comment_data.fragment.graphql +0 -27
  128. data/app/frontend/fragments/comment_thread.fragment.graphql +0 -6
  129. data/app/frontend/fragments/down_vote_button.fragment.graphql +0 -6
  130. data/app/frontend/fragments/up_vote_button.fragment.graphql +0 -6
  131. data/app/frontend/mutations/add_comment.mutation.graphql +0 -9
  132. data/app/frontend/mutations/down_vote.mutation.graphql +0 -9
  133. data/app/frontend/mutations/up_vote.mutation.graphql +0 -9
  134. data/app/frontend/queries/comments.query.graphql +0 -26
  135. data/app/frontend/support/asset_url.ts +0 -11
  136. data/app/frontend/support/generate_comments_data.ts +0 -49
  137. data/app/frontend/support/generate_user_data.ts +0 -14
  138. data/app/frontend/support/generate_user_group_data.ts +0 -14
  139. data/app/frontend/support/graphql_transformer.js +0 -32
  140. data/app/frontend/support/load_translations.ts +0 -48
  141. data/app/frontend/support/require_all.ts +0 -10
  142. data/app/frontend/support/resolve_graphql_query.ts +0 -37
  143. data/app/frontend/support/schema.ts +0 -2026
  144. data/app/types/decidim/comments/commentable_interface.rb +0 -61
  145. data/app/types/decidim/comments/commentable_mutation_type.rb +0 -33
  146. data/lib/decidim/comments/api/add_comment_type.rb +0 -13
  147. data/lib/decidim/comments/api/comment_mutation_type.rb +0 -20
  148. data/lib/decidim/comments/api/comment_type.rb +0 -89
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Comments
5
- # This interface represents a commentable object.
6
- CommentableInterface = GraphQL::InterfaceType.define do
7
- name "CommentableInterface"
8
- description "A commentable interface"
9
-
10
- field :id, !types.ID, "The commentable's ID"
11
-
12
- field :type, !types.String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`" do
13
- property :commentable_type
14
- end
15
-
16
- field :acceptsNewComments, !types.Boolean, "Whether the object can have new comments or not" do
17
- property :accepts_new_comments?
18
- end
19
-
20
- field :commentsHaveAlignment, !types.Boolean, "Whether the object comments have alignment or not" do
21
- property :comments_have_alignment?
22
- end
23
-
24
- field :commentsHaveVotes, !types.Boolean, "Whether the object comments have votes or not" do
25
- property :comments_have_votes?
26
- end
27
-
28
- field :comments do
29
- type !types[!CommentType]
30
-
31
- argument :orderBy, types.String, "Order the comments"
32
- argument :singleCommentId, types.String, "ID of the single comment to look at"
33
-
34
- resolve lambda { |obj, args, _ctx|
35
- SortedComments.for(obj, order_by: args[:orderBy], id: args[:singleCommentId])
36
- }
37
- end
38
-
39
- field :totalCommentsCount do
40
- type !types.Int
41
- description "The number of comments in all levels this resource holds"
42
-
43
- resolve lambda { |obj, _args, _ctx|
44
- obj.comments_count
45
- }
46
- end
47
-
48
- field :hasComments, !types.Boolean, "Check if the commentable has comments" do
49
- resolve lambda { |obj, _args, _ctx|
50
- obj.comment_threads.size.positive?
51
- }
52
- end
53
-
54
- field :userAllowedToComment, !types.Boolean, "Check if the current user can comment" do
55
- resolve lambda { |obj, _args, ctx|
56
- obj.commentable? && obj.user_allowed_to_comment?(ctx[:current_user])
57
- }
58
- end
59
- end
60
- end
61
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Comments
5
- CommentableMutationType = GraphQL::ObjectType.define do
6
- name "CommentableMutation"
7
- description "A commentable which includes its available mutations"
8
-
9
- field :id, !types.ID, "The Commentable's unique ID"
10
-
11
- field :addComment, Decidim::Comments::CommentType do
12
- description "Add a new comment to a commentable"
13
-
14
- argument :body, !types.String, "The comments's body"
15
- argument :alignment, types.Int, "The comment's alignment. Can be 0 (neutral), 1 (in favor) or -1 (against)'", default_value: 0
16
- argument :userGroupId, types.ID, "The comment's user group id. Replaces the author."
17
-
18
- resolve lambda { |obj, args, ctx|
19
- params = { "comment" => { "body" => args[:body], "alignment" => args[:alignment], "user_group_id" => args[:userGroupId], "commentable" => obj } }
20
- form = Decidim::Comments::CommentForm.from_params(params).with_context(
21
- current_organization: ctx[:current_organization],
22
- current_component: obj.component
23
- )
24
- Decidim::Comments::CreateComment.call(form, ctx[:current_user]) do
25
- on(:ok) do |comment|
26
- return comment
27
- end
28
- end
29
- }
30
- end
31
- end
32
- end
33
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Comments
5
- # This type represents a mutation to create new comments.
6
- AddCommentType = GraphQL::ObjectType.define do
7
- name "Add comment"
8
- description "Add a new comment"
9
-
10
- field :comment, CommentType, "The new created comment"
11
- end
12
- end
13
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Comments
5
- CommentMutationType = GraphQL::ObjectType.define do
6
- name "CommentMutation"
7
- description "A comment which includes its available mutations"
8
-
9
- field :id, !types.ID, "The Comment's unique ID"
10
-
11
- field :upVote, !Decidim::Comments::CommentType do
12
- resolve VoteCommentResolver.new(weight: 1)
13
- end
14
-
15
- field :downVote, !Decidim::Comments::CommentType do
16
- resolve VoteCommentResolver.new(weight: -1)
17
- end
18
- end
19
- end
20
- end
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Comments
5
- # This type represents a comment on a commentable object.
6
- CommentType = GraphQL::ObjectType.define do
7
- name "Comment"
8
- description "A comment"
9
-
10
- interfaces [
11
- -> { Decidim::Comments::CommentableInterface }
12
- ]
13
-
14
- field :author, !Decidim::Core::AuthorInterface, "The resource author" do
15
- resolve lambda { |obj, _args, _ctx|
16
- obj.user_group || obj.author
17
- }
18
- end
19
-
20
- field :id, !types.ID, "The Comment's unique ID"
21
-
22
- field :sgid, !types.String, "The Comment's signed global id" do
23
- resolve lambda { |obj, _args, _ctx|
24
- obj.to_sgid.to_s
25
- }
26
- end
27
-
28
- field :body, !types.String, "The comment message" do
29
- resolve lambda { |obj, _args, _ctx|
30
- obj.translated_body
31
- }
32
- end
33
-
34
- field :formattedBody, !types.String, "The comment message ready to display (it is expected to include HTML)", property: :formatted_body
35
-
36
- field :createdAt, !types.String, "The creation date of the comment" do
37
- resolve lambda { |obj, _args, _ctx|
38
- obj.created_at.iso8601
39
- }
40
- end
41
-
42
- field :formattedCreatedAt, !types.String, "The creation date of the comment in relative format", property: :friendly_created_at
43
-
44
- field :alignment, types.Int, "The comment's alignment. Can be 0 (neutral), 1 (in favor) or -1 (against)'"
45
-
46
- field :upVotes, !types.Int, "The number of comment's upVotes" do
47
- resolve lambda { |obj, _args, _ctx|
48
- obj.up_votes.size
49
- }
50
- end
51
-
52
- field :upVoted, !types.Boolean, "Check if the current user has upvoted the comment" do
53
- resolve lambda { |obj, _args, ctx|
54
- obj.up_voted_by?(ctx[:current_user])
55
- }
56
- end
57
-
58
- field :downVotes, !types.Int, "The number of comment's downVotes" do
59
- resolve lambda { |obj, _args, _ctx|
60
- obj.down_votes.size
61
- }
62
- end
63
-
64
- field :downVoted, !types.Boolean, "Check if the current user has downvoted the comment" do
65
- resolve lambda { |obj, _args, ctx|
66
- obj.down_voted_by?(ctx[:current_user])
67
- }
68
- end
69
-
70
- field :hasComments, !types.Boolean, "Check if the commentable has comments" do
71
- resolve lambda { |obj, _args, _ctx|
72
- obj.comment_threads.size.positive?
73
- }
74
- end
75
-
76
- field :alreadyReported, !types.Boolean, "Check if the current user has reported the comment" do
77
- resolve lambda { |obj, _args, ctx|
78
- obj.reported_by?(ctx[:current_user])
79
- }
80
- end
81
-
82
- field :userAllowedToComment, !types.Boolean, "Check if the current user can comment" do
83
- resolve lambda { |obj, _args, ctx|
84
- obj.root_commentable.commentable? && obj.root_commentable.user_allowed_to_comment?(ctx[:current_user])
85
- }
86
- end
87
- end
88
- end
89
- end