decidim-comments 0.23.3 → 0.24.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/comments/comments.component.js.es6 +292 -0
- data/app/assets/javascripts/decidim/comments/comments.component.test.js +581 -0
- data/app/assets/javascripts/decidim/comments/comments.js.erb +1 -1
- data/app/cells/decidim/comments/comment/actions.erb +7 -0
- data/app/cells/decidim/comments/comment/alignment_badge.erb +4 -0
- data/app/cells/decidim/comments/comment/author.erb +1 -0
- data/app/cells/decidim/comments/comment/show.erb +40 -0
- data/app/cells/decidim/comments/comment/utilities.erb +13 -0
- data/app/cells/decidim/comments/comment/votes.erb +25 -0
- data/app/cells/decidim/comments/comment_card_cell.rb +22 -0
- data/app/cells/decidim/comments/comment_cell.rb +142 -8
- data/app/cells/decidim/comments/comment_form/comment_as.erb +10 -0
- data/app/cells/decidim/comments/comment_form/show.erb +24 -0
- data/app/cells/decidim/comments/comment_form_cell.rb +94 -0
- data/app/cells/decidim/comments/comment_m/top.erb +1 -1
- data/app/cells/decidim/comments/comment_thread/show.erb +6 -0
- data/app/cells/decidim/comments/comment_thread/title.erb +3 -0
- data/app/cells/decidim/comments/comment_thread_cell.rb +30 -0
- data/app/cells/decidim/comments/comments/add_comment.erb +30 -0
- data/app/cells/decidim/comments/comments/blocked_comments_warning.erb +3 -0
- data/app/cells/decidim/comments/comments/order_control.erb +37 -0
- data/app/cells/decidim/comments/comments/show.erb +32 -0
- data/app/cells/decidim/comments/comments/single_comment_warning.erb +9 -0
- data/app/cells/decidim/comments/comments/user_comments_blocked_warning.erb +3 -0
- data/app/cells/decidim/comments/comments_cell.rb +134 -0
- data/app/commands/decidim/comments/vote_comment.rb +34 -10
- data/app/controllers/decidim/comments/application_controller.rb +16 -0
- data/app/controllers/decidim/comments/comments_controller.rb +122 -0
- data/app/controllers/decidim/comments/votes_controller.rb +41 -0
- data/app/events/decidim/comments/comment_created_event.rb +1 -1
- data/app/events/decidim/comments/comment_downvoted_event.rb +8 -0
- data/app/events/decidim/comments/comment_upvoted_event.rb +8 -0
- data/app/events/decidim/comments/comment_voted_event.rb +26 -0
- data/app/forms/decidim/comments/comment_form.rb +6 -2
- data/app/models/decidim/comments/comment.rb +22 -6
- data/app/models/decidim/comments/seed.rb +1 -1
- data/app/permissions/decidim/comments/permissions.rb +59 -0
- data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +2 -2
- data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +5 -6
- data/app/queries/decidim/comments/sorted_comments.rb +18 -14
- data/app/views/decidim/comments/comments/_comment.html.erb +5 -0
- data/app/views/decidim/comments/comments/_comments.html.erb +1 -0
- data/app/views/decidim/comments/comments/create.js.erb +16 -0
- data/app/views/decidim/comments/comments/error.js.erb +1 -0
- data/app/views/decidim/comments/comments/index.js.erb +24 -0
- data/app/views/decidim/comments/comments/reload.js.erb +21 -0
- data/app/views/decidim/comments/votes/create.js.erb +23 -0
- data/app/views/decidim/comments/votes/error.js.erb +1 -0
- data/config/locales/ar.yml +0 -2
- data/config/locales/ca.yml +17 -2
- data/config/locales/cs.yml +24 -7
- data/config/locales/de.yml +17 -2
- data/config/locales/el.yml +0 -2
- data/config/locales/en.yml +17 -2
- data/config/locales/es-MX.yml +17 -2
- data/config/locales/es-PY.yml +17 -2
- data/config/locales/es.yml +17 -2
- data/config/locales/eu.yml +0 -2
- data/config/locales/fi-plain.yml +17 -2
- data/config/locales/fi.yml +17 -2
- data/config/locales/fr-CA.yml +17 -2
- data/config/locales/fr.yml +17 -2
- data/config/locales/gl.yml +7 -2
- data/config/locales/hu.yml +0 -2
- data/config/locales/id-ID.yml +0 -2
- data/config/locales/is-IS.yml +0 -1
- data/config/locales/it.yml +4 -2
- data/config/locales/ja.yml +8 -4
- data/config/locales/lv.yml +0 -2
- data/config/locales/nl.yml +0 -2
- data/config/locales/no.yml +0 -2
- data/config/locales/pl.yml +21 -4
- data/config/locales/pt-BR.yml +0 -2
- data/config/locales/pt.yml +0 -2
- data/config/locales/ro-RO.yml +19 -2
- data/config/locales/ru.yml +0 -2
- data/config/locales/sk.yml +0 -2
- data/config/locales/sv.yml +17 -2
- data/config/locales/tr-TR.yml +7 -2
- data/config/locales/uk.yml +0 -1
- data/config/locales/zh-CN.yml +0 -2
- data/lib/decidim/api/add_comment_type.rb +13 -0
- data/lib/decidim/api/comment_mutation_type.rb +22 -0
- data/lib/decidim/api/comment_type.rb +89 -0
- data/lib/decidim/api/commentable_interface.rb +50 -0
- data/lib/decidim/api/commentable_mutation_type.rb +30 -0
- data/{app/types/decidim/comments → lib/decidim/api}/commentable_type.rb +2 -5
- data/lib/decidim/comments.rb +1 -3
- data/lib/decidim/comments/api.rb +12 -0
- data/lib/decidim/comments/comments_helper.rb +10 -52
- data/lib/decidim/comments/engine.rb +9 -7
- data/lib/decidim/comments/mutation_extensions.rb +22 -22
- data/lib/decidim/comments/query_extensions.rb +12 -14
- data/lib/decidim/comments/test.rb +1 -0
- data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +65 -0
- data/lib/decidim/comments/version.rb +1 -1
- metadata +65 -64
- data/app/assets/javascripts/decidim/comments/bundle.js +0 -268
- data/app/frontend/application/apollo_client.ts +0 -12
- data/app/frontend/application/application.component.test.tsx +0 -23
- data/app/frontend/application/application.component.tsx +0 -35
- data/app/frontend/application/icon.component.test.tsx +0 -38
- data/app/frontend/application/icon.component.tsx +0 -46
- data/app/frontend/comments/add_comment_form.component.test.tsx +0 -265
- data/app/frontend/comments/add_comment_form.component.tsx +0 -482
- data/app/frontend/comments/comment.component.test.tsx +0 -490
- data/app/frontend/comments/comment.component.tsx +0 -677
- data/app/frontend/comments/comment_order_selector.component.test.tsx +0 -29
- data/app/frontend/comments/comment_order_selector.component.tsx +0 -106
- data/app/frontend/comments/comment_thread.component.test.tsx +0 -82
- data/app/frontend/comments/comment_thread.component.tsx +0 -81
- data/app/frontend/comments/comments.component.test.tsx +0 -150
- data/app/frontend/comments/comments.component.tsx +0 -289
- data/app/frontend/comments/down_vote_button.component.test.tsx +0 -59
- data/app/frontend/comments/down_vote_button.component.tsx +0 -133
- data/app/frontend/comments/up_vote_button.component.test.tsx +0 -59
- data/app/frontend/comments/up_vote_button.component.tsx +0 -133
- data/app/frontend/comments/vote_button.component.tsx +0 -50
- data/app/frontend/comments/vote_button_component.test.tsx +0 -64
- data/app/frontend/entry.ts +0 -38
- data/app/frontend/entry_test.ts +0 -6
- data/app/frontend/fragments/add_comment_form_commentable.fragment.graphql +0 -4
- data/app/frontend/fragments/add_comment_form_session.fragment.graphql +0 -6
- data/app/frontend/fragments/comment.fragment.graphql +0 -14
- data/app/frontend/fragments/comment_data.fragment.graphql +0 -27
- data/app/frontend/fragments/comment_thread.fragment.graphql +0 -6
- data/app/frontend/fragments/down_vote_button.fragment.graphql +0 -6
- data/app/frontend/fragments/up_vote_button.fragment.graphql +0 -6
- data/app/frontend/mutations/add_comment.mutation.graphql +0 -9
- data/app/frontend/mutations/down_vote.mutation.graphql +0 -9
- data/app/frontend/mutations/up_vote.mutation.graphql +0 -9
- data/app/frontend/queries/comments.query.graphql +0 -26
- data/app/frontend/support/asset_url.ts +0 -11
- data/app/frontend/support/generate_comments_data.ts +0 -49
- data/app/frontend/support/generate_user_data.ts +0 -14
- data/app/frontend/support/generate_user_group_data.ts +0 -14
- data/app/frontend/support/graphql_transformer.js +0 -32
- data/app/frontend/support/load_translations.ts +0 -48
- data/app/frontend/support/require_all.ts +0 -10
- data/app/frontend/support/resolve_graphql_query.ts +0 -37
- data/app/frontend/support/schema.ts +0 -2026
- data/app/types/decidim/comments/commentable_interface.rb +0 -61
- data/app/types/decidim/comments/commentable_mutation_type.rb +0 -33
- data/lib/decidim/comments/api/add_comment_type.rb +0 -13
- data/lib/decidim/comments/api/comment_mutation_type.rb +0 -20
- 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
|