decidim-comments 0.0.8.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/comments/bundle.js +4 -486
  3. data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
  4. data/app/commands/decidim/comments/create_comment.rb +8 -2
  5. data/app/frontend/application/application.component.tsx +3 -3
  6. data/app/frontend/application/icon.component.tsx +1 -1
  7. data/app/frontend/comments/add_comment_form.component.tsx +7 -7
  8. data/app/frontend/comments/comment.component.test.tsx +7 -7
  9. data/app/frontend/comments/comment.component.tsx +6 -6
  10. data/app/frontend/comments/comment_thread.component.tsx +2 -2
  11. data/app/frontend/comments/comments.component.test.tsx +5 -5
  12. data/app/frontend/comments/comments.component.tsx +6 -6
  13. data/app/frontend/comments/down_vote_button.component.test.tsx +4 -4
  14. data/app/frontend/comments/down_vote_button.component.tsx +3 -3
  15. data/app/frontend/comments/up_vote_button.component.test.tsx +4 -4
  16. data/app/frontend/comments/up_vote_button.component.tsx +3 -3
  17. data/app/frontend/comments/vote_button.component.tsx +1 -1
  18. data/app/frontend/comments/vote_button_component.test.tsx +2 -2
  19. data/app/frontend/entry.ts +2 -2
  20. data/app/frontend/support/generate_comments_data.ts +2 -2
  21. data/app/frontend/support/load_translations.ts +2 -2
  22. data/app/frontend/support/resolve_graphql_query.ts +1 -1
  23. data/app/mailers/decidim/comments/comment_notification_mailer.rb +1 -1
  24. data/app/models/decidim/comments/comment.rb +3 -8
  25. data/app/models/decidim/comments/seed.rb +1 -0
  26. data/config/locales/fr.yml +62 -1
  27. data/db/migrate/20170504085413_add_root_commentable_to_comments.rb +7 -0
  28. data/db/migrate/20170510091348_update_root_commentable_for_comments.rb +22 -0
  29. data/db/migrate/20170510091409_set_root_commentable_null_constraints.rb +6 -0
  30. data/db/seeds.rb +4 -2
  31. data/lib/decidim/comments/engine.rb +8 -0
  32. data/lib/decidim/comments/test/factories.rb +1 -0
  33. metadata +9 -6
@@ -0,0 +1,7 @@
1
+ class AddRootCommentableToComments < ActiveRecord::Migration[5.0]
2
+ def change
3
+ change_table :decidim_comments_comments do |t|
4
+ t.references :decidim_root_commentable, polymorphic: true, index: { name: "decidim_comments_comment_root_commentable" }
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ class UpdateRootCommentableForComments < ActiveRecord::Migration[5.0]
2
+ def up
3
+ Decidim::Comments::Comment.where(depth: 0).update_all(
4
+ "decidim_root_commentable_id = decidim_commentable_id, decidim_root_commentable_type = decidim_commentable_type"
5
+ )
6
+
7
+ Decidim::Comments::Comment.where("depth > 0").find_each do |comment|
8
+ comment.root_commentable = root_commentable(comment)
9
+ comment.save(validate: false)
10
+ end
11
+ end
12
+
13
+ def down
14
+ end
15
+
16
+ private
17
+
18
+ def root_commentable(comment)
19
+ return comment.commentable if comment.depth.zero?
20
+ root_commentable comment.commentable
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ class SetRootCommentableNullConstraints < ActiveRecord::Migration[5.0]
2
+ def change
3
+ change_column_null(:decidim_comments_comments, :decidim_root_commentable_id, false)
4
+ change_column_null(:decidim_comments_comments, :decidim_root_commentable_type, false)
5
+ end
6
+ end
data/db/seeds.rb CHANGED
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
1
2
  # Since comments cannot exist without a real model we are not including
2
3
  # specific seeds for this engine.
3
4
  # Other engines are free to include comments on their seeds like this:
4
- #
5
- # n.times do
5
+ #
6
+ # n.times do
6
7
  # Decidim::Comments::Comment.create!(
7
8
  # author: author,
8
9
  # commentable: commentable,
10
+ # root_commentable: commentable,
9
11
  # body: Faker::Lorem.paragraph
10
12
  # )
11
13
  # end
@@ -29,6 +29,14 @@ module Decidim
29
29
  initializer "decidim_comments.mutation_extensions" do
30
30
  Comments::MutationExtensions.extend!(Decidim::Api::MutationType)
31
31
  end
32
+
33
+ initializer "decidim.stats" do
34
+ Decidim.stats.register :comments_count, priority: StatsRegistry::MEDIUM_PRIORITY do |features, start_at, end_at|
35
+ Decidim.feature_manifests.sum do |feature|
36
+ feature.stats.filter(tag: :comments).with_context(features, start_at, end_at).map { |_name, value| value }.sum
37
+ end
38
+ end
39
+ end
32
40
  end
33
41
  end
34
42
  end
@@ -6,6 +6,7 @@ FactoryGirl.define do
6
6
  factory :comment, class: "Decidim::Comments::Comment" do
7
7
  author { build(:user, organization: commentable.organization) }
8
8
  commentable { build(:dummy_resource) }
9
+ root_commentable { commentable }
9
10
  body { Faker::Lorem.paragraph }
10
11
  end
11
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-04-27 00:00:00.000000000 Z
13
+ date: 2017-05-18 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.0.8.1
21
+ version: 0.1.0
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.0.8.1
28
+ version: 0.1.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rails
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 0.0.8.1
63
+ version: 0.1.0
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.0.8.1
70
+ version: 0.1.0
71
71
  description: Pluggable comments system for some components.
72
72
  email:
73
73
  - josepjaume@gmail.com
@@ -155,6 +155,9 @@ files:
155
155
  - db/migrate/20161216102820_add_alignment_to_comments.rb
156
156
  - db/migrate/20161219150806_create_comment_votes.rb
157
157
  - db/migrate/20170123102043_add_user_group_id_to_comments.rb
158
+ - db/migrate/20170504085413_add_root_commentable_to_comments.rb
159
+ - db/migrate/20170510091348_update_root_commentable_for_comments.rb
160
+ - db/migrate/20170510091409_set_root_commentable_null_constraints.rb
158
161
  - db/seeds.rb
159
162
  - lib/decidim/comments.rb
160
163
  - lib/decidim/comments/admin.rb