decidim-comments 0.22.0 → 0.23.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/comments/bundle.js +53 -53
  3. data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
  4. data/app/cells/decidim/comments/comment_activity_cell.rb +2 -22
  5. data/app/cells/decidim/comments/comment_cell.rb +22 -0
  6. data/app/cells/decidim/comments/comment_m/footer.erb +5 -0
  7. data/app/cells/decidim/comments/comment_m/top.erb +7 -0
  8. data/app/cells/decidim/comments/comment_m_cell.rb +29 -0
  9. data/app/commands/decidim/comments/create_comment.rb +1 -1
  10. data/app/events/decidim/comments/comment_event.rb +1 -9
  11. data/app/forms/decidim/comments/comment_form.rb +8 -1
  12. data/app/frontend/comments/add_comment_form.component.test.tsx +30 -28
  13. data/app/frontend/comments/add_comment_form.component.tsx +32 -16
  14. data/app/frontend/comments/comment.component.test.tsx +35 -4
  15. data/app/frontend/comments/comment.component.tsx +24 -15
  16. data/app/frontend/comments/comment_thread.component.test.tsx +9 -8
  17. data/app/frontend/comments/comment_thread.component.tsx +3 -1
  18. data/app/frontend/comments/comments.component.test.tsx +17 -14
  19. data/app/frontend/comments/comments.component.tsx +28 -4
  20. data/app/frontend/comments/down_vote_button.component.tsx +24 -9
  21. data/app/frontend/comments/up_vote_button.component.tsx +24 -9
  22. data/app/frontend/mutations/add_comment.mutation.graphql +2 -2
  23. data/app/frontend/mutations/down_vote.mutation.graphql +2 -2
  24. data/app/frontend/mutations/up_vote.mutation.graphql +2 -2
  25. data/app/frontend/queries/comments.query.graphql +2 -2
  26. data/app/frontend/support/schema.ts +1060 -735
  27. data/app/helpers/decidim/comments/comment_cells_helper.rb +33 -0
  28. data/app/models/decidim/comments/comment.rb +80 -21
  29. data/app/models/decidim/comments/seed.rb +1 -1
  30. data/app/types/decidim/comments/commentable_interface.rb +1 -1
  31. data/app/types/decidim/comments/commentable_mutation_type.rb +4 -1
  32. data/config/locales/am-ET.yml +1 -0
  33. data/config/locales/bg.yml +6 -0
  34. data/config/locales/ca.yml +1 -0
  35. data/config/locales/cs.yml +2 -1
  36. data/config/locales/da.yml +1 -0
  37. data/config/locales/de.yml +29 -28
  38. data/config/locales/en.yml +1 -0
  39. data/config/locales/eo.yml +1 -0
  40. data/config/locales/es-MX.yml +1 -0
  41. data/config/locales/es-PY.yml +1 -0
  42. data/config/locales/es.yml +3 -2
  43. data/config/locales/et.yml +1 -0
  44. data/config/locales/fi-plain.yml +1 -0
  45. data/config/locales/fi.yml +2 -1
  46. data/config/locales/fr-CA.yml +2 -1
  47. data/config/locales/fr.yml +2 -1
  48. data/config/locales/gl.yml +13 -0
  49. data/config/locales/hr.yml +1 -0
  50. data/config/locales/hu.yml +1 -1
  51. data/config/locales/is-IS.yml +0 -2
  52. data/config/locales/is.yml +76 -0
  53. data/config/locales/it.yml +1 -0
  54. data/config/locales/ja-JP.yml +2 -2
  55. data/config/locales/ja.yml +121 -0
  56. data/config/locales/ko-KR.yml +1 -0
  57. data/config/locales/ko.yml +1 -0
  58. data/config/locales/lt.yml +1 -0
  59. data/config/locales/{lv-LV.yml → lv.yml} +0 -0
  60. data/config/locales/mt.yml +1 -0
  61. data/config/locales/nl.yml +11 -10
  62. data/config/locales/om-ET.yml +1 -0
  63. data/config/locales/pl.yml +6 -5
  64. data/config/locales/si-LK.yml +1 -0
  65. data/config/locales/so-SO.yml +1 -0
  66. data/config/locales/sv.yml +1 -0
  67. data/config/locales/sw-KE.yml +1 -0
  68. data/config/locales/ti-ER.yml +1 -0
  69. data/config/locales/tr-TR.yml +53 -33
  70. data/config/locales/uk.yml +0 -1
  71. data/config/locales/vi-VN.yml +1 -0
  72. data/config/locales/vi.yml +1 -0
  73. data/config/locales/zh-CN.yml +121 -0
  74. data/config/locales/zh-TW.yml +1 -0
  75. data/db/migrate/20200706123136_make_comments_handle_i18n.rb +41 -0
  76. data/db/migrate/20200828101910_add_commentable_counter_cache_to_comments.rb +9 -0
  77. data/lib/decidim/comments/api/comment_type.rb +5 -1
  78. data/lib/decidim/comments/comment_serializer.rb +7 -2
  79. data/lib/decidim/comments/comment_vote_serializer.rb +5 -1
  80. data/lib/decidim/comments/commentable.rb +11 -0
  81. data/lib/decidim/comments/comments_helper.rb +28 -4
  82. data/lib/decidim/comments/engine.rb +13 -0
  83. data/lib/decidim/comments/mutation_extensions.rb +8 -0
  84. data/lib/decidim/comments/query_extensions.rb +4 -0
  85. data/lib/decidim/comments/test/factories.rb +10 -1
  86. data/lib/decidim/comments/test/shared_examples/comment_event.rb +1 -1
  87. data/lib/decidim/comments/version.rb +1 -1
  88. metadata +42 -14
@@ -59,6 +59,19 @@ module Decidim
59
59
  metric_operation.manager_class = "Decidim::Comments::Metrics::CommentParticipantsMetricMeasure"
60
60
  end
61
61
  end
62
+
63
+ initializer "decidim_comments.register_resources" do
64
+ Decidim.register_resource(:comment) do |resource|
65
+ resource.model_class_name = "Decidim::Comments::Comment"
66
+ resource.card = "decidim/comments/comment"
67
+ resource.searchable = true
68
+ end
69
+ end
70
+
71
+ initializer "decidim_comments.add_cells_view_paths" do
72
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Comments::Engine.root}/app/cells")
73
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Comments::Engine.root}/app/views") # for partials
74
+ end
62
75
  end
63
76
  end
64
77
  end
@@ -16,8 +16,12 @@ module Decidim
16
16
 
17
17
  argument :id, !types.String, "The commentable's ID"
18
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."
19
21
 
20
22
  resolve lambda { |_obj, args, _ctx|
23
+ I18n.locale = args[:locale].presence
24
+ RequestStore.store[:toggle_machine_translations] = args[:toggleTranslations]
21
25
  args[:type].constantize.find(args[:id])
22
26
  }
23
27
  end
@@ -26,8 +30,12 @@ module Decidim
26
30
  description "A comment"
27
31
 
28
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."
29
35
 
30
36
  resolve lambda { |_obj, args, _ctx|
37
+ I18n.locale = args[:locale].presence
38
+ RequestStore.store[:toggle_machine_translations] = args[:toggleTranslations]
31
39
  Comment.find(args["id"])
32
40
  }
33
41
  end
@@ -16,8 +16,12 @@ module Decidim
16
16
 
17
17
  argument :id, !types.String, "The commentable's ID"
18
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."
19
21
 
20
22
  resolve lambda { |_obj, args, _ctx|
23
+ I18n.locale = args[:locale].presence
24
+ RequestStore.store[:toggle_machine_translations] = args[:toggleTranslations]
21
25
  args[:type].constantize.find(args[:id])
22
26
  }
23
27
  end
@@ -7,7 +7,16 @@ FactoryBot.define do
7
7
  author { build(:user, organization: commentable.organization) }
8
8
  commentable { build(:dummy_resource) }
9
9
  root_commentable { commentable }
10
- body { Faker::Lorem.paragraph }
10
+ body { Decidim::Faker::Localized.paragraph }
11
+
12
+ after(:build) do |comment, evaluator|
13
+ comment.body = if evaluator.body.is_a?(String)
14
+ { comment.root_commentable.organization.default_locale || "en" => evaluator.body }
15
+ else
16
+ evaluator.body
17
+ end
18
+ comment.body = Decidim::ContentProcessor.parse_with_processor(:hashtag, comment.body, current_organization: comment.root_commentable.organization).rewrite
19
+ end
11
20
 
12
21
  trait :comment_on_comment do
13
22
  author { build(:user, organization: root_commentable.organization) }
@@ -16,7 +16,7 @@ shared_context "when it's a comment event" do
16
16
  let(:comment_author_name) { decidim_html_escape comment.author.name }
17
17
 
18
18
  let(:extra) { { comment_id: comment.id } }
19
- let(:resource_title) { decidim_html_escape resource.title }
19
+ let(:resource_title) { decidim_html_escape(translated(resource.title)) }
20
20
  let(:user_group) do
21
21
  user_group = create(:user_group, :verified, organization: organization, users: [comment_author])
22
22
  comment.update!(user_group: user_group)
@@ -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.22.0"
7
+ "0.23.3"
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.22.0
4
+ version: 0.23.3
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-09-01 00:00:00.000000000 Z
13
+ date: 2021-02-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.22.0
21
+ version: 0.23.3
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.22.0
28
+ version: 0.23.3
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: jquery-rails
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -60,28 +60,28 @@ dependencies:
60
60
  requirements:
61
61
  - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 0.22.0
63
+ version: 0.23.3
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - '='
69
69
  - !ruby/object:Gem::Version
70
- version: 0.22.0
70
+ version: 0.23.3
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: decidim-dev
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - '='
76
76
  - !ruby/object:Gem::Version
77
- version: 0.22.0
77
+ version: 0.23.3
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - '='
83
83
  - !ruby/object:Gem::Version
84
- version: 0.22.0
84
+ version: 0.23.3
85
85
  description: Pluggable comments system for some components.
86
86
  email:
87
87
  - josepjaume@gmail.com
@@ -98,6 +98,10 @@ files:
98
98
  - app/assets/javascripts/decidim/comments/bundle.js.map
99
99
  - app/assets/javascripts/decidim/comments/comments.js.erb
100
100
  - app/cells/decidim/comments/comment_activity_cell.rb
101
+ - app/cells/decidim/comments/comment_cell.rb
102
+ - app/cells/decidim/comments/comment_m/footer.erb
103
+ - app/cells/decidim/comments/comment_m/top.erb
104
+ - app/cells/decidim/comments/comment_m_cell.rb
101
105
  - app/commands/decidim/comments/create_comment.rb
102
106
  - app/commands/decidim/comments/vote_comment.rb
103
107
  - app/events/decidim/comments/comment_by_followed_user_event.rb
@@ -151,6 +155,7 @@ files:
151
155
  - app/frontend/support/require_all.ts
152
156
  - app/frontend/support/resolve_graphql_query.ts
153
157
  - app/frontend/support/schema.ts
158
+ - app/helpers/decidim/comments/comment_cells_helper.rb
154
159
  - app/models/decidim/comments/application_record.rb
155
160
  - app/models/decidim/comments/comment.rb
156
161
  - app/models/decidim/comments/comment_vote.rb
@@ -165,22 +170,27 @@ files:
165
170
  - app/types/decidim/comments/commentable_interface.rb
166
171
  - app/types/decidim/comments/commentable_mutation_type.rb
167
172
  - app/types/decidim/comments/commentable_type.rb
173
+ - config/locales/am-ET.yml
168
174
  - config/locales/ar-SA.yml
169
175
  - config/locales/ar.yml
170
176
  - config/locales/bg-BG.yml
177
+ - config/locales/bg.yml
171
178
  - config/locales/ca.yml
172
179
  - config/locales/cs-CZ.yml
173
180
  - config/locales/cs.yml
174
181
  - config/locales/da-DK.yml
182
+ - config/locales/da.yml
175
183
  - config/locales/de.yml
176
184
  - config/locales/el-GR.yml
177
185
  - config/locales/el.yml
178
186
  - config/locales/en.yml
179
187
  - config/locales/eo-UY.yml
188
+ - config/locales/eo.yml
180
189
  - config/locales/es-MX.yml
181
190
  - config/locales/es-PY.yml
182
191
  - config/locales/es.yml
183
192
  - config/locales/et-EE.yml
193
+ - config/locales/et.yml
184
194
  - config/locales/eu.yml
185
195
  - config/locales/fi-pl.yml
186
196
  - config/locales/fi-plain.yml
@@ -190,28 +200,44 @@ files:
190
200
  - config/locales/ga-IE.yml
191
201
  - config/locales/gl.yml
192
202
  - config/locales/hr-HR.yml
203
+ - config/locales/hr.yml
193
204
  - config/locales/hu.yml
194
205
  - config/locales/id-ID.yml
195
206
  - config/locales/is-IS.yml
207
+ - config/locales/is.yml
196
208
  - config/locales/it.yml
197
209
  - config/locales/ja-JP.yml
210
+ - config/locales/ja.yml
211
+ - config/locales/ko-KR.yml
212
+ - config/locales/ko.yml
198
213
  - config/locales/lt-LT.yml
199
- - config/locales/lv-LV.yml
214
+ - config/locales/lt.yml
215
+ - config/locales/lv.yml
200
216
  - config/locales/mt-MT.yml
217
+ - config/locales/mt.yml
201
218
  - config/locales/nl.yml
202
219
  - config/locales/no.yml
220
+ - config/locales/om-ET.yml
203
221
  - config/locales/pl.yml
204
222
  - config/locales/pt-BR.yml
205
223
  - config/locales/pt.yml
206
224
  - config/locales/ro-RO.yml
207
225
  - config/locales/ru.yml
226
+ - config/locales/si-LK.yml
208
227
  - config/locales/sk-SK.yml
209
228
  - config/locales/sk.yml
210
229
  - config/locales/sl.yml
230
+ - config/locales/so-SO.yml
211
231
  - config/locales/sr-CS.yml
212
232
  - config/locales/sv.yml
233
+ - config/locales/sw-KE.yml
234
+ - config/locales/ti-ER.yml
213
235
  - config/locales/tr-TR.yml
214
236
  - config/locales/uk.yml
237
+ - config/locales/vi-VN.yml
238
+ - config/locales/vi.yml
239
+ - config/locales/zh-CN.yml
240
+ - config/locales/zh-TW.yml
215
241
  - db/migrate/20161130143508_create_comments.rb
216
242
  - db/migrate/20161214082645_add_depth_to_comments.rb
217
243
  - db/migrate/20161216102820_add_alignment_to_comments.rb
@@ -224,6 +250,8 @@ files:
224
250
  - db/migrate/20181016142511_make_authors_polymorphic_for_comments.rb
225
251
  - db/migrate/20181019092928_make_author_polymorphic_for_comment_votes.rb
226
252
  - db/migrate/20200320105911_index_foreign_keys_in_decidim_comments_comments.rb
253
+ - db/migrate/20200706123136_make_comments_handle_i18n.rb
254
+ - db/migrate/20200828101910_add_commentable_counter_cache_to_comments.rb
227
255
  - db/seeds.rb
228
256
  - lib/decidim/comments.rb
229
257
  - lib/decidim/comments/admin.rb
@@ -249,7 +277,7 @@ homepage: https://github.com/decidim/decidim
249
277
  licenses:
250
278
  - AGPL-3.0
251
279
  metadata: {}
252
- post_install_message:
280
+ post_install_message:
253
281
  rdoc_options: []
254
282
  require_paths:
255
283
  - lib
@@ -257,15 +285,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
257
285
  requirements:
258
286
  - - ">="
259
287
  - !ruby/object:Gem::Version
260
- version: '2.5'
288
+ version: '2.6'
261
289
  required_rubygems_version: !ruby/object:Gem::Requirement
262
290
  requirements:
263
291
  - - ">="
264
292
  - !ruby/object:Gem::Version
265
293
  version: '0'
266
294
  requirements: []
267
- rubygems_version: 3.1.2
268
- signing_key:
295
+ rubygems_version: 3.0.3
296
+ signing_key:
269
297
  specification_version: 4
270
298
  summary: Decidim comments module
271
299
  test_files: []