decidim-comments 0.0.5 → 0.0.6
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 +28 -28
- data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
- data/app/commands/decidim/comments/create_comment.rb +9 -1
- data/app/frontend/application/icon.component.jsx +1 -1
- data/app/frontend/comments/add_comment_form.component.jsx +11 -10
- data/app/frontend/comments/add_comment_form.component.test.jsx +5 -5
- data/app/frontend/comments/comment.component.jsx +91 -1
- data/app/frontend/comments/comment.component.test.jsx +18 -0
- data/app/frontend/comments/comment_data.fragment.graphql +2 -0
- data/app/frontend/comments/comment_order_selector.component.jsx +4 -5
- data/app/frontend/comments/comments.query.graphql +1 -0
- data/app/mailers/decidim/comments/comment_notification_mailer.rb +8 -0
- data/app/models/decidim/comments/abilities/admin_user.rb +25 -0
- data/app/models/decidim/comments/abilities/process_admin_user.rb +33 -0
- data/app/models/decidim/comments/comment.rb +7 -1
- data/app/models/decidim/comments/comment_vote.rb +3 -1
- data/app/queries/decidim/comments/sorted_comments.rb +1 -0
- 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 +11 -0
- data/config/locales/en.yml +12 -2
- data/config/locales/es.yml +11 -0
- data/config/locales/eu.yml +38 -1
- data/config/locales/fi.yml +66 -0
- data/lib/decidim/comments.rb +2 -0
- data/lib/decidim/comments/admin.rb +9 -0
- data/lib/decidim/comments/admin_engine.rb +22 -0
- data/lib/decidim/comments/api/comment_type.rb +12 -0
- data/lib/decidim/comments/commentable.rb +0 -2
- data/lib/decidim/comments/engine.rb +1 -0
- data/lib/decidim/comments/test/factories.rb +3 -0
- metadata +13 -14
@@ -16,17 +16,16 @@ class CommentOrderSelector extends Component {
|
|
16
16
|
}
|
17
17
|
}
|
18
18
|
|
19
|
-
componentDidMount() {
|
20
|
-
$(document).foundation();
|
21
|
-
}
|
22
|
-
|
23
19
|
render() {
|
24
20
|
const { orderBy } = this.state;
|
25
21
|
|
26
22
|
return (
|
27
23
|
<div className="order-by__dropdown order-by__dropdown--right">
|
28
24
|
<span className="order-by__text">{ I18n.t("components.comment_order_selector.title") }</span>
|
29
|
-
<ul
|
25
|
+
<ul
|
26
|
+
className="dropdown menu"
|
27
|
+
data-dropdown-menu
|
28
|
+
data-close-on-click-inside="false">
|
30
29
|
<li>
|
31
30
|
<a>{ I18n.t(`components.comment_order_selector.order.${orderBy}`) }</a>
|
32
31
|
<ul className="menu">
|
@@ -6,6 +6,8 @@ module Decidim
|
|
6
6
|
class CommentNotificationMailer < Decidim::ApplicationMailer
|
7
7
|
helper Decidim::ResourceHelper
|
8
8
|
|
9
|
+
helper_method :commentable_title
|
10
|
+
|
9
11
|
def comment_created(user, comment, commentable)
|
10
12
|
with_user(user) do
|
11
13
|
@comment = comment
|
@@ -26,6 +28,12 @@ module Decidim
|
|
26
28
|
mail(to: comment.author.email, subject: subject)
|
27
29
|
end
|
28
30
|
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def commentable_title
|
35
|
+
@commentable.title.kind_of?(Hash) ? @commentable.title[I18n.locale.to_s] : @commentable.title
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Comments
|
4
|
+
module Abilities
|
5
|
+
# Defines the abilities related to comments for a logged in admin user.
|
6
|
+
# Intended to be used with `cancancan`.
|
7
|
+
class AdminUser
|
8
|
+
include CanCan::Ability
|
9
|
+
|
10
|
+
attr_reader :user, :context
|
11
|
+
|
12
|
+
def initialize(user, context)
|
13
|
+
return unless user && user.role?(:admin)
|
14
|
+
|
15
|
+
@user = user
|
16
|
+
@context = context
|
17
|
+
|
18
|
+
can :manage, Comment
|
19
|
+
can :unreport, Comment
|
20
|
+
can :hide, Comment
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Comments
|
4
|
+
module Abilities
|
5
|
+
# Defines the abilities related to comments for a logged in process admin user.
|
6
|
+
# Intended to be used with `cancancan`.
|
7
|
+
class ProcessAdminUser
|
8
|
+
include CanCan::Ability
|
9
|
+
|
10
|
+
attr_reader :user, :context
|
11
|
+
|
12
|
+
def initialize(user, context)
|
13
|
+
return unless user && !user.role?(:admin)
|
14
|
+
|
15
|
+
@user = user
|
16
|
+
@context = context
|
17
|
+
|
18
|
+
can :manage, Comment do |comment|
|
19
|
+
participatory_processes.include?(comment.feature.participatory_process)
|
20
|
+
end
|
21
|
+
can :unreport, Comment
|
22
|
+
can :hide, Comment
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def participatory_processes
|
28
|
+
@participatory_processes ||= Decidim::Admin::ManageableParticipatoryProcessesForUser.for(@user)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -5,6 +5,7 @@ module Decidim
|
|
5
5
|
# comment on them. The will be able to create conversations between users
|
6
6
|
# to discuss or share their thoughts about the resource.
|
7
7
|
class Comment < ApplicationRecord
|
8
|
+
include Reportable
|
8
9
|
include Decidim::Authorable
|
9
10
|
include Decidim::Comments::Commentable
|
10
11
|
|
@@ -28,7 +29,7 @@ module Decidim
|
|
28
29
|
|
29
30
|
before_save :compute_depth
|
30
31
|
|
31
|
-
delegate :organization, to: :commentable
|
32
|
+
delegate :organization, :feature, to: :commentable
|
32
33
|
|
33
34
|
# Public: Override Commentable concern method `accepts_new_comments?`
|
34
35
|
def accepts_new_comments?
|
@@ -55,6 +56,11 @@ module Decidim
|
|
55
56
|
commentable.root_commentable
|
56
57
|
end
|
57
58
|
|
59
|
+
# Public: Overrides the `reported_content` Reportable concern method.
|
60
|
+
def reported_content
|
61
|
+
"<p>#{body}</p>"
|
62
|
+
end
|
63
|
+
|
58
64
|
private
|
59
65
|
|
60
66
|
# Private: Check if commentable can have comments and if not adds
|
@@ -7,7 +7,8 @@ module Decidim
|
|
7
7
|
belongs_to :comment, foreign_key: "decidim_comment_id", class_name: Comment
|
8
8
|
belongs_to :author, foreign_key: "decidim_author_id", class_name: Decidim::User
|
9
9
|
|
10
|
-
validates :comment, uniqueness: { scope: :author }
|
10
|
+
validates :comment, presence: true, uniqueness: { scope: :author }
|
11
|
+
validates :author, presence: true
|
11
12
|
validates :weight, inclusion: { in: [-1, 1] }
|
12
13
|
validate :author_and_comment_same_organization
|
13
14
|
|
@@ -15,6 +16,7 @@ module Decidim
|
|
15
16
|
|
16
17
|
# Private: check if the comment and the author have the same organization
|
17
18
|
def author_and_comment_same_organization
|
19
|
+
return unless author.present? && comment.present?
|
18
20
|
errors.add(:comment, :invalid) unless author.organization == comment.organization
|
19
21
|
end
|
20
22
|
end
|
data/config/locales/ca.yml
CHANGED
@@ -38,6 +38,17 @@ ca:
|
|
38
38
|
against: En contra
|
39
39
|
in_favor: A favor
|
40
40
|
reply: Respondre
|
41
|
+
report:
|
42
|
+
action: Denuncia
|
43
|
+
already_reported: Aquest contingut ja ha estat denunciat i serà revisat per un administrador.
|
44
|
+
close: Tancar
|
45
|
+
description: Aquest contingut no és apropiat?
|
46
|
+
details: Comentaris addicionals
|
47
|
+
reasons:
|
48
|
+
does_not_belong: Conté activitat il·legal, amenaces de suïcidi, informació personal, o qualsevol altra cosa que creguis que no pertany a %{organization_name}.
|
49
|
+
offensive: Conté racisme, sexisme, insults, atacs personals, amenaces de mort, peticions de suïcidi o qualsevol forma de discurs d'odi.
|
50
|
+
spam: Conté "clickbait", publicitat o estafes.
|
51
|
+
title: Denuncia un problema
|
41
52
|
comment_order_selector:
|
42
53
|
order:
|
43
54
|
best_rated: Més ben valorats
|
data/config/locales/en.yml
CHANGED
@@ -22,8 +22,7 @@ en:
|
|
22
22
|
subject: You have a new reply of your comment
|
23
23
|
components:
|
24
24
|
add_comment_form:
|
25
|
-
account_message:
|
26
|
-
"
|
25
|
+
account_message: '<a href="%{sign_in_url}">Sign in with your account</a> or <a href="%{sign_up_url}">sign up</a> to add your comment. '
|
27
26
|
form:
|
28
27
|
body:
|
29
28
|
label: Comment
|
@@ -40,6 +39,17 @@ en:
|
|
40
39
|
against: Against
|
41
40
|
in_favor: In favor
|
42
41
|
reply: Reply
|
42
|
+
report:
|
43
|
+
action: Report
|
44
|
+
already_reported: This content is already reported and it will be reviewed by an admin.
|
45
|
+
close: Close
|
46
|
+
description: Is this content inappropriate?
|
47
|
+
details: Additional comments
|
48
|
+
reasons:
|
49
|
+
does_not_belong: Contains illegal activity, suicide threats, personal information, or something else you think doesn't belong on %{organization_name}.
|
50
|
+
offensive: Contains racism, sexism, slurs, personal attacks, death threats, suicide requests or any form of hate speech.
|
51
|
+
spam: Contains clickbait, advertising, scams or script bots.
|
52
|
+
title: Report a problem
|
43
53
|
comment_order_selector:
|
44
54
|
order:
|
45
55
|
best_rated: Best rated
|
data/config/locales/es.yml
CHANGED
@@ -38,6 +38,17 @@ es:
|
|
38
38
|
against: En contra
|
39
39
|
in_favor: A favor
|
40
40
|
reply: Respuesta
|
41
|
+
report:
|
42
|
+
action: Denunciar
|
43
|
+
already_reported: Este contenido ya fue denunciado y será revisado por un administrador.
|
44
|
+
close: Cerrar
|
45
|
+
description: '¿Es inapropiado este contenido?'
|
46
|
+
details: Comentarios adicionales
|
47
|
+
reasons:
|
48
|
+
does_not_belong: Contiene actividad ilegal, amenazas de suicidio, información personal o cualquier otra cosa que usted piense que no pertenece en %{organization_name}.
|
49
|
+
offensive: Contiene racismo, sexismo, insultos, ataques personales, amenazas de muerte, solicitudes de suicidio o cualquier forma de discurso de odio.
|
50
|
+
spam: Contiene clickbait, publicidad o estafas.
|
51
|
+
title: Denunciar un problema
|
41
52
|
comment_order_selector:
|
42
53
|
order:
|
43
54
|
best_rated: Mejor valoración
|
data/config/locales/eu.yml
CHANGED
@@ -2,4 +2,41 @@ eu:
|
|
2
2
|
decidim:
|
3
3
|
comments:
|
4
4
|
comment_notification_mailer:
|
5
|
-
hello: Kaixo %{name},
|
5
|
+
hello: Kaixo, %{name},
|
6
|
+
notifications_settings_link: jakinarazpenen konfigurazio-orria
|
7
|
+
mailer:
|
8
|
+
comment_notification:
|
9
|
+
comment_created:
|
10
|
+
subject: Iruzkin berri bat duzu
|
11
|
+
reply_created:
|
12
|
+
subject: Zure iruzkinetako bati erantzuna eman diote
|
13
|
+
components:
|
14
|
+
add_comment_form:
|
15
|
+
form:
|
16
|
+
body:
|
17
|
+
label: Iruzkina
|
18
|
+
placeholder: Zer deritzozu honi?
|
19
|
+
form_error: Testua behar da, eta ezin du izan %{length} karaktere baino gehiago.
|
20
|
+
submit: Bidali
|
21
|
+
user_group_id:
|
22
|
+
label: 'Iruzkindu honela:'
|
23
|
+
opinion:
|
24
|
+
neutral: Neutrala
|
25
|
+
title: Jarri hemen zure iruzkina
|
26
|
+
comment:
|
27
|
+
alignment:
|
28
|
+
against: Aurka
|
29
|
+
in_favor: Alde
|
30
|
+
reply: Erantzuna
|
31
|
+
comment_order_selector:
|
32
|
+
order:
|
33
|
+
best_rated: Balorazio hoberena
|
34
|
+
most_discussed: Eztabaidatuenak
|
35
|
+
older: Zaharrena
|
36
|
+
recent: Berri-berria
|
37
|
+
title: 'Ordenatu honen arabera:'
|
38
|
+
comments:
|
39
|
+
loading: Iruzkinak kargatzen...
|
40
|
+
title: "%{count} iruzkin"
|
41
|
+
featured_comment:
|
42
|
+
title: Iruzkin nabarmendua
|
@@ -0,0 +1,66 @@
|
|
1
|
+
fi:
|
2
|
+
activerecord:
|
3
|
+
errors:
|
4
|
+
messages:
|
5
|
+
cannot_have_comments: ei voi poistaa kommentteja
|
6
|
+
decidim:
|
7
|
+
comments:
|
8
|
+
comment_notification_mailer:
|
9
|
+
comment_created:
|
10
|
+
new_comment_html: Uusi kommentti henkilöltä <b>%{commenter}</b> osoitteessa <b>%{commentable_link}</b>
|
11
|
+
hello: Hei %{name},
|
12
|
+
manage_email_subscriptions_html: 'Voit lopettaa näiden viestien vastaanottamisen vaihtamalla asetuksiasi osoitteessa: %{link}.'
|
13
|
+
notifications_settings_link: ilmoitusten asetussivu
|
14
|
+
reply_created:
|
15
|
+
new_reply_html: Henkilö <b>%{commenter}</b> on vastannut kommenttiisi osoitteessa <b>%{commentable_link}</b>
|
16
|
+
mailer:
|
17
|
+
comment_notification:
|
18
|
+
comment_created:
|
19
|
+
subject: Sinulla on uusi kommentti
|
20
|
+
reply_created:
|
21
|
+
subject: Kommenttiisi on vastattu
|
22
|
+
components:
|
23
|
+
add_comment_form:
|
24
|
+
account_message: "<a href=\"%{sign_in_url}\">Kirjaudu sisään käyttäjätililläsi</a> tai <a href=\"%{sign_up_url}\">luo käyttäjätili</a> kommentoidaksesi.\n"
|
25
|
+
form:
|
26
|
+
body:
|
27
|
+
label: Kommentti
|
28
|
+
placeholder: Mitä mieltä olet tästä?
|
29
|
+
form_error: Teksti vaaditaan ja se ei voi olla pidempi kuin %{length} merkkiä.
|
30
|
+
submit: Lähetä
|
31
|
+
user_group_id:
|
32
|
+
label: Kommentoi käyttäjänä
|
33
|
+
opinion:
|
34
|
+
neutral: Neutraali
|
35
|
+
title: Lisää kommenttisi
|
36
|
+
comment:
|
37
|
+
alignment:
|
38
|
+
against: Vastaan
|
39
|
+
in_favor: Puolesta
|
40
|
+
reply: Vastaa
|
41
|
+
report:
|
42
|
+
action: Raportoi
|
43
|
+
already_reported: Tämä sisältö on jo raportoitu ja ylläpitäjä tutkii sen.
|
44
|
+
close: Sulje
|
45
|
+
description: Onko tämä sisältö epäasiallista?
|
46
|
+
details: Lisätiedot
|
47
|
+
reasons:
|
48
|
+
does_not_belong: Sisältää laitonta toimintaa, itsemurhauhkailua, henkilökohtaisia tietoja tai jotain muuta, jonka et usko kuuluvan organisaatioon %{organization_name}.
|
49
|
+
offensive: Sisältää rasismia, seksismiä, haukkumista, henkilökohtaisia hyökkäyksiä, tappouhkauksia, itsemurhapyyntöjä tai muuta vihapuhetta.
|
50
|
+
spam: Sisältää klikkihoukutteita, mainostusta, huijauksia tai bottiskriptejä.
|
51
|
+
title: Raportoi ongelmasta
|
52
|
+
comment_order_selector:
|
53
|
+
order:
|
54
|
+
best_rated: Parhaiksi arvioidut
|
55
|
+
most_discussed: Eniten keskustelua herättäneet
|
56
|
+
older: Vanhemmat
|
57
|
+
recent: Uusimmat
|
58
|
+
title: 'Järjestä tulokset:'
|
59
|
+
comment_thread:
|
60
|
+
title: Keskustelu henkilön %{authorName} kanssa
|
61
|
+
comments:
|
62
|
+
blocked_comments_warning: Kommentointi on estetty tämänhetkisessä vaiheessa, mutta voit lukea kommentteja aikaisemmista vaiheista.
|
63
|
+
loading: Ladataan kommentteja ...
|
64
|
+
title: "%{count} kommenttia"
|
65
|
+
featured_comment:
|
66
|
+
title: Esille nostettu kommentti
|
data/lib/decidim/comments.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Decidim
|
3
|
+
module Comments
|
4
|
+
# This is the engine that runs on the public interface of `decidim-comments`.
|
5
|
+
class AdminEngine < ::Rails::Engine
|
6
|
+
isolate_namespace Decidim::Comments::Admin
|
7
|
+
|
8
|
+
paths["db/migrate"] = nil
|
9
|
+
|
10
|
+
initializer "decidim_comments.inject_abilities_to_user" do |_app|
|
11
|
+
Decidim.configure do |config|
|
12
|
+
config.admin_abilities += ["Decidim::Comments::Abilities::AdminUser"]
|
13
|
+
config.admin_abilities += ["Decidim::Comments::Abilities::ProcessAdminUser"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_seed
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -12,6 +12,12 @@ module Decidim
|
|
12
12
|
|
13
13
|
field :id, !types.ID, "The Comment's unique ID"
|
14
14
|
|
15
|
+
field :sgid, !types.String, "The Comment's signed global id" do
|
16
|
+
resolve lambda { |obj, _args, _ctx|
|
17
|
+
obj.to_sgid.to_s
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
15
21
|
field :body, !types.String, "The comment message"
|
16
22
|
|
17
23
|
field :createdAt, !types.String, "The creation date of the comment" do
|
@@ -57,6 +63,12 @@ module Decidim
|
|
57
63
|
obj.accepts_new_comments? && obj.comments.size.positive?
|
58
64
|
}
|
59
65
|
end
|
66
|
+
|
67
|
+
field :alreadyReported, !types.Boolean, "Check if the current user has reported the comment" do
|
68
|
+
resolve lambda { |obj, _args, ctx|
|
69
|
+
obj.reported_by?(ctx[:current_user])
|
70
|
+
}
|
71
|
+
end
|
60
72
|
end
|
61
73
|
end
|
62
74
|
end
|
@@ -9,8 +9,6 @@ module Decidim
|
|
9
9
|
extend ActiveSupport::Concern
|
10
10
|
|
11
11
|
included do
|
12
|
-
include Decidim::Authorable
|
13
|
-
|
14
12
|
has_many :comments, as: :commentable, foreign_key: "decidim_commentable_id", foreign_type: "decidim_commentable_type", class_name: "Decidim::Comments::Comment"
|
15
13
|
|
16
14
|
# Public: Wether the object's comments are visible or not.
|