decidim-comments 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -5
- data/app/assets/javascripts/decidim/comments/bundle.js +1 -540
- data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
- data/app/frontend/application/apollo_client.ts +3 -11
- data/app/frontend/application/application.component.test.tsx +1 -1
- data/app/frontend/application/icon.component.test.tsx +15 -26
- data/app/frontend/application/icon.component.tsx +10 -11
- data/app/frontend/comments/add_comment_form.component.test.tsx +13 -13
- data/app/frontend/comments/add_comment_form.component.tsx +25 -25
- data/app/frontend/comments/comment.component.test.tsx +236 -35
- data/app/frontend/comments/comment.component.tsx +5 -5
- data/app/frontend/comments/comment_order_selector.component.test.tsx +1 -1
- data/app/frontend/comments/comment_order_selector.component.tsx +1 -1
- data/app/frontend/comments/comment_thread.component.test.tsx +2 -2
- data/app/frontend/comments/comment_thread.component.tsx +2 -2
- data/app/frontend/comments/comments.component.test.tsx +5 -5
- data/app/frontend/comments/comments.component.tsx +7 -7
- data/app/frontend/comments/down_vote_button.component.test.tsx +2 -2
- data/app/frontend/comments/down_vote_button.component.tsx +14 -14
- data/app/frontend/comments/up_vote_button.component.test.tsx +2 -2
- data/app/frontend/comments/up_vote_button.component.tsx +14 -14
- data/app/frontend/comments/vote_button.component.tsx +2 -2
- data/app/frontend/entry.ts +1 -1
- data/app/frontend/support/generate_comments_data.ts +2 -2
- data/app/frontend/support/generate_user_data.ts +1 -1
- data/app/frontend/support/generate_user_group_data.ts +1 -1
- data/app/frontend/support/resolve_graphql_query.ts +1 -1
- data/app/types/decidim/comments/commentable_mutation_type.rb +1 -1
- data/config/locales/uk.yml +18 -0
- data/lib/decidim/comments/api/comment_type.rb +1 -1
- data/lib/decidim/comments/engine.rb +6 -2
- data/lib/decidim/comments/mutation_extensions.rb +15 -17
- data/lib/decidim/comments/query_extensions.rb +8 -10
- data/lib/decidim/comments/version.rb +1 -1
- metadata +9 -9
@@ -10,7 +10,7 @@ import UpVoteButton from "./up_vote_button.component";
|
|
10
10
|
import {
|
11
11
|
AddCommentFormCommentableFragment,
|
12
12
|
AddCommentFormSessionFragment,
|
13
|
-
CommentFragment
|
13
|
+
CommentFragment
|
14
14
|
} from "../support/schema";
|
15
15
|
|
16
16
|
const { I18n } = require("react-i18nify");
|
@@ -41,7 +41,7 @@ class Comment extends React.Component<CommentProps, CommentState> {
|
|
41
41
|
articleClassName: "comment",
|
42
42
|
isRootComment: false,
|
43
43
|
session: null,
|
44
|
-
votable: false
|
44
|
+
votable: false
|
45
45
|
};
|
46
46
|
|
47
47
|
public commentNode: HTMLElement;
|
@@ -50,7 +50,7 @@ class Comment extends React.Component<CommentProps, CommentState> {
|
|
50
50
|
super(props);
|
51
51
|
|
52
52
|
this.state = {
|
53
|
-
showReplyForm: false
|
53
|
+
showReplyForm: false
|
54
54
|
};
|
55
55
|
}
|
56
56
|
|
@@ -349,7 +349,7 @@ class Comment extends React.Component<CommentProps, CommentState> {
|
|
349
349
|
const { comment: { alignment } } = this.props;
|
350
350
|
const spanClassName = classnames("label alignment", {
|
351
351
|
success: alignment === 1,
|
352
|
-
alert: alignment === -1
|
352
|
+
alert: alignment === -1
|
353
353
|
});
|
354
354
|
|
355
355
|
let label = "";
|
@@ -429,7 +429,7 @@ class Comment extends React.Component<CommentProps, CommentState> {
|
|
429
429
|
</label>
|
430
430
|
<button type="submit" name="commit" className="button">{I18n.t("components.comment.report.action")}</button>
|
431
431
|
</form>
|
432
|
-
)
|
432
|
+
)
|
433
433
|
];
|
434
434
|
})()
|
435
435
|
}
|
@@ -13,7 +13,7 @@ describe("<CommentThread />", () => {
|
|
13
13
|
const orderBy = "older";
|
14
14
|
const rootCommentable = {
|
15
15
|
id: "1",
|
16
|
-
type: "Decidim::DummyResources::DummyResource"
|
16
|
+
type: "Decidim::DummyResources::DummyResource"
|
17
17
|
};
|
18
18
|
let comment: CommentFragment;
|
19
19
|
let session: any = null;
|
@@ -23,7 +23,7 @@ describe("<CommentThread />", () => {
|
|
23
23
|
const commentsData = generateCommentsData(1);
|
24
24
|
|
25
25
|
session = {
|
26
|
-
user: generateCUserData()
|
26
|
+
user: generateCUserData()
|
27
27
|
};
|
28
28
|
comment = commentsData[0];
|
29
29
|
});
|
@@ -5,7 +5,7 @@ import Comment from "./comment.component";
|
|
5
5
|
import {
|
6
6
|
AddCommentFormCommentableFragment,
|
7
7
|
AddCommentFormSessionFragment,
|
8
|
-
CommentFragment
|
8
|
+
CommentFragment
|
9
9
|
} from "../support/schema";
|
10
10
|
|
11
11
|
const { I18n } = require("react-i18nify");
|
@@ -29,7 +29,7 @@ interface CommentThreadProps {
|
|
29
29
|
class CommentThread extends React.Component<CommentThreadProps> {
|
30
30
|
public static defaultProps: any = {
|
31
31
|
session: null,
|
32
|
-
votable: false
|
32
|
+
votable: false
|
33
33
|
};
|
34
34
|
|
35
35
|
public render() {
|
@@ -29,21 +29,21 @@ describe("<Comments />", () => {
|
|
29
29
|
filterResult: false,
|
30
30
|
rootValue: {
|
31
31
|
session: {
|
32
|
-
user: userData
|
32
|
+
user: userData
|
33
33
|
},
|
34
34
|
commentable: {
|
35
35
|
acceptsNewComments: true,
|
36
36
|
commentsHaveAlignment: true,
|
37
37
|
commentsHaveVotes: true,
|
38
38
|
totalCommentsCount: 15,
|
39
|
-
comments: commentsData
|
40
|
-
}
|
39
|
+
comments: commentsData
|
40
|
+
}
|
41
41
|
},
|
42
42
|
variables: {
|
43
43
|
orderBy,
|
44
44
|
commentableId,
|
45
|
-
commentableType
|
46
|
-
}
|
45
|
+
commentableType
|
46
|
+
}
|
47
47
|
});
|
48
48
|
|
49
49
|
session = result.session;
|
@@ -9,7 +9,7 @@ import CommentThread from "./comment_thread.component";
|
|
9
9
|
|
10
10
|
import {
|
11
11
|
GetCommentsQuery,
|
12
|
-
GetCommentsQueryVariables
|
12
|
+
GetCommentsQueryVariables
|
13
13
|
} from "../support/schema";
|
14
14
|
|
15
15
|
const { I18n } = require("react-i18nify");
|
@@ -32,8 +32,8 @@ export class Comments extends React.Component<CommentsProps> {
|
|
32
32
|
loading: false,
|
33
33
|
session: null,
|
34
34
|
commentable: {
|
35
|
-
comments: []
|
36
|
-
}
|
35
|
+
comments: []
|
36
|
+
}
|
37
37
|
};
|
38
38
|
|
39
39
|
public render() {
|
@@ -142,7 +142,7 @@ export const commentsQuery = require("../queries/comments.query.graphql");
|
|
142
142
|
|
143
143
|
const CommentsWithData: any = graphql<GetCommentsQuery, CommentsProps>(commentsQuery, {
|
144
144
|
options: {
|
145
|
-
pollInterval: 15000
|
145
|
+
pollInterval: 15000
|
146
146
|
},
|
147
147
|
props: ({ ownProps, data }) => {
|
148
148
|
if (data) {
|
@@ -155,12 +155,12 @@ const CommentsWithData: any = graphql<GetCommentsQuery, CommentsProps>(commentsQ
|
|
155
155
|
orderBy: ownProps.orderBy,
|
156
156
|
reorderComments: (orderBy: string) => {
|
157
157
|
return refetch({
|
158
|
-
orderBy
|
158
|
+
orderBy
|
159
159
|
});
|
160
|
-
}
|
160
|
+
}
|
161
161
|
};
|
162
162
|
}
|
163
|
-
}
|
163
|
+
}
|
164
164
|
})(Comments);
|
165
165
|
|
166
166
|
export interface CommentsApplicationProps extends GetCommentsQueryVariables {
|
@@ -13,7 +13,7 @@ describe("<DownVoteButton />", () => {
|
|
13
13
|
const orderBy = "older";
|
14
14
|
const rootCommentable = {
|
15
15
|
id: "1",
|
16
|
-
type: "Decidim::DummyResources::DummyResource"
|
16
|
+
type: "Decidim::DummyResources::DummyResource"
|
17
17
|
};
|
18
18
|
let comment: DownVoteButtonFragment;
|
19
19
|
let session: any = null;
|
@@ -22,7 +22,7 @@ describe("<DownVoteButton />", () => {
|
|
22
22
|
beforeEach(() => {
|
23
23
|
const commentsData = generateCommentsData(1);
|
24
24
|
session = {
|
25
|
-
user: generateUserData()
|
25
|
+
user: generateUserData()
|
26
26
|
};
|
27
27
|
comment = commentsData[0];
|
28
28
|
});
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
CommentFragment,
|
10
10
|
DownVoteButtonFragment,
|
11
11
|
DownVoteMutation,
|
12
|
-
GetCommentsQuery
|
12
|
+
GetCommentsQuery
|
13
13
|
} from "../support/schema";
|
14
14
|
|
15
15
|
interface DownVoteButtonProps {
|
@@ -25,7 +25,7 @@ interface DownVoteButtonProps {
|
|
25
25
|
export const DownVoteButton: React.SFC<DownVoteButtonProps> = ({
|
26
26
|
session,
|
27
27
|
comment: { downVotes, upVoted, downVoted },
|
28
|
-
downVote
|
28
|
+
downVote
|
29
29
|
}) => {
|
30
30
|
let selectedClass = "";
|
31
31
|
|
@@ -58,7 +58,7 @@ const DownVoteButtonWithMutation = graphql<DownVoteMutation, DownVoteButtonProps
|
|
58
58
|
props: ({ ownProps, mutate }: { ownProps: DownVoteButtonProps, mutate: MutationFunc<DownVoteMutation> }) => ({
|
59
59
|
downVote: () => mutate({
|
60
60
|
variables: {
|
61
|
-
id: ownProps.comment.id
|
61
|
+
id: ownProps.comment.id
|
62
62
|
},
|
63
63
|
optimisticResponse: {
|
64
64
|
__typename: "Mutation",
|
@@ -68,15 +68,15 @@ const DownVoteButtonWithMutation = graphql<DownVoteMutation, DownVoteButtonProps
|
|
68
68
|
__typename: "Comment",
|
69
69
|
...ownProps.comment,
|
70
70
|
downVotes: ownProps.comment.downVotes + 1,
|
71
|
-
downVoted: true
|
72
|
-
}
|
73
|
-
}
|
71
|
+
downVoted: true
|
72
|
+
}
|
73
|
+
}
|
74
74
|
},
|
75
75
|
update: (store, { data }: { data: DownVoteMutation }) => {
|
76
76
|
const variables = {
|
77
77
|
commentableId: ownProps.rootCommentable.id,
|
78
78
|
commentableType: ownProps.rootCommentable.type,
|
79
|
-
orderBy: ownProps.orderBy
|
79
|
+
orderBy: ownProps.orderBy
|
80
80
|
};
|
81
81
|
|
82
82
|
const commentReducer = (comment: CommentFragment): CommentFragment => {
|
@@ -88,7 +88,7 @@ const DownVoteButtonWithMutation = graphql<DownVoteMutation, DownVoteButtonProps
|
|
88
88
|
|
89
89
|
return {
|
90
90
|
...comment,
|
91
|
-
comments: replies.map(commentReducer)
|
91
|
+
comments: replies.map(commentReducer)
|
92
92
|
};
|
93
93
|
};
|
94
94
|
|
@@ -101,15 +101,15 @@ const DownVoteButtonWithMutation = graphql<DownVoteMutation, DownVoteButtonProps
|
|
101
101
|
...prev,
|
102
102
|
commentable: {
|
103
103
|
...prev.commentable,
|
104
|
-
comments: prev.commentable.comments.map(commentReducer)
|
105
|
-
}
|
104
|
+
comments: prev.commentable.comments.map(commentReducer)
|
105
|
+
}
|
106
106
|
},
|
107
|
-
variables
|
107
|
+
variables
|
108
108
|
});
|
109
109
|
}
|
110
|
-
}
|
111
|
-
})
|
112
|
-
})
|
110
|
+
}
|
111
|
+
})
|
112
|
+
})
|
113
113
|
})(DownVoteButton);
|
114
114
|
|
115
115
|
export default DownVoteButtonWithMutation;
|
@@ -13,7 +13,7 @@ describe("<UpVoteButton />", () => {
|
|
13
13
|
const orderBy = "older";
|
14
14
|
const rootCommentable = {
|
15
15
|
id: "1",
|
16
|
-
type: "Decidim::DummyResources::DummyResource"
|
16
|
+
type: "Decidim::DummyResources::DummyResource"
|
17
17
|
};
|
18
18
|
let comment: UpVoteButtonFragment;
|
19
19
|
let session: any = null;
|
@@ -22,7 +22,7 @@ describe("<UpVoteButton />", () => {
|
|
22
22
|
beforeEach(() => {
|
23
23
|
const commentsData = generateCommentsData(1);
|
24
24
|
session = {
|
25
|
-
user: generateUserData()
|
25
|
+
user: generateUserData()
|
26
26
|
};
|
27
27
|
comment = commentsData[0];
|
28
28
|
});
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
CommentFragment,
|
10
10
|
GetCommentsQuery,
|
11
11
|
UpVoteButtonFragment,
|
12
|
-
UpVoteMutation
|
12
|
+
UpVoteMutation
|
13
13
|
} from "../support/schema";
|
14
14
|
|
15
15
|
interface UpVoteButtonProps {
|
@@ -25,7 +25,7 @@ interface UpVoteButtonProps {
|
|
25
25
|
export const UpVoteButton: React.SFC<UpVoteButtonProps> = ({
|
26
26
|
session,
|
27
27
|
comment: { upVotes, upVoted, downVoted },
|
28
|
-
upVote
|
28
|
+
upVote
|
29
29
|
}) => {
|
30
30
|
let selectedClass = "";
|
31
31
|
|
@@ -58,7 +58,7 @@ const UpVoteButtonWithMutation = graphql<UpVoteMutation, UpVoteButtonProps>(upVo
|
|
58
58
|
props: ({ ownProps, mutate }: { ownProps: UpVoteButtonProps, mutate: MutationFunc<UpVoteMutation> }) => ({
|
59
59
|
upVote: () => mutate({
|
60
60
|
variables: {
|
61
|
-
id: ownProps.comment.id
|
61
|
+
id: ownProps.comment.id
|
62
62
|
},
|
63
63
|
optimisticResponse: {
|
64
64
|
__typename: "Mutation",
|
@@ -68,15 +68,15 @@ const UpVoteButtonWithMutation = graphql<UpVoteMutation, UpVoteButtonProps>(upVo
|
|
68
68
|
__typename: "Comment",
|
69
69
|
...ownProps.comment,
|
70
70
|
upVotes: ownProps.comment.upVotes + 1,
|
71
|
-
upVoted: true
|
72
|
-
}
|
73
|
-
}
|
71
|
+
upVoted: true
|
72
|
+
}
|
73
|
+
}
|
74
74
|
},
|
75
75
|
update: (store, { data }: { data: UpVoteMutation }) => {
|
76
76
|
const variables = {
|
77
77
|
commentableId: ownProps.rootCommentable.id,
|
78
78
|
commentableType: ownProps.rootCommentable.type,
|
79
|
-
orderBy: ownProps.orderBy
|
79
|
+
orderBy: ownProps.orderBy
|
80
80
|
};
|
81
81
|
|
82
82
|
const commentReducer = (comment: CommentFragment): CommentFragment => {
|
@@ -88,7 +88,7 @@ const UpVoteButtonWithMutation = graphql<UpVoteMutation, UpVoteButtonProps>(upVo
|
|
88
88
|
|
89
89
|
return {
|
90
90
|
...comment,
|
91
|
-
comments: replies.map(commentReducer)
|
91
|
+
comments: replies.map(commentReducer)
|
92
92
|
};
|
93
93
|
};
|
94
94
|
|
@@ -101,15 +101,15 @@ const UpVoteButtonWithMutation = graphql<UpVoteMutation, UpVoteButtonProps>(upVo
|
|
101
101
|
...prev,
|
102
102
|
commentable: {
|
103
103
|
...prev.commentable,
|
104
|
-
comments: prev.commentable.comments.map(commentReducer)
|
105
|
-
}
|
104
|
+
comments: prev.commentable.comments.map(commentReducer)
|
105
|
+
}
|
106
106
|
},
|
107
|
-
variables
|
107
|
+
variables
|
108
108
|
});
|
109
109
|
}
|
110
|
-
}
|
111
|
-
})
|
112
|
-
})
|
110
|
+
}
|
111
|
+
})
|
112
|
+
})
|
113
113
|
})(UpVoteButton);
|
114
114
|
|
115
115
|
export default UpVoteButtonWithMutation;
|
@@ -22,7 +22,7 @@ const VoteButton: React.SFC<VoteButtonProps> = ({
|
|
22
22
|
voteAction,
|
23
23
|
disabled,
|
24
24
|
selectedClass,
|
25
|
-
userLoggedIn
|
25
|
+
userLoggedIn
|
26
26
|
}) => (
|
27
27
|
<button
|
28
28
|
className={`${buttonClassName} ${selectedClass}`}
|
@@ -40,7 +40,7 @@ VoteButton.defaultProps = {
|
|
40
40
|
iconName: "",
|
41
41
|
votes: 0,
|
42
42
|
selectedClass: "selected",
|
43
|
-
disabled: false
|
43
|
+
disabled: false
|
44
44
|
};
|
45
45
|
|
46
46
|
export default VoteButton;
|
data/app/frontend/entry.ts
CHANGED
@@ -27,7 +27,7 @@ const generateCommentsData = (num = 1) => {
|
|
27
27
|
avatarUrl: image.imageUrl(),
|
28
28
|
profilePath: `/profiles/${nickname}`,
|
29
29
|
deleted: false,
|
30
|
-
badge: "verified-badge"
|
30
|
+
badge: "verified-badge"
|
31
31
|
},
|
32
32
|
hasComments: false,
|
33
33
|
comments: [],
|
@@ -38,7 +38,7 @@ const generateCommentsData = (num = 1) => {
|
|
38
38
|
downVotes: random.number(),
|
39
39
|
downVoted: false,
|
40
40
|
sgid: random.uuid(),
|
41
|
-
alreadyReported: false
|
41
|
+
alreadyReported: false
|
42
42
|
});
|
43
43
|
}
|
44
44
|
|
@@ -17,7 +17,7 @@ module Decidim
|
|
17
17
|
|
18
18
|
resolve lambda { |obj, args, ctx|
|
19
19
|
params = { "comment" => { "body" => args[:body], "alignment" => args[:alignment], "user_group_id" => args[:userGroupId] } }
|
20
|
-
form = Decidim::Comments::CommentForm.from_params(params)
|
20
|
+
form = Decidim::Comments::CommentForm.from_params(params).with_context(current_organization: ctx[:current_organization])
|
21
21
|
Decidim::Comments::CreateComment.call(form, ctx[:current_user], obj) do
|
22
22
|
on(:ok) do |comment|
|
23
23
|
return comment
|
data/config/locales/uk.yml
CHANGED
@@ -52,6 +52,24 @@ uk:
|
|
52
52
|
title: "%{count} коментарів"
|
53
53
|
featured_comment:
|
54
54
|
title: Рекомендований коментар
|
55
|
+
events:
|
56
|
+
comments:
|
57
|
+
comment_created:
|
58
|
+
comment:
|
59
|
+
email_intro: '"%{resource_title}" прокоментували. Ви можете прочитати коментар на цій сторінці:'
|
60
|
+
email_outro: Ви отримали це сповіщення, тому що ви стежите за "%{resource_title}". Ви можете припинити стежити за ним, перейшовши за наведеним вище посиланням.
|
61
|
+
email_subject: Надійшов новий коментар від %{author_name} на %{resource_title}
|
62
|
+
notification_title: Надійшов новий коментар від <a href="%{author_path}">%{author_name} %{author_nickname}</a> на <a href="%{resource_path}">%{resource_title}</a>
|
63
|
+
reply:
|
64
|
+
email_intro: '"%{resource_title}" прокоментували'
|
65
|
+
email_outro: Ви отримали це сповіщення, тому що ви стежите за "%{resource_title}" чи його автором. Ви можете припинити стежити за ним, перейшовши за наведеним вище посиланням.
|
66
|
+
email_subject: Надійшла нова відповідь на ваш коментар від %{author_name} на <a href="%{resource_url}">%{resource_title}</a>
|
67
|
+
notification_title: Надійшла нова відповідь на ваш коментар від <a href="%{author_path}">%{author_name} %{author_nickname}</a> на <a href="%{resource_path}">%{resource_title}</a>
|
68
|
+
user_mentioned:
|
69
|
+
email_intro: Вас згадали
|
70
|
+
email_outro: Ви отримали це сповіщення, оскільки вас згадали в "%{resource_title}".
|
71
|
+
email_subject: Вас згадали у %{resource_title}
|
72
|
+
notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> згадав вас у <a href="%{resource_path}">%{resource_title}</a>
|
55
73
|
errors:
|
56
74
|
messages:
|
57
75
|
cannot_have_comments: не підлягає коментуванню
|