decidim-comments 0.23.1 → 0.24.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) 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_event.rb +0 -15
  35. data/app/events/decidim/comments/comment_upvoted_event.rb +8 -0
  36. data/app/events/decidim/comments/comment_voted_event.rb +26 -0
  37. data/app/forms/decidim/comments/comment_form.rb +6 -2
  38. data/app/models/decidim/comments/comment.rb +33 -11
  39. data/app/models/decidim/comments/seed.rb +1 -1
  40. data/app/permissions/decidim/comments/permissions.rb +59 -0
  41. data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +2 -2
  42. data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +5 -6
  43. data/app/queries/decidim/comments/sorted_comments.rb +18 -14
  44. data/app/views/decidim/comments/comments/_comment.html.erb +5 -0
  45. data/app/views/decidim/comments/comments/_comments.html.erb +1 -0
  46. data/app/views/decidim/comments/comments/create.js.erb +16 -0
  47. data/app/views/decidim/comments/comments/error.js.erb +1 -0
  48. data/app/views/decidim/comments/comments/index.js.erb +24 -0
  49. data/app/views/decidim/comments/comments/reload.js.erb +21 -0
  50. data/app/views/decidim/comments/votes/create.js.erb +23 -0
  51. data/app/views/decidim/comments/votes/error.js.erb +1 -0
  52. data/config/locales/ar.yml +0 -2
  53. data/config/locales/ca.yml +17 -2
  54. data/config/locales/cs.yml +20 -3
  55. data/config/locales/de.yml +46 -30
  56. data/config/locales/el.yml +0 -2
  57. data/config/locales/en.yml +17 -2
  58. data/config/locales/es-MX.yml +17 -2
  59. data/config/locales/es-PY.yml +17 -2
  60. data/config/locales/es.yml +17 -2
  61. data/config/locales/eu.yml +0 -2
  62. data/config/locales/fi-plain.yml +17 -2
  63. data/config/locales/fi.yml +17 -2
  64. data/config/locales/fr-CA.yml +17 -2
  65. data/config/locales/fr.yml +17 -2
  66. data/config/locales/gl.yml +20 -2
  67. data/config/locales/hu.yml +0 -2
  68. data/config/locales/id-ID.yml +0 -2
  69. data/config/locales/is-IS.yml +0 -1
  70. data/config/locales/it.yml +5 -2
  71. data/config/locales/ja.yml +14 -10
  72. data/config/locales/lv.yml +0 -2
  73. data/config/locales/nl.yml +7 -9
  74. data/config/locales/no.yml +0 -2
  75. data/config/locales/pl.yml +22 -4
  76. data/config/locales/pt-BR.yml +0 -2
  77. data/config/locales/pt.yml +0 -2
  78. data/config/locales/ro-RO.yml +0 -2
  79. data/config/locales/ru.yml +0 -2
  80. data/config/locales/si-LK.yml +1 -0
  81. data/config/locales/sk.yml +0 -2
  82. data/config/locales/sv.yml +7 -2
  83. data/config/locales/sw-KE.yml +1 -0
  84. data/config/locales/tr-TR.yml +60 -35
  85. data/config/locales/uk.yml +0 -1
  86. data/config/locales/zh-CN.yml +0 -2
  87. data/lib/decidim/api/add_comment_type.rb +13 -0
  88. data/lib/decidim/api/comment_mutation_type.rb +22 -0
  89. data/lib/decidim/api/comment_type.rb +89 -0
  90. data/lib/decidim/api/commentable_interface.rb +50 -0
  91. data/lib/decidim/api/commentable_mutation_type.rb +30 -0
  92. data/{app/types/decidim/comments → lib/decidim/api}/commentable_type.rb +2 -5
  93. data/lib/decidim/comments.rb +1 -3
  94. data/lib/decidim/comments/api.rb +12 -0
  95. data/lib/decidim/comments/comments_helper.rb +10 -52
  96. data/lib/decidim/comments/engine.rb +9 -7
  97. data/lib/decidim/comments/mutation_extensions.rb +22 -22
  98. data/lib/decidim/comments/query_extensions.rb +12 -14
  99. data/lib/decidim/comments/test.rb +1 -0
  100. data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +65 -0
  101. data/lib/decidim/comments/version.rb +1 -1
  102. metadata +72 -69
  103. data/app/assets/javascripts/decidim/comments/bundle.js +0 -268
  104. data/app/frontend/application/apollo_client.ts +0 -12
  105. data/app/frontend/application/application.component.test.tsx +0 -23
  106. data/app/frontend/application/application.component.tsx +0 -35
  107. data/app/frontend/application/icon.component.test.tsx +0 -38
  108. data/app/frontend/application/icon.component.tsx +0 -46
  109. data/app/frontend/comments/add_comment_form.component.test.tsx +0 -265
  110. data/app/frontend/comments/add_comment_form.component.tsx +0 -482
  111. data/app/frontend/comments/comment.component.test.tsx +0 -490
  112. data/app/frontend/comments/comment.component.tsx +0 -677
  113. data/app/frontend/comments/comment_order_selector.component.test.tsx +0 -29
  114. data/app/frontend/comments/comment_order_selector.component.tsx +0 -106
  115. data/app/frontend/comments/comment_thread.component.test.tsx +0 -82
  116. data/app/frontend/comments/comment_thread.component.tsx +0 -81
  117. data/app/frontend/comments/comments.component.test.tsx +0 -150
  118. data/app/frontend/comments/comments.component.tsx +0 -289
  119. data/app/frontend/comments/down_vote_button.component.test.tsx +0 -59
  120. data/app/frontend/comments/down_vote_button.component.tsx +0 -133
  121. data/app/frontend/comments/up_vote_button.component.test.tsx +0 -59
  122. data/app/frontend/comments/up_vote_button.component.tsx +0 -133
  123. data/app/frontend/comments/vote_button.component.tsx +0 -50
  124. data/app/frontend/comments/vote_button_component.test.tsx +0 -64
  125. data/app/frontend/entry.ts +0 -38
  126. data/app/frontend/entry_test.ts +0 -6
  127. data/app/frontend/fragments/add_comment_form_commentable.fragment.graphql +0 -4
  128. data/app/frontend/fragments/add_comment_form_session.fragment.graphql +0 -6
  129. data/app/frontend/fragments/comment.fragment.graphql +0 -14
  130. data/app/frontend/fragments/comment_data.fragment.graphql +0 -27
  131. data/app/frontend/fragments/comment_thread.fragment.graphql +0 -6
  132. data/app/frontend/fragments/down_vote_button.fragment.graphql +0 -6
  133. data/app/frontend/fragments/up_vote_button.fragment.graphql +0 -6
  134. data/app/frontend/mutations/add_comment.mutation.graphql +0 -9
  135. data/app/frontend/mutations/down_vote.mutation.graphql +0 -9
  136. data/app/frontend/mutations/up_vote.mutation.graphql +0 -9
  137. data/app/frontend/queries/comments.query.graphql +0 -26
  138. data/app/frontend/support/asset_url.ts +0 -11
  139. data/app/frontend/support/generate_comments_data.ts +0 -49
  140. data/app/frontend/support/generate_user_data.ts +0 -14
  141. data/app/frontend/support/generate_user_group_data.ts +0 -14
  142. data/app/frontend/support/graphql_transformer.js +0 -32
  143. data/app/frontend/support/load_translations.ts +0 -48
  144. data/app/frontend/support/require_all.ts +0 -10
  145. data/app/frontend/support/resolve_graphql_query.ts +0 -37
  146. data/app/frontend/support/schema.ts +0 -2026
  147. data/app/types/decidim/comments/commentable_interface.rb +0 -61
  148. data/app/types/decidim/comments/commentable_mutation_type.rb +0 -33
  149. data/lib/decidim/comments/api/add_comment_type.rb +0 -13
  150. data/lib/decidim/comments/api/comment_mutation_type.rb +0 -20
  151. data/lib/decidim/comments/api/comment_type.rb +0 -89
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Comments
5
+ class CommentableMutationType < Decidim::Api::Types::BaseObject
6
+ description "A commentable which includes its available mutations"
7
+
8
+ field :id, GraphQL::Types::ID, "The Commentable's unique ID", null: false
9
+
10
+ field :add_comment, Decidim::Comments::CommentType, description: "Add a new comment to a commentable", null: true do
11
+ argument :body, GraphQL::Types::String, "The comments's body", required: true
12
+ argument :alignment, GraphQL::Types::Int, "The comment's alignment. Can be 0 (neutral), 1 (in favor) or -1 (against)'", default_value: 0, required: false
13
+ argument :user_group_id, GraphQL::Types::ID, "The comment's user group id. Replaces the author.", required: false
14
+ end
15
+
16
+ def add_comment(body:, alignment: nil, user_group_id: nil)
17
+ params = { "comment" => { "body" => body, "alignment" => alignment, "user_group_id" => user_group_id, "commentable" => object } }
18
+ form = Decidim::Comments::CommentForm.from_params(params).with_context(
19
+ current_organization: context[:current_organization],
20
+ current_component: object.component
21
+ )
22
+ Decidim::Comments::CreateComment.call(form, context[:current_user]) do
23
+ on(:ok) do |comment|
24
+ return comment
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -3,13 +3,10 @@
3
3
  module Decidim
4
4
  module Comments
5
5
  # This type represents a commentable object.
6
- CommentableType = GraphQL::ObjectType.define do
7
- name "Commentable"
6
+ class CommentableType < Decidim::Api::Types::BaseObject
8
7
  description "A commentable object"
9
8
 
10
- interfaces [
11
- -> { Decidim::Comments::CommentableInterface }
12
- ]
9
+ implements Decidim::Comments::CommentableInterface
13
10
  end
14
11
  end
15
12
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "decidim/comments/admin"
4
+ require "decidim/comments/api"
4
5
  require "decidim/comments/engine"
5
6
  require "decidim/comments/admin_engine"
6
7
 
@@ -10,9 +11,6 @@ module Decidim
10
11
  # a React component which handle all the comments render and logic.
11
12
  module Comments
12
13
  autoload :CommentsHelper, "decidim/comments/comments_helper"
13
- autoload :AddCommentType, "decidim/comments/api/add_comment_type"
14
- autoload :CommentMutationType, "decidim/comments/api/comment_mutation_type"
15
- autoload :CommentType, "decidim/comments/api/comment_type"
16
14
  autoload :Commentable, "decidim/comments/commentable"
17
15
  autoload :CommentSerializer, "decidim/comments/comment_serializer"
18
16
  autoload :CommentVoteSerializer, "decidim/comments/comment_vote_serializer"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Comments
5
+ autoload :CommentableInterface, "decidim/api/commentable_interface"
6
+ autoload :AddCommentType, "decidim/api/add_comment_type"
7
+ autoload :CommentMutationType, "decidim/api/comment_mutation_type"
8
+ autoload :CommentType, "decidim/api/comment_type"
9
+ autoload :CommentableType, "decidim/api/commentable_type"
10
+ autoload :CommentableMutationType, "decidim/api/commentable_mutation_type"
11
+ end
12
+ end
@@ -15,63 +15,21 @@ module Decidim
15
15
  end
16
16
  end
17
17
 
18
- # Creates a Comments component which is rendered using `ReactDOM`
18
+ # Creates a Comments component through the comments cell.
19
19
  #
20
20
  # resource - A commentable resource
21
21
  #
22
- # Returns a div which contain a RectComponent
23
- def inline_comments_for(resource)
22
+ # Returns the comments cell
23
+ def inline_comments_for(resource, options = {})
24
24
  return unless resource.commentable?
25
25
 
26
- commentable_type = resource.commentable_type
27
- commentable_id = resource.id.to_s
28
- node_id = "comments-for-#{commentable_type.demodulize}-#{commentable_id}"
29
- react_comments_component(
30
- node_id, commentableType: commentable_type,
31
- commentableId: commentable_id,
32
- locale: I18n.locale,
33
- toggleTranslations: machine_translations_toggled?,
34
- commentsMaxLength: comments_max_length(resource)
35
- )
36
- end
37
-
38
- # Private: Render Comments component using inline javascript
39
- #
40
- # node_id - The id of the DOMElement to render the React component
41
- # props - A hash corresponding to Comments component props
42
- def react_comments_component(node_id, props)
43
- content_tag("div", "", id: node_id) +
44
- javascript_include_tag("decidim/comments/comments") +
45
- javascript_tag(%{
46
- window.DecidimComments.renderCommentsComponent(
47
- '#{node_id}',
48
- {
49
- commentableType: "#{props[:commentableType]}",
50
- commentableId: "#{props[:commentableId]}",
51
- locale: "#{props[:locale]}",
52
- toggleTranslations: #{props[:toggleTranslations]},
53
- commentsMaxLength: "#{props[:commentsMaxLength]}"
54
- }
55
- );
56
- })
57
- end
58
-
59
- def comments_max_length(resource)
60
- return 1000 unless resource.respond_to?(:component)
61
- return component_comments_max_length(resource) if component_comments_max_length(resource)
62
- return organization_comments_max_length(resource) if organization_comments_max_length(resource)
63
-
64
- 1000
65
- end
66
-
67
- def component_comments_max_length(resource)
68
- return unless resource.component&.settings.respond_to?(:comments_max_length)
69
-
70
- resource.component.settings.comments_max_length if resource.component.settings.comments_max_length.positive?
71
- end
72
-
73
- def organization_comments_max_length(resource)
74
- resource.component.organization.comments_max_length if resource.component.organization.comments_max_length.positive?
26
+ cell(
27
+ "decidim/comments/comments",
28
+ resource,
29
+ machine_translations: machine_translations_toggled?,
30
+ single_comment: params.fetch("commentId", nil),
31
+ order: options[:order]
32
+ ).to_s
75
33
  end
76
34
  end
77
35
  end
@@ -19,20 +19,22 @@ module Decidim
19
19
  class Engine < ::Rails::Engine
20
20
  isolate_namespace Decidim::Comments
21
21
 
22
+ routes do
23
+ resources :comments, only: [:index, :create] do
24
+ resources :votes, only: [:create]
25
+ end
26
+ end
27
+
22
28
  initializer "decidim_comments.assets" do |app|
23
29
  app.config.assets.precompile += %w(decidim_comments_manifest.js)
24
30
  end
25
31
 
26
32
  initializer "decidim_comments.query_extensions" do
27
- Decidim::Api::QueryType.define do
28
- QueryExtensions.define(self)
29
- end
33
+ Decidim::Api::QueryType.include QueryExtensions
30
34
  end
31
35
 
32
36
  initializer "decidim_comments.mutation_extensions" do
33
- Decidim::Api::MutationType.define do
34
- MutationExtensions.define(self)
35
- end
37
+ Decidim::Api::MutationType.include MutationExtensions
36
38
  end
37
39
 
38
40
  initializer "decidim.stats" do
@@ -63,7 +65,7 @@ module Decidim
63
65
  initializer "decidim_comments.register_resources" do
64
66
  Decidim.register_resource(:comment) do |resource|
65
67
  resource.model_class_name = "Decidim::Comments::Comment"
66
- resource.card = "decidim/comments/comment"
68
+ resource.card = "decidim/comments/comment_card"
67
69
  resource.searchable = true
68
70
  end
69
71
  end
@@ -10,36 +10,36 @@ module Decidim
10
10
  # type - A GraphQL::BaseType to extend.
11
11
  #
12
12
  # Returns nothing.
13
- def self.define(type)
14
- type.field :commentable, Decidim::Comments::CommentableMutationType do
13
+ def self.included(type)
14
+ type.field :commentable, Decidim::Comments::CommentableMutationType, null: false do
15
15
  description "A commentable"
16
16
 
17
- argument :id, !types.String, "The commentable's ID"
18
- argument :type, !types.String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`"
19
- argument :locale, !types.String, "The locale for which to get the comments text"
20
- argument :toggleTranslations, !types.Boolean, "Whether the user asked to toggle the machine translations or not."
21
-
22
- resolve lambda { |_obj, args, _ctx|
23
- I18n.locale = args[:locale].presence
24
- RequestStore.store[:toggle_machine_translations] = args[:toggleTranslations]
25
- args[:type].constantize.find(args[:id])
26
- }
17
+ argument :id, GraphQL::Types::String, "The commentable's ID", required: true
18
+ argument :type, GraphQL::Types::String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`", required: true
19
+ argument :locale, GraphQL::Types::String, "The locale for which to get the comments text", required: true
20
+ argument :toggle_translations, GraphQL::Types::Boolean, "Whether the user asked to toggle the machine translations or not.", required: true
27
21
  end
28
22
 
29
- type.field :comment, Decidim::Comments::CommentMutationType do
23
+ type.field :comment, Decidim::Comments::CommentMutationType, null: false do
30
24
  description "A comment"
31
25
 
32
- argument :id, !types.ID, "The comment's id"
33
- argument :locale, !types.String, "The locale for which to get the comments text"
34
- argument :toggleTranslations, !types.Boolean, "Whether the user asked to toggle the machine translations or not."
35
-
36
- resolve lambda { |_obj, args, _ctx|
37
- I18n.locale = args[:locale].presence
38
- RequestStore.store[:toggle_machine_translations] = args[:toggleTranslations]
39
- Comment.find(args["id"])
40
- }
26
+ argument :id, GraphQL::Types::ID, "The comment's id", required: true
27
+ argument :locale, GraphQL::Types::String, "The locale for which to get the comments text", required: true
28
+ argument :toggle_translations, GraphQL::Types::Boolean, "Whether the user asked to toggle the machine translations or not.", required: true
41
29
  end
42
30
  end
31
+
32
+ def commentable(id:, locale:, toggle_translations:, type:)
33
+ I18n.locale = locale.presence
34
+ RequestStore.store[:toggle_machine_translations] = toggle_translations
35
+ type.constantize.find(id)
36
+ end
37
+
38
+ def comment(id:, locale:, toggle_translations:)
39
+ I18n.locale = locale.presence
40
+ RequestStore.store[:toggle_machine_translations] = toggle_translations
41
+ Comment.find(id)
42
+ end
43
43
  end
44
44
  end
45
45
  end
@@ -10,22 +10,20 @@ module Decidim
10
10
  # type - A GraphQL::BaseType to extend.
11
11
  #
12
12
  # Returns nothing.
13
- def self.define(type)
14
- type.field :commentable do
15
- type !CommentableType
16
-
17
- argument :id, !types.String, "The commentable's ID"
18
- argument :type, !types.String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`"
19
- argument :locale, !types.String, "The locale for which to get the comments text"
20
- argument :toggleTranslations, !types.Boolean, "Whether the user asked to toggle the machine translations or not."
21
-
22
- resolve lambda { |_obj, args, _ctx|
23
- I18n.locale = args[:locale].presence
24
- RequestStore.store[:toggle_machine_translations] = args[:toggleTranslations]
25
- args[:type].constantize.find(args[:id])
26
- }
13
+ def self.included(type)
14
+ type.field :commentable, CommentableType, null: false do
15
+ argument :id, GraphQL::Types::String, "The commentable's ID", required: true
16
+ argument :type, GraphQL::Types::String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`", required: true
17
+ argument :locale, GraphQL::Types::String, "The locale for which to get the comments text", required: true
18
+ argument :toggle_translations, GraphQL::Types::Boolean, "Whether the user asked to toggle the machine translations or not.", required: true
27
19
  end
28
20
  end
21
+
22
+ def commentable(id:, locale:, toggle_translations:, type:)
23
+ I18n.locale = locale.presence
24
+ RequestStore.store[:toggle_machine_translations] = toggle_translations
25
+ type.constantize.find(id)
26
+ end
29
27
  end
30
28
  end
31
29
  end
@@ -2,3 +2,4 @@
2
2
 
3
3
  require "decidim/comments/test/shared_examples/create_comment_context"
4
4
  require "decidim/comments/test/shared_examples/comment_event"
5
+ require "decidim/comments/test/shared_examples/comment_voted_event"
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ shared_examples_for "a comment voted event" do
6
+ include_context "when it's a comment event"
7
+
8
+ let(:resource) { comment.commentable }
9
+
10
+ let(:comment) { create :comment }
11
+ let(:comment_vote) { create :comment_vote, comment: comment }
12
+ let(:comment_vote_author) { comment_vote.author }
13
+
14
+ let(:extra) { { comment_id: comment.id, author_id: comment_vote_author.id, weight: weight, downvotes: 100, upvotes: 999 } }
15
+ let(:resource_title) { decidim_html_escape(translated(resource.title)) }
16
+ let(:resource_text) { subject.resource_text }
17
+
18
+ let(:verb) { weight.positive? ? "upvoted" : "downvoted" }
19
+
20
+ describe "downvotes" do
21
+ it "outputs the total downvotes" do
22
+ expect(subject.downvotes).to eq(100)
23
+ end
24
+ end
25
+
26
+ describe "upvotes" do
27
+ it "outputs the total upvotes" do
28
+ expect(subject.upvotes).to eq(999)
29
+ end
30
+ end
31
+
32
+ describe "resource_text" do
33
+ it "outputs the comment body" do
34
+ expect(subject.resource_text).to eq comment.formatted_body
35
+ end
36
+ end
37
+
38
+ describe "email_subject" do
39
+ it "is generated correctly" do
40
+ expect(subject.email_subject).to eq("Your comment in \"#{resource_title}\" has been #{verb}.")
41
+ end
42
+ end
43
+
44
+ describe "email_intro" do
45
+ it "is generated correctly" do
46
+ expect(subject.email_intro).to eq("Your comment in \"#{resource_title}\" has been #{verb}. It now has a total of 999 upvotes and 100 downvotes.")
47
+ end
48
+ end
49
+
50
+ describe "email_outro" do
51
+ it "is generated correctly" do
52
+ expect(subject.email_outro)
53
+ .to eq("You have received this notification because you are the author of this comment.")
54
+ end
55
+ end
56
+
57
+ describe "notification_title" do
58
+ it "is generated correctly" do
59
+ expect(subject.notification_title)
60
+ .to include("Your <a href=\"#{resource_path}#comment_#{comment.id}\">comment</a> in \"#{resource_title}\" has been #{verb}")
61
+ expect(subject.notification_title)
62
+ .to include("It now has a total of 999 upvotes and 100 downvotes.")
63
+ end
64
+ end
65
+ end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-comments version.
5
5
  module Comments
6
6
  def self.version
7
- "0.23.1"
7
+ "0.24.0.rc2"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.1
4
+ version: 0.24.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
8
8
  - Marc Riera Casals
9
9
  - Oriol Gual Oliva
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-11-12 00:00:00.000000000 Z
13
+ date: 2021-03-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,70 +18,76 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.23.1
21
+ version: 0.24.0.rc2
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.23.1
28
+ version: 0.24.0.rc2
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: jquery-rails
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '4.3'
35
+ version: '4.4'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '4.3'
42
+ version: '4.4'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: redcarpet
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '3.4'
49
+ version: '3.5'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.5.1
50
53
  type: :runtime
51
54
  prerelease: false
52
55
  version_requirements: !ruby/object:Gem::Requirement
53
56
  requirements:
54
57
  - - "~>"
55
58
  - !ruby/object:Gem::Version
56
- version: '3.4'
59
+ version: '3.5'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.5.1
57
63
  - !ruby/object:Gem::Dependency
58
64
  name: decidim-admin
59
65
  requirement: !ruby/object:Gem::Requirement
60
66
  requirements:
61
67
  - - '='
62
68
  - !ruby/object:Gem::Version
63
- version: 0.23.1
69
+ version: 0.24.0.rc2
64
70
  type: :development
65
71
  prerelease: false
66
72
  version_requirements: !ruby/object:Gem::Requirement
67
73
  requirements:
68
74
  - - '='
69
75
  - !ruby/object:Gem::Version
70
- version: 0.23.1
76
+ version: 0.24.0.rc2
71
77
  - !ruby/object:Gem::Dependency
72
78
  name: decidim-dev
73
79
  requirement: !ruby/object:Gem::Requirement
74
80
  requirements:
75
81
  - - '='
76
82
  - !ruby/object:Gem::Version
77
- version: 0.23.1
83
+ version: 0.24.0.rc2
78
84
  type: :development
79
85
  prerelease: false
80
86
  version_requirements: !ruby/object:Gem::Requirement
81
87
  requirements:
82
88
  - - '='
83
89
  - !ruby/object:Gem::Version
84
- version: 0.23.1
90
+ version: 0.24.0.rc2
85
91
  description: Pluggable comments system for some components.
86
92
  email:
87
93
  - josepjaume@gmail.com
@@ -94,72 +100,57 @@ files:
94
100
  - README.md
95
101
  - Rakefile
96
102
  - app/assets/config/decidim_comments_manifest.js
97
- - app/assets/javascripts/decidim/comments/bundle.js
98
103
  - app/assets/javascripts/decidim/comments/bundle.js.map
104
+ - app/assets/javascripts/decidim/comments/comments.component.js.es6
105
+ - app/assets/javascripts/decidim/comments/comments.component.test.js
99
106
  - app/assets/javascripts/decidim/comments/comments.js.erb
107
+ - app/cells/decidim/comments/comment/actions.erb
108
+ - app/cells/decidim/comments/comment/alignment_badge.erb
109
+ - app/cells/decidim/comments/comment/author.erb
110
+ - app/cells/decidim/comments/comment/show.erb
111
+ - app/cells/decidim/comments/comment/utilities.erb
112
+ - app/cells/decidim/comments/comment/votes.erb
100
113
  - app/cells/decidim/comments/comment_activity_cell.rb
114
+ - app/cells/decidim/comments/comment_card_cell.rb
101
115
  - app/cells/decidim/comments/comment_cell.rb
116
+ - app/cells/decidim/comments/comment_form/comment_as.erb
117
+ - app/cells/decidim/comments/comment_form/show.erb
118
+ - app/cells/decidim/comments/comment_form_cell.rb
102
119
  - app/cells/decidim/comments/comment_m/footer.erb
103
120
  - app/cells/decidim/comments/comment_m/top.erb
104
121
  - app/cells/decidim/comments/comment_m_cell.rb
122
+ - app/cells/decidim/comments/comment_thread/show.erb
123
+ - app/cells/decidim/comments/comment_thread/title.erb
124
+ - app/cells/decidim/comments/comment_thread_cell.rb
125
+ - app/cells/decidim/comments/comments/add_comment.erb
126
+ - app/cells/decidim/comments/comments/blocked_comments_warning.erb
127
+ - app/cells/decidim/comments/comments/order_control.erb
128
+ - app/cells/decidim/comments/comments/show.erb
129
+ - app/cells/decidim/comments/comments/single_comment_warning.erb
130
+ - app/cells/decidim/comments/comments/user_comments_blocked_warning.erb
131
+ - app/cells/decidim/comments/comments_cell.rb
105
132
  - app/commands/decidim/comments/create_comment.rb
106
133
  - app/commands/decidim/comments/vote_comment.rb
134
+ - app/controllers/decidim/comments/application_controller.rb
135
+ - app/controllers/decidim/comments/comments_controller.rb
136
+ - app/controllers/decidim/comments/votes_controller.rb
107
137
  - app/events/decidim/comments/comment_by_followed_user_event.rb
108
138
  - app/events/decidim/comments/comment_by_followed_user_group_event.rb
109
139
  - app/events/decidim/comments/comment_created_event.rb
140
+ - app/events/decidim/comments/comment_downvoted_event.rb
110
141
  - app/events/decidim/comments/comment_event.rb
142
+ - app/events/decidim/comments/comment_upvoted_event.rb
143
+ - app/events/decidim/comments/comment_voted_event.rb
111
144
  - app/events/decidim/comments/reply_created_event.rb
112
145
  - app/events/decidim/comments/user_group_mentioned_event.rb
113
146
  - app/events/decidim/comments/user_mentioned_event.rb
114
147
  - app/forms/decidim/comments/comment_form.rb
115
- - app/frontend/application/apollo_client.ts
116
- - app/frontend/application/application.component.test.tsx
117
- - app/frontend/application/application.component.tsx
118
- - app/frontend/application/icon.component.test.tsx
119
- - app/frontend/application/icon.component.tsx
120
- - app/frontend/comments/add_comment_form.component.test.tsx
121
- - app/frontend/comments/add_comment_form.component.tsx
122
- - app/frontend/comments/comment.component.test.tsx
123
- - app/frontend/comments/comment.component.tsx
124
- - app/frontend/comments/comment_order_selector.component.test.tsx
125
- - app/frontend/comments/comment_order_selector.component.tsx
126
- - app/frontend/comments/comment_thread.component.test.tsx
127
- - app/frontend/comments/comment_thread.component.tsx
128
- - app/frontend/comments/comments.component.test.tsx
129
- - app/frontend/comments/comments.component.tsx
130
- - app/frontend/comments/down_vote_button.component.test.tsx
131
- - app/frontend/comments/down_vote_button.component.tsx
132
- - app/frontend/comments/up_vote_button.component.test.tsx
133
- - app/frontend/comments/up_vote_button.component.tsx
134
- - app/frontend/comments/vote_button.component.tsx
135
- - app/frontend/comments/vote_button_component.test.tsx
136
- - app/frontend/entry.ts
137
- - app/frontend/entry_test.ts
138
- - app/frontend/fragments/add_comment_form_commentable.fragment.graphql
139
- - app/frontend/fragments/add_comment_form_session.fragment.graphql
140
- - app/frontend/fragments/comment.fragment.graphql
141
- - app/frontend/fragments/comment_data.fragment.graphql
142
- - app/frontend/fragments/comment_thread.fragment.graphql
143
- - app/frontend/fragments/down_vote_button.fragment.graphql
144
- - app/frontend/fragments/up_vote_button.fragment.graphql
145
- - app/frontend/mutations/add_comment.mutation.graphql
146
- - app/frontend/mutations/down_vote.mutation.graphql
147
- - app/frontend/mutations/up_vote.mutation.graphql
148
- - app/frontend/queries/comments.query.graphql
149
- - app/frontend/support/asset_url.ts
150
- - app/frontend/support/generate_comments_data.ts
151
- - app/frontend/support/generate_user_data.ts
152
- - app/frontend/support/generate_user_group_data.ts
153
- - app/frontend/support/graphql_transformer.js
154
- - app/frontend/support/load_translations.ts
155
- - app/frontend/support/require_all.ts
156
- - app/frontend/support/resolve_graphql_query.ts
157
- - app/frontend/support/schema.ts
158
148
  - app/helpers/decidim/comments/comment_cells_helper.rb
159
149
  - app/models/decidim/comments/application_record.rb
160
150
  - app/models/decidim/comments/comment.rb
161
151
  - app/models/decidim/comments/comment_vote.rb
162
152
  - app/models/decidim/comments/seed.rb
153
+ - app/permissions/decidim/comments/permissions.rb
163
154
  - app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb
164
155
  - app/queries/decidim/comments/metrics/comments_metric_manage.rb
165
156
  - app/queries/decidim/comments/sorted_comments.rb
@@ -167,9 +158,14 @@ files:
167
158
  - app/scrubbers/decidim/comments/user_input_scrubber.rb
168
159
  - app/services/decidim/comments/comment_creation.rb
169
160
  - app/services/decidim/comments/new_comment_notification_creator.rb
170
- - app/types/decidim/comments/commentable_interface.rb
171
- - app/types/decidim/comments/commentable_mutation_type.rb
172
- - app/types/decidim/comments/commentable_type.rb
161
+ - app/views/decidim/comments/comments/_comment.html.erb
162
+ - app/views/decidim/comments/comments/_comments.html.erb
163
+ - app/views/decidim/comments/comments/create.js.erb
164
+ - app/views/decidim/comments/comments/error.js.erb
165
+ - app/views/decidim/comments/comments/index.js.erb
166
+ - app/views/decidim/comments/comments/reload.js.erb
167
+ - app/views/decidim/comments/votes/create.js.erb
168
+ - app/views/decidim/comments/votes/error.js.erb
173
169
  - config/locales/am-ET.yml
174
170
  - config/locales/ar-SA.yml
175
171
  - config/locales/ar.yml
@@ -223,12 +219,14 @@ files:
223
219
  - config/locales/pt.yml
224
220
  - config/locales/ro-RO.yml
225
221
  - config/locales/ru.yml
222
+ - config/locales/si-LK.yml
226
223
  - config/locales/sk-SK.yml
227
224
  - config/locales/sk.yml
228
225
  - config/locales/sl.yml
229
226
  - config/locales/so-SO.yml
230
227
  - config/locales/sr-CS.yml
231
228
  - config/locales/sv.yml
229
+ - config/locales/sw-KE.yml
232
230
  - config/locales/ti-ER.yml
233
231
  - config/locales/tr-TR.yml
234
232
  - config/locales/uk.yml
@@ -251,12 +249,16 @@ files:
251
249
  - db/migrate/20200706123136_make_comments_handle_i18n.rb
252
250
  - db/migrate/20200828101910_add_commentable_counter_cache_to_comments.rb
253
251
  - db/seeds.rb
252
+ - lib/decidim/api/add_comment_type.rb
253
+ - lib/decidim/api/comment_mutation_type.rb
254
+ - lib/decidim/api/comment_type.rb
255
+ - lib/decidim/api/commentable_interface.rb
256
+ - lib/decidim/api/commentable_mutation_type.rb
257
+ - lib/decidim/api/commentable_type.rb
254
258
  - lib/decidim/comments.rb
255
259
  - lib/decidim/comments/admin.rb
256
260
  - lib/decidim/comments/admin_engine.rb
257
- - lib/decidim/comments/api/add_comment_type.rb
258
- - lib/decidim/comments/api/comment_mutation_type.rb
259
- - lib/decidim/comments/api/comment_type.rb
261
+ - lib/decidim/comments/api.rb
260
262
  - lib/decidim/comments/comment_serializer.rb
261
263
  - lib/decidim/comments/comment_vote_serializer.rb
262
264
  - lib/decidim/comments/commentable.rb
@@ -269,13 +271,14 @@ files:
269
271
  - lib/decidim/comments/test.rb
270
272
  - lib/decidim/comments/test/factories.rb
271
273
  - lib/decidim/comments/test/shared_examples/comment_event.rb
274
+ - lib/decidim/comments/test/shared_examples/comment_voted_event.rb
272
275
  - lib/decidim/comments/test/shared_examples/create_comment_context.rb
273
276
  - lib/decidim/comments/version.rb
274
277
  homepage: https://github.com/decidim/decidim
275
278
  licenses:
276
279
  - AGPL-3.0
277
280
  metadata: {}
278
- post_install_message:
281
+ post_install_message:
279
282
  rdoc_options: []
280
283
  require_paths:
281
284
  - lib
@@ -283,15 +286,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
283
286
  requirements:
284
287
  - - ">="
285
288
  - !ruby/object:Gem::Version
286
- version: '2.6'
289
+ version: '2.7'
287
290
  required_rubygems_version: !ruby/object:Gem::Requirement
288
291
  requirements:
289
- - - ">="
292
+ - - ">"
290
293
  - !ruby/object:Gem::Version
291
- version: '0'
294
+ version: 1.3.1
292
295
  requirements: []
293
- rubygems_version: 3.0.3
294
- signing_key:
296
+ rubygems_version: 3.1.2
297
+ signing_key:
295
298
  specification_version: 4
296
299
  summary: Decidim comments module
297
300
  test_files: []