i18n_feedback 0.3.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7fcc717fd98e35452b32dced0c863804d92a13c6c50986004c74ffad64189ca
4
- data.tar.gz: 00fa165a3e61bd18e773458cc00c7e38d324e3b00387b1eb0b78269738b73369
3
+ metadata.gz: f4dee71413e641b59a88d1116ac134410395055d31f097d83800155feead9fc8
4
+ data.tar.gz: 4e41cd76dd83acbdd77ff95ece48bed916040bdf0e6227e78aa6090f8c28025b
5
5
  SHA512:
6
- metadata.gz: 8b2dcf16cb6edcec67828d8294cf670205c5b61b591cbeded1eb6605519a0a16b485d644c8b60d7b24d3134088396a22657a653acdeac7dc95b2aeeae64ea1ff
7
- data.tar.gz: 8a60071cfafc8fd341723f4d92f132caa2b71953de672bb3f508b2923315e698ccdac7431acf5f07724c330cb2a70223abb34d560b65e61aa40350875c754b18
6
+ metadata.gz: 9483d2a561d1edb370685c85ac3dfaa5030532c58102aeb923926ea180de687d738e9e7deccbf8a6689f617f4ae7da7a20750272a5306419d60389d574c5b4f4
7
+ data.tar.gz: d50924f6b93eec7fe93bb5e5baa8a7a53a43e8fdcf864b571531646d3f47f8554dff87e6766289ce0589830f0d354176759ea85ebadbff6722396664aec632b9
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.4.0]
6
+
7
+ - Add a `config.on_submit` hook, called with each saved suggestion right after
8
+ it's stored — notify Slack, send an email, open a ticket. Runs inline after
9
+ save, so keep it fast or hand off to a job.
10
+
5
11
  ## [0.3.1]
6
12
 
7
13
  - Fix the widget showing raw key markers (e.g. `⟦i18n_feedback.title⟧`) in its own
data/README.md CHANGED
@@ -234,6 +234,16 @@ end
234
234
  Each row stores `translation_key`, `locale`, `old_value`, `proposed_value`,
235
235
  `comment`, `page_url`, and optional `author_id` / `author_label`.
236
236
 
237
+ ### Getting notified
238
+
239
+ To be pinged when a suggestion comes in, set `on_submit`. It's called with the
240
+ saved `Suggestion` right after it's stored — notify Slack, send an email, open a
241
+ ticket. It runs inline in the request, so keep it fast or hand off to a job:
242
+
243
+ ```ruby
244
+ config.on_submit = ->(suggestion) { SuggestionMailer.with(suggestion:).created.deliver_later }
245
+ ```
246
+
237
247
  ## Security
238
248
 
239
249
  - The tool is gated **on the server** for every marker, endpoint, and injection.
@@ -18,6 +18,7 @@ module I18nFeedback
18
18
  attribute_author(suggestion)
19
19
 
20
20
  if suggestion.save
21
+ I18nFeedback.config.on_submit.call(suggestion)
21
22
  head :created
22
23
  else
23
24
  render json: { errors: suggestion.errors.full_messages }, status: :unprocessable_entity
@@ -36,4 +36,9 @@ I18nFeedback.configure do |config|
36
36
  # Keep this in sync with the `mount` line in config/routes.rb.
37
37
  #
38
38
  # config.mount_path = "/i18n_feedback"
39
+
40
+ # Called with each saved suggestion — notify Slack, send an email, open a
41
+ # ticket. Runs inline after save, so keep it fast or hand off to a job.
42
+ #
43
+ # config.on_submit = ->(suggestion) { SuggestionMailer.with(suggestion:).created.deliver_later }
39
44
  end
@@ -48,6 +48,10 @@ module I18nFeedback
48
48
  # suggest mode without the parameter.
49
49
  attr_accessor :toggle_param
50
50
 
51
+ # Called with each saved suggestion — notify Slack, send an email, open a
52
+ # ticket. Runs inline after save; keep it fast or hand off to a job.
53
+ attr_accessor :on_submit
54
+
51
55
  def initialize
52
56
  @enabled_environments = %w[development staging]
53
57
  @enabled = ->(_request) { true }
@@ -59,6 +63,7 @@ module I18nFeedback
59
63
  @show_pill = true
60
64
  @pill_label = nil
61
65
  @toggle_param = 'i18n_feedback'
66
+ @on_submit = ->(_suggestion) {}
62
67
  end
63
68
 
64
69
  def environment_enabled?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module I18nFeedback
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_feedback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov