decidim-comments 0.27.0 → 0.27.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6c6e52bf2d6fb82ec3a0ef63c1a19166171b0f36b11c50348147eb83df09e2a
4
- data.tar.gz: e1830e662a9498d68f8104382506b74b47a59124ffdf2519fc3de6a4b58753ea
3
+ metadata.gz: 3d694f5d314d6415388541f689f72405dacfae3bb21943ce499b7ac4548dbee3
4
+ data.tar.gz: 4a25dae5aa24bdeaaa86076af801a5210c0dcdace52ef9e4e177be0f17502736
5
5
  SHA512:
6
- metadata.gz: 1d9c728231a9257cd5d2d61757df644fe9297c72c3ecdf6d5a34387ae212876ee2596b1946100ffaaafdd7662ec82bc4aefab408ceca6be36a537995756409ca
7
- data.tar.gz: f874636ccc380e12d2f844c0e4b15a02e60e5f2416ffd20bdaa215965dcea80dc460ecdc3c5cf4aedae8afa93d32f92bf983a6d3e335637507921dd261ad1aa0
6
+ metadata.gz: 84fa5683fe04af6fac1f6d5f808e924905eec1a1acaf8e68171b67822c67ee55f913e2476eefb8e6a04730ce77e09ecc166129c71ee865683df34a37c281e72c
7
+ data.tar.gz: 6a489cd703c56038f592b22342794add4b02ad7fc3e502fd1caa4bdf0382357104f098c7f5a1b9efe32d7d798b444c8d1a27f74e256cac37dd77d5b39ba486ef
@@ -56,8 +56,6 @@ module Decidim
56
56
  validate :body_length
57
57
  validate :commentable_can_have_comments
58
58
 
59
- delegate :organization, to: :commentable
60
-
61
59
  scope :not_deleted, -> { where(deleted_at: nil) }
62
60
 
63
61
  translatable_fields :body
@@ -81,6 +79,10 @@ module Decidim
81
79
  where(alignment: -1)
82
80
  end
83
81
 
82
+ def organization
83
+ commentable&.organization || participatory_space&.organization
84
+ end
85
+
84
86
  def visible?
85
87
  participatory_space.try(:visible?) && component.try(:published?)
86
88
  end
@@ -131,6 +133,8 @@ module Decidim
131
133
 
132
134
  # Public: Overrides the `reported_content_url` Reportable concern method.
133
135
  def reported_content_url
136
+ return unless root_commentable
137
+
134
138
  url_params = { anchor: "comment_#{id}" }
135
139
 
136
140
  if root_commentable.respond_to?(:polymorphic_resource_url)
@@ -43,7 +43,10 @@ export default class CommentsComponent {
43
43
  this.mounted = true;
44
44
  this._initializeComments(this.$element);
45
45
  if (!this.singleComment) {
46
- this._fetchComments();
46
+ $(".add-comment textarea", this.$element).prop("disabled", true);
47
+ this._fetchComments(() => {
48
+ $(".add-comment textarea", this.$element).prop("disabled", false);
49
+ });
47
50
  }
48
51
 
49
52
  $(".order-by__dropdown .is-submenu-item a", this.$element).on("click.decidim-comments", () => this._onInitOrder());
@@ -215,10 +218,11 @@ export default class CommentsComponent {
215
218
  * Sends an ajax request based on current
216
219
  * params to get comments for the component
217
220
  * @private
221
+ * @param {Function} successCallback A callback that is called after a
222
+ * successful fetch
218
223
  * @returns {Void} - Returns nothing
219
224
  */
220
- _fetchComments() {
221
- $(".add-comment textarea", this.$element).prop("disabled", true);
225
+ _fetchComments(successCallback = null) {
222
226
  Rails.ajax({
223
227
  url: this.commentsUrl,
224
228
  type: "GET",
@@ -231,7 +235,9 @@ export default class CommentsComponent {
231
235
  ...(this.lastCommentId && { "after": this.lastCommentId })
232
236
  }),
233
237
  success: () => {
234
- $(".add-comment textarea", this.$element).prop("disabled", false);
238
+ if (successCallback) {
239
+ successCallback();
240
+ }
235
241
  this._pollComments();
236
242
  }
237
243
  });
@@ -418,6 +418,21 @@ describe("CommentsComponent", () => {
418
418
  expect(window.setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 1000);
419
419
  });
420
420
 
421
+ it("does not disable the textarea when polling comments normally", () => {
422
+ Rails.ajax.mockImplementationOnce((options) => options.success());
423
+
424
+ subject.mountComponent();
425
+
426
+ // Delay the success call 2s after the polling has happened to test that
427
+ // the textarea is still enabled when the polling is happening.
428
+ Rails.ajax.mockImplementationOnce((options) => {
429
+ setTimeout(options.success(), 2000);
430
+ });
431
+ jest.advanceTimersByTime(1500);
432
+
433
+ expect($(`${selector} .add-comment textarea`).prop("disabled")).toBeFalsy();
434
+ });
435
+
421
436
  describe("when mounted", () => {
422
437
  beforeEach(() => {
423
438
  spyOnAddComment("on");
@@ -0,0 +1 @@
1
+ gn:
@@ -0,0 +1 @@
1
+ lo:
@@ -4,6 +4,7 @@ ro:
4
4
  models:
5
5
  decidim/comments/comment_by_followed_user_event: Comentariu
6
6
  decidim/comments/comment_created_event: Comentează
7
+ decidim/comments/comment_upvoted_event: Comentariu votat
7
8
  decidim/comments/reply_created_event: Răspuns la comentariu
8
9
  decidim/comments/user_group_mentioned_event: Menționează
9
10
  decidim/comments/user_mentioned_event: Menționează
@@ -73,6 +74,7 @@ ro:
73
74
  edit: Editează
74
75
  edited: Editat
75
76
  hide_replies: Ascunde răspunsurile
77
+ moderated_at: Comentariu moderat pe %{date}
76
78
  reply: Răspunde
77
79
  report:
78
80
  action: Raportează
@@ -50,6 +50,18 @@ module Decidim
50
50
 
51
51
  "<p>#{text}</p>"
52
52
  end
53
+
54
+ # Prevents underscores to be replaced with <em> tags in comments, such as
55
+ # https://github.com/org/module_with_underscores or within words such as
56
+ # "Look for comment_maximum_length in the code". The `no_intra_emphasis`
57
+ # option for Redcarpet does not apparently work for this renderer.
58
+ #
59
+ # Related issues:
60
+ # https://github.com/vmg/redcarpet/issues/402
61
+ # https://github.com/vmg/redcarpet/issues/427
62
+ def emphasis(text)
63
+ "_#{text}_"
64
+ end
53
65
  end
54
66
  end
55
67
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-comments version.
5
5
  module Comments
6
6
  def self.version
7
- "0.27.0"
7
+ "0.27.1"
8
8
  end
9
9
  end
10
10
  end
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.27.0
4
+ version: 0.27.1
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: 2022-09-29 00:00:00.000000000 Z
13
+ date: 2022-11-15 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.27.0
21
+ version: 0.27.1
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.27.0
28
+ version: 0.27.1
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: redcarpet
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -52,28 +52,28 @@ dependencies:
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 0.27.0
55
+ version: 0.27.1
56
56
  type: :development
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 0.27.0
62
+ version: 0.27.1
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: decidim-dev
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 0.27.0
69
+ version: 0.27.1
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - '='
75
75
  - !ruby/object:Gem::Version
76
- version: 0.27.0
76
+ version: 0.27.1
77
77
  description: Pluggable comments system for some components.
78
78
  email:
79
79
  - josepjaume@gmail.com
@@ -197,6 +197,7 @@ files:
197
197
  - config/locales/fr.yml
198
198
  - config/locales/ga-IE.yml
199
199
  - config/locales/gl.yml
200
+ - config/locales/gn-PY.yml
200
201
  - config/locales/hr-HR.yml
201
202
  - config/locales/hr.yml
202
203
  - config/locales/hu.yml
@@ -209,6 +210,7 @@ files:
209
210
  - config/locales/ko.yml
210
211
  - config/locales/lb-LU.yml
211
212
  - config/locales/lb.yml
213
+ - config/locales/lo-LA.yml
212
214
  - config/locales/lt-LT.yml
213
215
  - config/locales/lt.yml
214
216
  - config/locales/lv.yml