ideasbugs 1.2.0 → 1.3.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: f1e288c1f22144db48200a796fddc805d6a7e420d5f9b1c7a88cd74be51b800c
4
- data.tar.gz: beb0741c4e1c81dd46bd91f776525a3cabdac8028927e99ecb3f650129310127
3
+ metadata.gz: edf399697a638eaa2a13340445fdde4c862f924f4ab6f330c3d973aa2c5a7747
4
+ data.tar.gz: 6760c8e7f1ed291a38e77ffb7a4d836b85542da3627f130af198af79e9c38dc4
5
5
  SHA512:
6
- metadata.gz: 7e65c2eaa8171bdb2c67c5737503c353f2c90d755ce17334b0c18b2670e1cf77e04f90dd8c753f46417c0e910901219b2fde794ea4b5a4bcc49e0ff666905b31
7
- data.tar.gz: d5c9b2d8960368ef45cb1ecdf0d3c24a91c951fef728ad6067bea3ffac0e66a1443f196040e434510723c9103ec4d0b189847a3b38f89cbb484f020a726b72a1
6
+ metadata.gz: bfa830068047cb3f390a47a4d5841ffd4dee8911c9ca410c64e3553301b7fe261474db8ee079f53bad2990103274c0b4f6ba18ab94c412e02f87d42b29c9cff6
7
+ data.tar.gz: e8da203df04a8e43f0444e92203201d93ad7be19097759b04470318aec9ee688092ea8f4661da82b8167c9bd6bb85ed66eea661caa89a62be70feddff05f4aec
data/AGENTS.md CHANGED
@@ -90,6 +90,10 @@ With `show_button = false`, any element carrying `data-ideasbugs-open` opens the
90
90
 
91
91
  `open → in_review → resolved`, as plain strings in `Ideasbugs::Feedback::STATUSES` with a scope per status (`Feedback.open`, `.in_review`, `.resolved`) plus `newest_first`. Deliberately not an Active Record enum — `open` as an enum scope would collide with `Kernel#open`. Do not "modernize" it into an enum.
92
92
 
93
+ ### Duplicates
94
+
95
+ `duplicate.mark_duplicate_of!(original)` links two feedbacks asking for the same thing; `unmark_duplicate!` undoes it. A duplicate is a link, not a merge: never copy, move or delete its message, author or screenshots, and never change it through `update_all`. Go through these two methods, which keep the link one level deep and on one tenant. `bin/rails generate ideasbugs:duplicates` exists **only** to add the column to installs made before 1.3; a fresh install already has it.
96
+
93
97
  ### Multi-tenancy
94
98
 
95
99
  One resolver returning an **opaque key** — GlobalID, id, subdomain, slug. The gem never takes a foreign key into host models:
@@ -116,6 +120,7 @@ customer.feedback.open
116
120
  - **Do not expose screenshots by blob URL** — the gated route exists so a leaked signed URL cannot hand over a customer's screenshot.
117
121
  - **Do not set config outside the initializer.** `rate_limit` in particular is read once when the controller class loads; assigning config per-request mutates it process-wide.
118
122
  - **Do not convert the status strings to an enum** (see above).
123
+ - **Do not re-implement submission rules in a host API endpoint.** Call `Ideasbugs::Feedback.submit` (README → File feedback from your own API). The host endpoint brings its own authentication, `enabled`-style gate, throttle and tenant key.
119
124
 
120
125
  ### Configuration worth knowing
121
126
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,29 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.3.1] - 2026-11-10
6
+
7
+ - Fix the dashboard queue under Rails edge Ractor requests. 1.3.0's
8
+ `Feedback.originals` scope raised `Ractor::IsolationError` in a non-main
9
+ Ractor. Normal Rails boots were unaffected. No migration or initializer
10
+ change.
11
+
12
+ ## [1.3.0] - 2026-11-10
13
+
14
+ - **Duplicates.** Mark a feedback as a duplicate of another from the dashboard
15
+ (`Feedback#mark_duplicate_of!`, undone with `unmark_duplicate!`). The
16
+ duplicate leaves the queue and its counts, keeps its own message, author and
17
+ screenshots, and is listed on the original, which shows how many it has. The
18
+ link stays one level deep and within one tenant. Deleting an original puts
19
+ its duplicates back in the queue.
20
+ - **Cost:** one nullable `duplicate_of_id` column. Existing installs run
21
+ `bin/rails generate ideasbugs:duplicates && bin/rails db:migrate`; until
22
+ then the dashboard behaves exactly as in 1.2, without duplicate controls.
23
+ Fresh installs get the column from `ideasbugs:install`. No initializer
24
+ change.
25
+ - Add a README recipe for filing feedback from a host's own API through
26
+ `Feedback.submit`.
27
+
5
28
  ## [1.2.0] - 2026-11-09
6
29
 
7
30
  - Add `Ideasbugs::Feedback.submit(attributes, author:, tenant:, user_agent:,
data/README.md CHANGED
@@ -74,7 +74,7 @@ the things it should not do. It ships inside the gem, so
74
74
  | | |
75
75
  | ------------ | ------------------------------------------------------------------------ |
76
76
  | **Widget** | Type (bug / feature / other), optional section, message, up to 3 screenshots |
77
- | **Dashboard**| Status tabs (open → in review → resolved), type filter, search, inline screenshots |
77
+ | **Dashboard**| Status tabs (open → in review → resolved), type filter, search, inline screenshots, duplicates |
78
78
  | **Storage** | `ideasbugs_feedbacks` — ordinary Active Record rows you can query and export |
79
79
  | **Deps** | None. Plain JS — no Tailwind, no Stimulus, no importmap, no build step |
80
80
  | **Auth** | Lambdas over the raw request — Devise, Rails 8 auth, Basic auth, anything |
@@ -223,7 +223,90 @@ end
223
223
  Each row stores `kind`, `section`, `message`, `status` (`open` / `in_review` /
224
224
  `resolved`), `page_url`, `user_agent`, an optional `tenant`, and optional
225
225
  `author_id` / `author_label`. Screenshots are Active Storage attachments
226
- (`feedback.screenshots`).
226
+ (`feedback.screenshots`). `duplicate_of_id` points a duplicate at its original.
227
+
228
+ ## Duplicates
229
+
230
+ When two people ask for the same thing, open one in the dashboard and mark it
231
+ as a duplicate of the other by number. The duplicate leaves the queue but keeps
232
+ its own words, author and screenshots, and the original lists it with a count.
233
+ **Not a duplicate** puts it back. Nothing is merged, so marking is safe to undo.
234
+
235
+ ```ruby
236
+ duplicate.mark_duplicate_of!(original) # one level deep, see below
237
+ original.duplicates # an ordinary relation
238
+ Ideasbugs::Feedback.originals # everything that isn't a duplicate
239
+ duplicate.unmark_duplicate!
240
+ ```
241
+
242
+ The link is always one level deep. A duplicate of a duplicate points at the
243
+ original, marking an original moves its own duplicates along with it, and
244
+ marking an original as a duplicate of one of its duplicates swaps the two.
245
+ Both must be on the same board (tenant). Deleting an original puts its
246
+ duplicates back in the queue. A duplicate follows its original's status in the
247
+ dashboard and keeps its own `status` for when it is unmarked.
248
+
249
+ **Upgrading from 1.2 or earlier:** run
250
+ `bin/rails generate ideasbugs:duplicates && bin/rails db:migrate`. Until then
251
+ the dashboard works as before, without duplicate controls.
252
+
253
+ ## File feedback from your own API
254
+
255
+ The widget is one way in. If your app already has an API, one endpoint lets
256
+ scripts, integrations and AI agents file feedback with the tokens they already
257
+ use for the rest of it. `Ideasbugs::Feedback.submit` applies the widget's rules
258
+ (page URL privacy filtering, attribution, screenshot limits, `on_submit`), so
259
+ API feedback lands in the same dashboard and nothing drifts:
260
+
261
+ ```ruby
262
+ # config/routes.rb
263
+ namespace :api do
264
+ resource :feedback, only: :create
265
+ end
266
+ ```
267
+
268
+ ```ruby
269
+ # app/controllers/api/feedbacks_controller.rb
270
+ class Api::FeedbacksController < Api::BaseController # your token-authenticated base
271
+ rate_limit to: 10, within: 1.minute, by: -> { current_user.id }
272
+
273
+ def create
274
+ feedback = Ideasbugs::Feedback.submit(
275
+ params.require(:feedback).permit(:kind, :section, :message, :page_url),
276
+ author: current_user,
277
+ tenant: Current.organization&.to_gid&.to_s, # what config.tenant returns; omit for one board
278
+ user_agent: request.user_agent
279
+ )
280
+
281
+ if feedback.persisted?
282
+ render json: { id: feedback.id, kind: feedback.kind, status: feedback.status }, status: :created
283
+ else
284
+ render json: { errors: feedback.errors.full_messages }, status: :unprocessable_entity
285
+ end
286
+ end
287
+ end
288
+ ```
289
+
290
+ ```bash
291
+ curl -X POST https://app.example.com/api/feedback \
292
+ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
293
+ -d '{"feedback":{"kind":"bug","message":"The yearly export times out."}}'
294
+ ```
295
+
296
+ `submit` reads only `kind`, `section`, `message` and `page_url`, and returns
297
+ the record: check `persisted?` and `errors`. Your endpoint still owns:
298
+
299
+ - **Authentication.** The gem has no tokens of its own. Attribute feedback to
300
+ the token's user so the dashboard shows who sent it.
301
+ - **The gates.** `config.enabled` and `config.rate_limit` guard the widget's
302
+ endpoint only. Apply the same rule and a throttle here.
303
+ - **The tenant.** Pass the key `config.tenant` would return for that user, or
304
+ the feedback lands on the global board.
305
+ - **Screenshots.** Pass uploaded files as `screenshots:` from a multipart
306
+ request. A JSON-only endpoint can stay text-only.
307
+
308
+ To let agents find it, list the endpoint in your API docs or OpenAPI schema
309
+ like any other.
227
310
 
228
311
  ## Multi-tenancy
229
312
 
@@ -276,8 +359,10 @@ stable under semantic versioning:
276
359
 
277
360
  - `Ideasbugs::Feedback`, including `kind`, `section`, `message`, `status`,
278
361
  `page_url`, `user_agent`, `tenant`, `author_id`, `author_label`, timestamps,
279
- `STATUSES`, status helpers/scopes, `newest_first`, `for_tenant`, and gated
280
- `screenshots`.
362
+ `STATUSES`, status helpers/scopes, `newest_first`, `for_tenant`, gated
363
+ `screenshots`, `Feedback.submit`, and the duplicate API (`duplicate_of`,
364
+ `duplicates`, `duplicate?`, `originals`, `mark_duplicate_of!`,
365
+ `unmark_duplicate!`).
281
366
  - `has_feedback` and the host-model collection it defines.
282
367
  - `Ideasbugs.configure` and the documented configuration options.
283
368
  - `mount_ideasbugs`, `ideasbugs_tag`, and `data-ideasbugs-open`.
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ideasbugs
4
+ # Files a feedback under another one asking for the same thing, or takes it
5
+ # back out. Both ends resolve through the tenant scope, so a duplicate can
6
+ # never point across boards.
7
+ class DuplicatesController < DashboardController
8
+ before_action -> { head :not_found unless Feedback.tracks_duplicates? }
9
+ before_action -> { @feedback = tenant_scope.find(params[:feedback_id]) }
10
+
11
+ def create
12
+ original = tenant_scope.find_by(id: params[:original_id].to_s.delete_prefix('#').strip)
13
+ unless original
14
+ return refuse(t('ideasbugs.dashboard.duplicate_not_found', default: 'No feedback with that number.'))
15
+ end
16
+
17
+ @feedback.mark_duplicate_of!(original)
18
+ original = @feedback.duplicate_of
19
+ redirect_to feedbacks_path(status: original.status, feedback_id: original.id), status: :see_other
20
+ rescue ActiveRecord::RecordInvalid => e
21
+ refuse(e.record.errors.full_messages.to_sentence)
22
+ end
23
+
24
+ def destroy
25
+ @feedback.unmark_duplicate!
26
+ redirect_to feedbacks_path(status: @feedback.status, feedback_id: @feedback.id), status: :see_other
27
+ end
28
+
29
+ private
30
+
31
+ def refuse(message)
32
+ redirect_back fallback_location: feedbacks_path(feedback_id: @feedback.id), alert: message, status: :see_other
33
+ end
34
+ end
35
+ end
@@ -11,15 +11,16 @@ module Ideasbugs
11
11
  @status = Feedback::STATUSES.include?(params[:status]) ? params[:status] : 'open'
12
12
  @kind = Ideasbugs.config.kinds.map(&:to_s).include?(params[:kind]) ? params[:kind] : nil
13
13
  @query = params[:q].to_s.strip.presence
14
- @counts = tenant_scope.group(:status).count
14
+ @counts = tenant_scope.originals.group(:status).count
15
15
 
16
- scope = tenant_scope.where(status: @status)
16
+ scope = tenant_scope.originals.where(status: @status)
17
17
  scope = scope.where(kind: @kind) if @kind
18
18
  scope = search(scope) if @query
19
19
  @page = [params[:page].to_i, 1].max
20
20
  @feedbacks = scope.newest_first.offset((@page - 1) * PER_PAGE).limit(PER_PAGE + 1).to_a
21
21
  @more = @feedbacks.size > PER_PAGE
22
22
  @feedbacks = @feedbacks.first(PER_PAGE)
23
+ @duplicate_counts = duplicate_counts(@feedbacks)
23
24
 
24
25
  @selected_feedback = tenant_scope.find_by(id: params[:feedback_id]) if params[:feedback_id].present?
25
26
 
@@ -43,6 +44,13 @@ module Ideasbugs
43
44
 
44
45
  private
45
46
 
47
+ # One grouped query for the whole page rather than a count per row.
48
+ def duplicate_counts(feedbacks)
49
+ return {} unless Feedback.tracks_duplicates?
50
+
51
+ tenant_scope.where(duplicate_of_id: feedbacks.map(&:id)).group(:duplicate_of_id).count
52
+ end
53
+
46
54
  def set_feedback
47
55
  @feedback = tenant_scope.find(params[:id])
48
56
  end
@@ -34,6 +34,27 @@ module Ideasbugs
34
34
  scope status, -> { where(status:) }
35
35
  end
36
36
 
37
+ # A duplicate is a judgment, not a merge: the row keeps its own words,
38
+ # author and screenshots, and points at the original asking for the same
39
+ # thing. Always one level deep, so nothing walks a chain. Installs from
40
+ # before 1.3 lack the column until they run `ideasbugs:duplicates`, and
41
+ # everything below stays inert until then; hence no `dependent:` here.
42
+ belongs_to :duplicate_of, class_name: 'Ideasbugs::Feedback', optional: true, inverse_of: :duplicates
43
+ has_many :duplicates, class_name: 'Ideasbugs::Feedback', foreign_key: :duplicate_of_id,
44
+ inverse_of: :duplicate_of
45
+
46
+ validate :duplicate_of_an_original, if: -> { self.class.tracks_duplicates? && duplicate_of_id_changed? }
47
+ before_destroy :release_duplicates
48
+
49
+ # What the queue lists: everything that is not a duplicate of something else.
50
+ # `klass.`, not a bare call: relation delegation caches the method name on
51
+ # the class, which a non-main Ractor may not write.
52
+ scope :originals, -> { klass.tracks_duplicates? ? where(duplicate_of_id: nil) : all }
53
+
54
+ def self.tracks_duplicates?
55
+ column_names.include?('duplicate_of_id')
56
+ end
57
+
37
58
  SUBMITTED_ATTRIBUTES = %i[kind section message page_url].freeze
38
59
 
39
60
  # Files feedback the way the widget does: privacy-filtered page URL, author
@@ -91,6 +112,30 @@ module Ideasbugs
91
112
  respond_to?(:screenshots) && screenshots.attached?
92
113
  end
93
114
 
115
+ def duplicate?
116
+ self.class.tracks_duplicates? && duplicate_of_id.present?
117
+ end
118
+
119
+ # Files this feedback under `original` as asking for the same thing. The
120
+ # link stays one level deep: a duplicate of a duplicate points at its
121
+ # original, this row's own duplicates move along with it, and marking an
122
+ # original as a duplicate of one of its own duplicates swaps the two.
123
+ def mark_duplicate_of!(original)
124
+ original = original.duplicate_of if original.duplicate_of_id && original.duplicate_of_id != id
125
+
126
+ transaction do
127
+ # Moving links fires nothing, and must not trip validations that a row
128
+ # filed under an older config would fail today.
129
+ duplicates.where.not(id: original.id).update_all(duplicate_of_id: original.id, updated_at: Time.current)
130
+ original.update_column(:duplicate_of_id, nil) if original.duplicate_of_id == id
131
+ update!(duplicate_of: original)
132
+ end
133
+ end
134
+
135
+ def unmark_duplicate!
136
+ update!(duplicate_of: nil)
137
+ end
138
+
94
139
  def attribute_to(author)
95
140
  return unless author
96
141
 
@@ -121,6 +166,28 @@ module Ideasbugs
121
166
 
122
167
  private
123
168
 
169
+ def duplicate_of_an_original
170
+ return if duplicate_of_id.nil?
171
+
172
+ original = duplicate_of
173
+ if original.nil? || original.id == id
174
+ errors.add(:duplicate_of, 'must be another feedback')
175
+ elsif original.tenant != tenant
176
+ errors.add(:duplicate_of, 'must be on the same board')
177
+ elsif original.duplicate_of_id
178
+ errors.add(:duplicate_of, 'is itself a duplicate')
179
+ elsif persisted? && duplicates.exists?
180
+ errors.add(:base, 'Feedback with duplicates of its own cannot be a duplicate')
181
+ end
182
+ end
183
+
184
+ # Deleting an original puts its duplicates back in the queue.
185
+ def release_duplicates
186
+ return unless self.class.tracks_duplicates?
187
+
188
+ duplicates.update_all(duplicate_of_id: nil, updated_at: Time.current)
189
+ end
190
+
124
191
  def screenshot_error(files)
125
192
  config = Ideasbugs.config
126
193
  return [:error_save] unless config.screenshots_enabled?
@@ -9,7 +9,9 @@
9
9
 
10
10
  <%# The shared status switch, carrying the status the heading badge used to
11
11
  state: the current one is lit and inert, every other one is a submit
12
- that files the report under it. One form, no JS. %>
12
+ that files the report under it. One form, no JS. A duplicate has no
13
+ lifecycle of its own: it follows its original. %>
14
+ <% unless feedback.duplicate? %>
13
15
  <%= form_with url: feedback_path(feedback), method: :patch, class: 'status-switch' do %>
14
16
  <% Ideasbugs::Feedback::STATUSES.each do |status| %>
15
17
  <% label = t("ideasbugs.statuses.#{status}", default: status.humanize) %>
@@ -23,9 +25,28 @@
23
25
  <% end %>
24
26
  <% end %>
25
27
  <% end %>
28
+ <% end %>
26
29
  </div>
27
30
 
28
31
  <div class="detail-scroll">
32
+ <% if flash[:alert] %>
33
+ <p class="flash alert" role="alert"><%= flash[:alert] %></p>
34
+ <% end %>
35
+
36
+ <% if feedback.duplicate? && (original = feedback.duplicate_of) %>
37
+ <div class="card pad duplicate-of">
38
+ <p>
39
+ <%= t('ideasbugs.dashboard.duplicate_of', default: 'Duplicate of') %>
40
+ <%= link_to "##{original.id}", feedbacks_path(status: original.status, feedback_id: original.id) %>
41
+ <span class="badge status-<%= original.status %>">
42
+ <%= t("ideasbugs.statuses.#{original.status}", default: original.status.humanize) %>
43
+ </span>
44
+ </p>
45
+ <p class="muted"><%= truncate(original.message, length: 160) %></p>
46
+ <%= button_to t('ideasbugs.dashboard.not_duplicate', default: 'Not a duplicate'),
47
+ feedback_duplicate_path(feedback), method: :delete, class: 'small' %>
48
+ </div>
49
+ <% end %>
29
50
  <div class="card pad">
30
51
  <dl>
31
52
  <% if feedback.section.present? %>
@@ -63,9 +84,38 @@
63
84
  <% end %>
64
85
  </div>
65
86
 
87
+ <% duplicates = Ideasbugs::Feedback.tracks_duplicates? ? feedback.duplicates.newest_first.to_a : [] %>
88
+ <% if duplicates.any? %>
89
+ <section class="card duplicates" aria-labelledby="duplicates-<%= feedback.id %>">
90
+ <h2 id="duplicates-<%= feedback.id %>">
91
+ <%= t('ideasbugs.dashboard.duplicates', default: 'Duplicates') %> <span class="count"><%= duplicates.size %></span>
92
+ </h2>
93
+ <% duplicates.each do |duplicate| %>
94
+ <%= link_to feedbacks_path(status: feedback.status, feedback_id: duplicate.id), class: 'record-row' do %>
95
+ <span class="record-main">
96
+ <span class="record-copy"><%= truncate(duplicate.message, length: 120) %></span>
97
+ <span class="muted record-meta">
98
+ <span>#<%= duplicate.id %></span>
99
+ <% if duplicate.author_label.present? %>
100
+ <span><%= duplicate.author_label %></span>
101
+ <% end %>
102
+ </span>
103
+ </span>
104
+ <% end %>
105
+ <% end %>
106
+ </section>
107
+ <% end %>
108
+
66
109
  <%# Status lives in the switch in the heading; only what a switch cannot say
67
110
  is left here. %>
68
111
  <div class="actions">
112
+ <% if Ideasbugs::Feedback.tracks_duplicates? && !feedback.duplicate? %>
113
+ <%= form_with url: feedback_duplicate_path(feedback), method: :post, class: 'mark-duplicate' do %>
114
+ <label for="original_id_<%= feedback.id %>"><%= t('ideasbugs.dashboard.mark_duplicate', default: 'Mark as duplicate of #') %></label>
115
+ <input type="text" name="original_id" id="original_id_<%= feedback.id %>" required autocomplete="off">
116
+ <button><%= t('ideasbugs.dashboard.mark_duplicate_submit', default: 'Mark duplicate') %></button>
117
+ <% end %>
118
+ <% end %>
69
119
  <%= button_to t('ideasbugs.dashboard.delete', default: 'Delete'),
70
120
  feedback_path(feedback),
71
121
  method: :delete, class: 'danger',
@@ -60,6 +60,9 @@
60
60
  <% if feedback.author_label.present? %>
61
61
  <span><%= feedback.author_label %></span>
62
62
  <% end %>
63
+ <% if (duplicates = @duplicate_counts[feedback.id]) %>
64
+ <span><%= t('ideasbugs.dashboard.duplicates_count', count: duplicates, default: 'Duplicates: %{count}') %></span>
65
+ <% end %>
63
66
  </span>
64
67
  </span>
65
68
  <% if feedback.screenshots? %>
@@ -45,3 +45,10 @@ en:
45
45
  move_to_resolved: "Mark resolved"
46
46
  delete: "Delete"
47
47
  delete_confirm: "Delete this feedback?"
48
+ duplicate_of: "Duplicate of"
49
+ duplicates: "Duplicates"
50
+ duplicates_count: "Duplicates: %{count}"
51
+ mark_duplicate: "Mark as duplicate of #"
52
+ mark_duplicate_submit: "Mark duplicate"
53
+ not_duplicate: "Not a duplicate"
54
+ duplicate_not_found: "No feedback with that number."
data/config/routes.rb CHANGED
@@ -14,6 +14,7 @@ Ideasbugs::Engine.routes.draw do
14
14
  # Screenshots stream through the dashboard's own gate, never via public
15
15
  # Active Storage blob URLs.
16
16
  resources :screenshots, only: :show
17
+ resource :duplicate, only: %i[create destroy]
17
18
  end
18
19
 
19
20
  root to: 'feedbacks#index'
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators'
4
+ require 'rails/generators/active_record'
5
+ require_relative '../migration_helpers'
6
+
7
+ module Ideasbugs
8
+ module Generators
9
+ # For apps that installed ideasbugs before 1.3: adds the nullable
10
+ # `duplicate_of_id` column (and its index) to ideasbugs_feedbacks. A fresh
11
+ # install already gets it. Additive: existing rows are originals, and the
12
+ # dashboard offers duplicate marking once the column exists.
13
+ #
14
+ # bin/rails generate ideasbugs:duplicates && bin/rails db:migrate
15
+ class DuplicatesGenerator < Rails::Generators::Base
16
+ include ActiveRecord::Generators::Migration
17
+ include MigrationHelpers
18
+
19
+ source_root File.expand_path('templates', __dir__)
20
+
21
+ desc 'Adds the duplicate_of column to ideasbugs_feedbacks (duplicates upgrade).'
22
+
23
+ def create_migration_file
24
+ migration_template 'add_duplicate_of_to_ideasbugs_feedbacks.rb.tt',
25
+ 'db/migrate/add_duplicate_of_to_ideasbugs_feedbacks.rb'
26
+ end
27
+
28
+ def post_install
29
+ say "\nduplicate_of column queued. Run `rails db:migrate`, then mark", :green
30
+ say 'duplicates from any feedback in the dashboard.'
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddDuplicateOfToIdeasbugsFeedbacks < ActiveRecord::Migration<%= migration_version %>
4
+ def change
5
+ add_reference :ideasbugs_feedbacks, :duplicate_of<%= reference_type_option %>, index: true
6
+ end
7
+ end
@@ -12,6 +12,7 @@ class CreateIdeasbugsFeedbacks < ActiveRecord::Migration<%= migration_version %>
12
12
  t.string :author_id
13
13
  t.string :author_label
14
14
  t.string :tenant # opaque per-tenant key; nil = single global board
15
+ t.references :duplicate_of<%= reference_type_option %>, index: true
15
16
 
16
17
  t.timestamps
17
18
  end
@@ -24,9 +24,18 @@ module Ideasbugs
24
24
  # template is expanded at generate time: emitting the method name would
25
25
  # put `id: primary_key_type` in the migration, where nothing defines it.
26
26
  def primary_key_type_option
27
+ primary_key_type ? ", id: :#{primary_key_type}" : ''
28
+ end
29
+
30
+ # The same lookup for a column that points back at a feedback row, so
31
+ # `duplicate_of_id` matches a uuid-keyed table's own id.
32
+ def reference_type_option
33
+ primary_key_type ? ", type: :#{primary_key_type}" : ''
34
+ end
35
+
36
+ def primary_key_type
27
37
  config = Rails.configuration.generators
28
- type = config.options[config.orm][:primary_key_type]
29
- type ? ", id: :#{type}" : ''
38
+ config.options[config.orm][:primary_key_type]
30
39
  end
31
40
  end
32
41
  end
@@ -286,8 +286,8 @@
286
286
  }
287
287
 
288
288
  /* ---------------------------------------------------------------------------
289
- * GEM-SPECIFIC — ideasbugs only: the kind and status badges, and the
290
- * screenshots a reporter attached.
289
+ * GEM-SPECIFIC — ideasbugs only: the kind and status badges, the
290
+ * screenshots a reporter attached, and duplicates.
291
291
  * ------------------------------------------------------------------------- */
292
292
 
293
293
  :root {
@@ -314,6 +314,14 @@
314
314
  & .status-switch button.current.status-in_review { color: var(--ib-in-review); }
315
315
  & .status-switch button.current.status-resolved { color: var(--ib-resolved); }
316
316
 
317
+ /* A duplicate's link to its original, and the original's list of them. */
318
+ & .duplicate-of p { margin: 0 0 8px; }
319
+ & .duplicates h2 { margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--ib-border); font-size: 14px; }
320
+ & .duplicates .record-row:last-child { border-bottom: 0; }
321
+ & .actions form.mark-duplicate { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
322
+ & .mark-duplicate label { color: var(--ib-muted); font-size: 13px; white-space: nowrap; }
323
+ & .mark-duplicate input { width: 9em; }
324
+
317
325
  & .shots { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
318
326
  & .shots img { max-width: 280px; max-height: 200px; border: 1px solid var(--ib-border); border-radius: 8px; }
319
327
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ideasbugs
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ideasbugs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov
@@ -49,6 +49,7 @@ files:
49
49
  - app/controllers/concerns/ideasbugs/request_context.rb
50
50
  - app/controllers/ideasbugs/application_controller.rb
51
51
  - app/controllers/ideasbugs/dashboard_controller.rb
52
+ - app/controllers/ideasbugs/duplicates_controller.rb
52
53
  - app/controllers/ideasbugs/feedbacks_controller.rb
53
54
  - app/controllers/ideasbugs/screenshots_controller.rb
54
55
  - app/controllers/ideasbugs/submissions_controller.rb
@@ -98,6 +99,8 @@ files:
98
99
  - docs/screenshots/dashboard-light.png
99
100
  - docs/screenshots/widget-dark.png
100
101
  - docs/screenshots/widget-light.png
102
+ - lib/generators/ideasbugs/duplicates/duplicates_generator.rb
103
+ - lib/generators/ideasbugs/duplicates/templates/add_duplicate_of_to_ideasbugs_feedbacks.rb.tt
101
104
  - lib/generators/ideasbugs/install/install_generator.rb
102
105
  - lib/generators/ideasbugs/install/templates/create_ideasbugs_feedbacks.rb.tt
103
106
  - lib/generators/ideasbugs/install/templates/initializer.rb