decidim-comments 0.3.2 → 0.4.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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/comments/bundle.js +30 -30
- data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
- data/app/commands/decidim/comments/create_comment.rb +10 -14
- data/app/frontend/application/application.component.tsx +1 -1
- data/app/frontend/comments/add_comment_form.component.test.tsx +33 -26
- data/app/frontend/comments/add_comment_form.component.tsx +109 -83
- data/app/frontend/comments/comment.component.test.tsx +29 -24
- data/app/frontend/comments/comment.component.tsx +12 -5
- data/app/frontend/comments/comment_thread.component.test.tsx +12 -7
- data/app/frontend/comments/comment_thread.component.tsx +7 -2
- data/app/frontend/comments/comments.component.tsx +26 -15
- data/app/frontend/comments/down_vote_button.component.test.tsx +9 -4
- data/app/frontend/comments/down_vote_button.component.tsx +56 -37
- data/app/frontend/comments/up_vote_button.component.test.tsx +9 -4
- data/app/frontend/comments/up_vote_button.component.tsx +31 -16
- data/app/frontend/comments/vote_button.component.tsx +3 -0
- data/app/mailers/decidim/comments/comment_notification_mailer.rb +8 -6
- data/app/models/decidim/comments/comment.rb +13 -1
- data/app/views/decidim/comments/comment_notification_mailer/comment_created.html.erb +1 -1
- data/app/views/decidim/comments/comment_notification_mailer/reply_created.html.erb +1 -1
- data/config/locales/ca.yml +2 -0
- data/config/locales/en.yml +2 -0
- data/config/locales/es.yml +2 -0
- data/config/locales/fr.yml +2 -2
- data/lib/decidim/comments/commentable.rb +1 -0
- metadata +6 -6
@@ -1,9 +1,10 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import { graphql } from "react-apollo";
|
2
|
+
import { graphql, MutationFunc } from "react-apollo";
|
3
3
|
|
4
4
|
import VoteButton from "./vote_button.component";
|
5
5
|
|
6
6
|
import {
|
7
|
+
AddCommentFormCommentableFragment,
|
7
8
|
AddCommentFormSessionFragment,
|
8
9
|
CommentFragment,
|
9
10
|
GetCommentsQuery,
|
@@ -17,6 +18,8 @@ interface UpVoteButtonProps {
|
|
17
18
|
} | null;
|
18
19
|
comment: UpVoteButtonFragment;
|
19
20
|
upVote?: () => void;
|
21
|
+
rootCommentable: AddCommentFormCommentableFragment;
|
22
|
+
orderBy: string;
|
20
23
|
}
|
21
24
|
|
22
25
|
export const UpVoteButton: React.SFC<UpVoteButtonProps> = ({
|
@@ -49,9 +52,10 @@ export const UpVoteButton: React.SFC<UpVoteButtonProps> = ({
|
|
49
52
|
};
|
50
53
|
|
51
54
|
const upVoteMutation = require("../mutations/up_vote.mutation.graphql");
|
55
|
+
const getCommentsQuery = require("../queries/comments.query.graphql");
|
52
56
|
|
53
57
|
const UpVoteButtonWithMutation = graphql(upVoteMutation, {
|
54
|
-
props: ({ ownProps, mutate }) => ({
|
58
|
+
props: ({ ownProps, mutate }: { ownProps: UpVoteButtonProps, mutate: MutationFunc<UpVoteMutation> }) => ({
|
55
59
|
upVote: () => mutate({
|
56
60
|
variables: {
|
57
61
|
id: ownProps.comment.id,
|
@@ -68,28 +72,39 @@ const UpVoteButtonWithMutation = graphql(upVoteMutation, {
|
|
68
72
|
},
|
69
73
|
},
|
70
74
|
},
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
update: (store, result: UpVoteMutation) => {
|
76
|
+
const variables = {
|
77
|
+
commentableId: ownProps.rootCommentable.id,
|
78
|
+
commentableType: ownProps.rootCommentable.type,
|
79
|
+
orderBy: ownProps.orderBy,
|
80
|
+
};
|
75
81
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
};
|
83
|
-
};
|
82
|
+
const commentReducer = (comment: CommentFragment): CommentFragment => {
|
83
|
+
const replies = comment.comments || [];
|
84
|
+
|
85
|
+
if (comment.id === ownProps.comment.id && result.comment) {
|
86
|
+
return result.comment.upVote;
|
87
|
+
}
|
84
88
|
|
85
89
|
return {
|
90
|
+
...comment,
|
91
|
+
comments: replies.map(commentReducer),
|
92
|
+
};
|
93
|
+
};
|
94
|
+
|
95
|
+
const prev = store.readQuery<GetCommentsQuery>({ query: getCommentsQuery, variables });
|
96
|
+
|
97
|
+
store.writeQuery({
|
98
|
+
query: getCommentsQuery,
|
99
|
+
data: {
|
86
100
|
...prev,
|
87
101
|
commentable: {
|
88
102
|
...prev.commentable,
|
89
103
|
comments: prev.commentable.comments.map(commentReducer),
|
90
104
|
},
|
91
|
-
}
|
92
|
-
|
105
|
+
},
|
106
|
+
variables,
|
107
|
+
});
|
93
108
|
},
|
94
109
|
}),
|
95
110
|
}),
|
@@ -9,26 +9,28 @@ module Decidim
|
|
9
9
|
|
10
10
|
helper_method :commentable_title
|
11
11
|
|
12
|
-
def comment_created(comment, commentable)
|
13
|
-
with_user(
|
12
|
+
def comment_created(user, comment, commentable)
|
13
|
+
with_user(user) do
|
14
|
+
@user = user
|
14
15
|
@comment = comment
|
15
16
|
@commentable = commentable
|
16
17
|
@locator = Decidim::ResourceLocatorPresenter.new(@commentable)
|
17
18
|
@organization = commentable.organization
|
18
19
|
subject = I18n.t("comment_created.subject", scope: "decidim.comments.mailer.comment_notification")
|
19
|
-
mail(to:
|
20
|
+
mail(to: user.email, subject: subject)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
def reply_created(reply, comment, commentable)
|
24
|
-
with_user(
|
24
|
+
def reply_created(user, reply, comment, commentable)
|
25
|
+
with_user(user) do
|
26
|
+
@user = user
|
25
27
|
@reply = reply
|
26
28
|
@comment = comment
|
27
29
|
@commentable = commentable
|
28
30
|
@locator = Decidim::ResourceLocatorPresenter.new(@commentable)
|
29
31
|
@organization = commentable.organization
|
30
32
|
subject = I18n.t("reply_created.subject", scope: "decidim.comments.mailer.comment_notification")
|
31
|
-
mail(to:
|
33
|
+
mail(to: user.email, subject: subject)
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -6,7 +6,7 @@ module Decidim
|
|
6
6
|
# comment on them. The will be able to create conversations between users
|
7
7
|
# to discuss or share their thoughts about the resource.
|
8
8
|
class Comment < ApplicationRecord
|
9
|
-
include Reportable
|
9
|
+
include Decidim::Reportable
|
10
10
|
include Decidim::Authorable
|
11
11
|
include Decidim::Comments::Commentable
|
12
12
|
|
@@ -59,6 +59,18 @@ module Decidim
|
|
59
59
|
ResourceLocatorPresenter.new(root_commentable).url(anchor: "comment_#{id}")
|
60
60
|
end
|
61
61
|
|
62
|
+
# Public: Overrides the `notifiable?` Notifiable concern method.
|
63
|
+
# When a comment is commented the comment's author is notified if it is not the same
|
64
|
+
# who has replied the comment and if the comment's author has replied notifiations enabled.
|
65
|
+
def notifiable?(context)
|
66
|
+
context[:author] != author && author.replies_notifications?
|
67
|
+
end
|
68
|
+
|
69
|
+
# Public: Overrides the `users_to_notify` Notifiable concern method.
|
70
|
+
def users_to_notify
|
71
|
+
[author]
|
72
|
+
end
|
73
|
+
|
62
74
|
private
|
63
75
|
|
64
76
|
# Private: Check if commentable can have comments and if not adds
|
data/config/locales/ca.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/fr.yml
CHANGED
@@ -27,7 +27,7 @@ fr:
|
|
27
27
|
label: Commentaire
|
28
28
|
placeholder: Que pensez-vous de cela?
|
29
29
|
form_error: Le texte est requis et ne peut pas dépasser %{length} caractères.
|
30
|
-
submit:
|
30
|
+
submit: Publier
|
31
31
|
user_group_id:
|
32
32
|
label: Commenter en tant que
|
33
33
|
opinion:
|
@@ -46,7 +46,7 @@ fr:
|
|
46
46
|
details: Commentaires additionnels
|
47
47
|
reasons:
|
48
48
|
does_not_belong: Contient des activités illégales, des menaces suicidaires, des informations personnelles, ou autre chose que vous pensez ne pas être approprié à %{organization_name}.
|
49
|
-
offensive: Contient des propos
|
49
|
+
offensive: Contient des propos racistes, sexistes, des insultes, des attaques personnelles, des menaces de mort, des incitations au suicide ou toute forme de discours de haine.
|
50
50
|
spam: Contient des piège-à-clic (clickbait), des publicités, des escroqueries ou des robots fonctionnant au script (script bots).
|
51
51
|
title: Signaler un problème
|
52
52
|
comment_order_selector:
|
@@ -7,6 +7,7 @@ module Decidim
|
|
7
7
|
# Shared behaviour for commentable models.
|
8
8
|
module Commentable
|
9
9
|
extend ActiveSupport::Concern
|
10
|
+
include Decidim::Notifiable
|
10
11
|
|
11
12
|
included do
|
12
13
|
has_many :comments, as: :commentable, foreign_key: "decidim_commentable_id", foreign_type: "decidim_commentable_type", class_name: "Decidim::Comments::Comment"
|
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.
|
4
|
+
version: 0.4.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-
|
13
|
+
date: 2017-07-12 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.
|
21
|
+
version: 0.4.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.
|
28
|
+
version: 0.4.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.
|
63
|
+
version: 0.4.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.
|
70
|
+
version: 0.4.0
|
71
71
|
description: Pluggable comments system for some components.
|
72
72
|
email:
|
73
73
|
- josepjaume@gmail.com
|