plan_my_stuff 0.25.0 → 0.26.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: 64667e99c4a5b732a987a483072636d81c8d36840433feaf83f4d89b71f96934
4
- data.tar.gz: 4675d511991935756e77c8730c57588bcbea68fd48acecfc67753c2062cd48ab
3
+ metadata.gz: 6561200ae8220464aa3e705f21ae4d6695a4c3ae3db222677bb1deddddcd37b7
4
+ data.tar.gz: 98d519079e5c203741de10ce667341246d20335253033357a5d3ae8e1b48feee
5
5
  SHA512:
6
- metadata.gz: 2393fea9842e2c1ee5656f4123416933b0021ba5fcdf80962ddc1e15ea72f12682dbd353cde0f8931066eb2a656be4a34bcf8a6c7ab886e200c52df66c30876b
7
- data.tar.gz: 3aea3806e8ca62fc0de5bf2b94544f0cb5888c3a20a224e8104b85f4d99095715d845e4509a80930c9eb2d9652a16b05151c659b53b19eda3e8f77ce6b5e7bb6
6
+ metadata.gz: 8c78d58f9322827d0483389f56dd82d02786929b851cfc6bf81bdc11973f7cdb06e3866b12c40054d4db71f44a24f5c817fd41213b374cf96eeec75e4c384b44
7
+ data.tar.gz: 9b1464ab72de0568958a73d75bb79f4d7e4095bbebc9e97dcf5f97445c79eace14f83d65da99de36f61c10f5ca37e178e5ffb2ef59afa941cad8f49b3ba56be2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.26.0
4
+
5
+ ### Added
6
+
7
+ - `PlanMyStuff::Issue#awaiting_reply?` - returns `true` when the issue's `Issue Status` field is `Waiting on Reply`.
8
+ - `config.issue_field_names` (canonical field name => consumer field name) and `config.issue_field_values` (canonical
9
+ field name => `{ canonical value => consumer value }`) let a consuming org rename the native Issue Fields / option
10
+ labels the gem refers to internally. Translation runs via the new `PlanMyStuff::IssueFieldTranslation` module:
11
+ canonical => consumer on writes and filters (`set_issue_fields!`, `Issue.list` / `.count` `issue_fields:` +
12
+ `priority_list:`), consumer => canonical on reads (`Issue#issue_fields`), so internal comparisons like
13
+ `awaiting_reply?` / `priority_list?` keep working regardless of the org's naming. Unmapped names / values pass
14
+ through unchanged (identity fallback, mirroring `config.pipeline_statuses`).
15
+
16
+ ### Changed
17
+
18
+ - The waiting/inactivity lifecycle methods now write the native `Issue Status` issue field alongside their existing
19
+ label/metadata changes (gated on `config.issue_fields_enabled`): `enter_waiting_on_user!` sets `Waiting on Reply`,
20
+ `clear_waiting_on_user!` sets `Open`, and `reopen_by_reply!` sets `Reopened`. No-op when `issue_fields_enabled` is
21
+ `false`.
22
+
3
23
  ## 0.25.0
4
24
 
5
25
  ### Added
data/CONFIGURATION.md CHANGED
@@ -214,6 +214,8 @@ config.issue_types = {
214
214
  | Option | Type | Default | Description |
215
215
  |---|---|---|---|
216
216
  | `issue_fields_enabled` | `Boolean` | `true` | Whether the Issue Fields public preview is wired up for the org. |
217
+ | `issue_field_names` | `Hash{String => String}` | `{}` | Canonical Issue Field name => the consumer org's field name. |
218
+ | `issue_field_values` | `Hash` | `{}` | Per field: canonical value => consumer value (single-select labels). |
217
219
 
218
220
  GitHub Issue Fields are structured per-issue metadata (text, number, date, or single-select)
219
221
  configured once at the org level. The preview is rolling out org-by-org. Leave this flag at its
@@ -229,6 +231,27 @@ With the flag off:
229
231
  config.issue_fields_enabled = false # org not admitted to the preview yet
230
232
  ```
231
233
 
234
+ `issue_field_names` and `issue_field_values` let a consuming org rename the native Issue Fields (and their
235
+ single-select option labels) the gem refers to internally, the same way `pipeline_statuses` aliases pipeline
236
+ statuses. Translation is bidirectional via `PlanMyStuff::IssueFieldTranslation`: canonical => consumer on writes and
237
+ filters, consumer => canonical on reads, so internal comparisons (`awaiting_reply?`, `priority_list?`) keep working.
238
+ Unmapped names / values pass through unchanged.
239
+
240
+ ```ruby
241
+ config.issue_field_names = {
242
+ 'Issue Status' => 'Status',
243
+ 'Priority' => 'Prio',
244
+ }
245
+ config.issue_field_values = {
246
+ 'Issue Status' => {
247
+ 'Submitted' => 'Triaged',
248
+ 'Waiting on Reply' => 'Awaiting Customer',
249
+ 'Open' => 'Open',
250
+ 'Reopened' => 'Reopened',
251
+ },
252
+ }
253
+ ```
254
+
232
255
  ## Release pipeline
233
256
 
234
257
  | Option | Type | Default | Description |
@@ -12,7 +12,11 @@ module PlanMyStuff
12
12
  # POST /issues/:issue_id/closure
13
13
  def create
14
14
  issue = PlanMyStuff::Issue.find(params[:issue_id])
15
- issue.update!(state: :closed)
15
+ to_update = {}
16
+ if PlanMyStuff.configuration.issue_fields_enabled
17
+ to_update[:issue_fields] = { 'Issue Status' => 'Fixed' }
18
+ end
19
+ issue.update!(state: :closed, **to_update)
16
20
 
17
21
  yield(issue) if block_given?
18
22
  return if performed?
@@ -28,7 +32,11 @@ module PlanMyStuff
28
32
  # DELETE /issues/:issue_id/closure
29
33
  def destroy
30
34
  issue = PlanMyStuff::Issue.find(params[:issue_id])
31
- issue.update!(state: :open)
35
+ to_update = {}
36
+ if PlanMyStuff.configuration.issue_fields_enabled
37
+ to_update[:issue_fields] = { 'Issue Status' => 'Reopened' }
38
+ end
39
+ issue.update!(state: :open, **to_update)
32
40
 
33
41
  yield(issue) if block_given?
34
42
  return if performed?
@@ -193,6 +193,27 @@ PlanMyStuff.configure do |config|
193
193
  #
194
194
  # config.issue_fields_enabled = false
195
195
 
196
+ # Rename the native Issue Fields the gem refers to internally to whatever your
197
+ # org actually calls them. Keys are the gem's canonical names; values are your
198
+ # org's field names. Applied on reads, writes, and filters; unmapped names pass
199
+ # through unchanged.
200
+ # config.issue_field_names = {
201
+ # 'Issue Status' => 'Status',
202
+ # 'Priority' => 'Prio',
203
+ # }
204
+
205
+ # Rename single-select option labels, nested by canonical field name. Keys are
206
+ # the gem's canonical values; values are your org's option labels. Unmapped
207
+ # fields / values pass through unchanged.
208
+ # config.issue_field_values = {
209
+ # 'Issue Status' => {
210
+ # 'Submitted' => 'Triaged',
211
+ # 'Waiting on Reply' => 'Awaiting Customer',
212
+ # 'Open' => 'Open',
213
+ # 'Reopened' => 'Reopened',
214
+ # },
215
+ # }
216
+
196
217
  # --------------------------------------------------------------------------
197
218
  # Boot behavior
198
219
  # --------------------------------------------------------------------------
@@ -197,6 +197,23 @@ module PlanMyStuff
197
197
  #
198
198
  attr_accessor :pipeline_testing_values
199
199
 
200
+ # Canonical Issue Field name to consumer field name map. Lets a consuming org rename the native issue fields the
201
+ # gem refers to internally (e.g. +"Issue Status"+ -> +"Status"+) without touching gem code. Applied via
202
+ # +PlanMyStuff::IssueFieldTranslation+ on reads, writes, and filters; unmapped names pass through unchanged.
203
+ #
204
+ # @return [Hash{String => String}]
205
+ #
206
+ attr_accessor :issue_field_names
207
+
208
+ # Canonical Issue Field value translations, nested by canonical field name:
209
+ # +{ 'Issue Status' => { 'Waiting on Reply' => 'Awaiting Customer', ... } }+. Lets a consuming org rename
210
+ # single-select option labels without touching gem code. Applied via +PlanMyStuff::IssueFieldTranslation+;
211
+ # unmapped fields / values pass through unchanged.
212
+ #
213
+ # @return [Hash{String => Hash{String => String}}]
214
+ #
215
+ attr_accessor :issue_field_values
216
+
200
217
  # @return [String] branch name that PRs merge into for "Ready for release" transition
201
218
  attr_accessor :main_branch
202
219
 
@@ -404,6 +421,8 @@ module PlanMyStuff
404
421
  @pipeline_statuses = {}
405
422
  @pipeline_testing_field_name = PlanMyStuff::Pipeline::Testing::FIELD_NAME
406
423
  @pipeline_testing_values = PlanMyStuff::Pipeline::Testing::VALUES.dup
424
+ @issue_field_names = {}
425
+ @issue_field_values = {}
407
426
  @main_branch = 'main'
408
427
  @production_branch = 'production'
409
428
  @mount_groups = { webhooks: true, issues: true, projects: true }
@@ -108,6 +108,11 @@ module PlanMyStuff
108
108
  raise(PlanMyStuff::IssueFieldsNotEnabledError)
109
109
  end
110
110
 
111
+ if issue_fields.present?
112
+ issue_fields = issue_fields.to_h.transform_keys(&:to_s)
113
+ issue_fields['Issue Status'] = 'Submitted' if issue_fields['Issue Status'].blank?
114
+ end
115
+
111
116
  if body.blank?
112
117
  raise(PlanMyStuff::ValidationError.new('body must be present', field: :body, expected_type: :string))
113
118
  end
@@ -356,7 +361,7 @@ module PlanMyStuff
356
361
  field_pairs = []
357
362
  field_pairs.concat(build_issue_field_filter_pairs(issue_fields)) if issue_fields.present?
358
363
  if priority_list && PlanMyStuff.configuration.issue_fields_enabled
359
- field_pairs << 'priority-list:Yes'
364
+ field_pairs.concat(build_issue_field_filter_pairs('Priority List' => 'Yes'))
360
365
  end
361
366
  params[:issue_field_values] = field_pairs.join(',') if field_pairs.present?
362
367
 
@@ -428,7 +433,7 @@ module PlanMyStuff
428
433
  field_pairs = []
429
434
  field_pairs.concat(build_issue_field_filter_pairs(issue_fields)) if issue_fields.present?
430
435
  if priority_list && PlanMyStuff.configuration.issue_fields_enabled
431
- field_pairs << 'priority-list:Yes'
436
+ field_pairs.concat(build_issue_field_filter_pairs('Priority List' => 'Yes'))
432
437
  end
433
438
  qualifiers += field_pairs.map { |pair| "field.#{pair}" }
434
439
 
@@ -644,11 +649,13 @@ module PlanMyStuff
644
649
  #
645
650
  def build_issue_field_filter_pairs(hash)
646
651
  hash.flat_map do |name, value|
647
- slug = field_filter_slug(name)
652
+ slug = field_filter_slug(PlanMyStuff::IssueFieldTranslation.consumer_field_name(name))
648
653
  case value
649
654
  when nil then []
650
655
  when Range then range_field_filter_pairs(slug, value)
651
- else ["#{slug}:#{format_field_filter_value(value)}"]
656
+ else
657
+ consumer_value = PlanMyStuff::IssueFieldTranslation.consumer_value(name, value)
658
+ ["#{slug}:#{format_field_filter_value(consumer_value)}"]
652
659
  end
653
660
  end
654
661
  end
@@ -1028,7 +1035,13 @@ module PlanMyStuff
1028
1035
  raise(PlanMyStuff::IssueFieldsNotEnabledError) unless PlanMyStuff.configuration.issue_fields_enabled
1029
1036
 
1030
1037
  fields_by_name = PlanMyStuff::IssueField.list(org: repo.organization).index_by { |field| field.name.downcase }
1031
- inputs = updates.map { |name, value| build_issue_field_input(fields_by_name, name, value) }
1038
+ inputs = updates.map do |name, value|
1039
+ build_issue_field_input(
1040
+ fields_by_name,
1041
+ PlanMyStuff::IssueFieldTranslation.consumer_field_name(name),
1042
+ PlanMyStuff::IssueFieldTranslation.consumer_value(name, value),
1043
+ )
1044
+ end
1032
1045
 
1033
1046
  PlanMyStuff.client.graphql(
1034
1047
  PlanMyStuff::GraphQL::Queries::SET_ISSUE_FIELD_VALUES,
@@ -3,6 +3,11 @@
3
3
  module PlanMyStuff
4
4
  module IssueExtractions
5
5
  module Waiting
6
+ # @return [Boolean]
7
+ def awaiting_reply?
8
+ issue_fields['Issue Status'] == 'Waiting on Reply'
9
+ end
10
+
6
11
  # Marks the issue as waiting on an end-user reply. Sets +metadata.waiting_on_user_at+ to now, (re)computes
7
12
  # +metadata.next_reminder_at+, and adds the configured +waiting_on_user_label+ to the issue. Called from
8
13
  # +Comment.create!+ when a support user posts a comment with +waiting_on_reply: true+, and from the
@@ -19,6 +24,11 @@ module PlanMyStuff
19
24
  PlanMyStuff::Label.ensure!(repo: repo, name: label)
20
25
  PlanMyStuff::Label.add!(issue: self, labels: [label], user: user) if labels.exclude?(label)
21
26
 
27
+ to_update = {}
28
+ if PlanMyStuff.configuration.issue_fields_enabled
29
+ to_update[:issue_fields] = { 'Issue Status' => 'Waiting on Reply' }
30
+ end
31
+
22
32
  self.class.update!(
23
33
  number: number,
24
34
  repo: repo,
@@ -26,6 +36,7 @@ module PlanMyStuff
26
36
  waiting_on_user_at: PlanMyStuff.format_time(now),
27
37
  next_reminder_at: format_next_reminder_at(from: now),
28
38
  },
39
+ **to_update,
29
40
  )
30
41
  reload
31
42
  end
@@ -42,6 +53,11 @@ module PlanMyStuff
42
53
 
43
54
  PlanMyStuff::Label.remove!(issue: self, labels: [label]) if labels.include?(label)
44
55
 
56
+ to_update = {}
57
+ if PlanMyStuff.configuration.issue_fields_enabled
58
+ to_update[:issue_fields] = { 'Issue Status' => 'Open' }
59
+ end
60
+
45
61
  self.class.update!(
46
62
  number: number,
47
63
  repo: repo,
@@ -50,6 +66,7 @@ module PlanMyStuff
50
66
  next_reminder_at:
51
67
  metadata.waiting_on_approval_at ? PlanMyStuff.format_time(metadata.next_reminder_at) : nil,
52
68
  },
69
+ **to_update,
53
70
  )
54
71
  reload
55
72
  end
@@ -67,11 +84,17 @@ module PlanMyStuff
67
84
  inactive_label = PlanMyStuff.configuration.user_inactive_label
68
85
  PlanMyStuff::Label.remove!(issue: self, labels: [inactive_label]) if labels.include?(inactive_label)
69
86
 
87
+ to_update = {}
88
+ if PlanMyStuff.configuration.issue_fields_enabled
89
+ to_update[:issue_fields] = { 'Issue Status' => 'Reopened' }
90
+ end
91
+
70
92
  self.class.update!(
71
93
  number: number,
72
94
  repo: repo,
73
95
  state: :open,
74
96
  metadata: { closed_by_inactivity: false },
97
+ **to_update,
75
98
  )
76
99
  reload
77
100
 
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PlanMyStuff
4
+ # Translates between the canonical Issue Field names / values the gem refers to internally (e.g. +"Issue Status"+,
5
+ # +"Waiting on Reply"+) and the names / values a consuming org actually uses on GitHub. Driven by
6
+ # +config.issue_field_names+ (canonical field name => consumer field name) and +config.issue_field_values+
7
+ # (canonical field name => { canonical value => consumer value }).
8
+ #
9
+ # Outbound (canonical -> consumer) translation happens on writes and filters; inbound (consumer -> canonical) on
10
+ # reads, so internal comparisons like +issue_fields['Issue Status'] == 'Waiting on Reply'+ keep working regardless of
11
+ # how the org named the field or option. Unconfigured names / values pass through unchanged (identity fallback,
12
+ # mirroring +config.pipeline_statuses+).
13
+ module IssueFieldTranslation
14
+ module_function
15
+
16
+ # @param canonical [String, Symbol] canonical field name
17
+ #
18
+ # @return [String] the consumer's field name, or the canonical name when unmapped
19
+ #
20
+ def consumer_field_name(canonical)
21
+ PlanMyStuff.configuration.issue_field_names.fetch(canonical.to_s, canonical.to_s)
22
+ end
23
+
24
+ # @param consumer [String] the consumer's field name (as GitHub returns it)
25
+ #
26
+ # @return [String] the canonical field name, or the consumer name when unmapped
27
+ #
28
+ def canonical_field_name(consumer)
29
+ PlanMyStuff.configuration.issue_field_names.invert.fetch(consumer, consumer)
30
+ end
31
+
32
+ # Translates a canonical value to the consumer's value for the given canonical field. Non-String values (numbers,
33
+ # dates, +nil+) pass through untouched -- only single-select / text labels are translatable.
34
+ #
35
+ # @param canonical_field [String, Symbol] canonical field name
36
+ # @param value [Object, nil] canonical value
37
+ #
38
+ # @return [Object, nil] the consumer's value, or the input when unmapped / non-String
39
+ #
40
+ def consumer_value(canonical_field, value)
41
+ return value unless value.is_a?(String)
42
+
43
+ value_map(canonical_field).fetch(value, value)
44
+ end
45
+
46
+ # Translates a consumer value back to the canonical value for the given canonical field.
47
+ #
48
+ # @param canonical_field [String, Symbol] canonical field name
49
+ # @param value [Object, nil] consumer value
50
+ #
51
+ # @return [Object, nil] the canonical value, or the input when unmapped / non-String
52
+ #
53
+ def canonical_value(canonical_field, value)
54
+ return value unless value.is_a?(String)
55
+
56
+ value_map(canonical_field).invert.fetch(value, value)
57
+ end
58
+
59
+ # @param canonical_field [String, Symbol]
60
+ #
61
+ # @return [Hash{String => String}] canonical-value => consumer-value map for the field (empty when unconfigured)
62
+ #
63
+ def value_map(canonical_field)
64
+ PlanMyStuff.configuration.issue_field_values.fetch(canonical_field.to_s, {})
65
+ end
66
+ end
67
+ end
@@ -6,7 +6,8 @@ module PlanMyStuff
6
6
  # as +Date+, number fields as +Float+, single-select fields as the option name +String+, and
7
7
  # text fields as the raw +String+.
8
8
  #
9
- # Access is by field display name; string and symbol keys both work. Iteration yields
9
+ # Access is by canonical field name (consumer names / values are reverse-translated via
10
+ # +PlanMyStuff::IssueFieldTranslation+ on construction); string and symbol keys both work. Iteration yields
10
11
  # +[name, value]+ pairs in the order GitHub returned them.
11
12
  class IssueFieldValueSet
12
13
  include Enumerable
@@ -19,7 +20,10 @@ module PlanMyStuff
19
20
  # @return [PlanMyStuff::IssueFieldValueSet]
20
21
  #
21
22
  def from_graphql(nodes)
22
- pairs = Array.wrap(nodes).map { |node| [node.dig(:field, :name), coerce(node)] }
23
+ pairs = Array.wrap(nodes).map do |node|
24
+ canonical_name = PlanMyStuff::IssueFieldTranslation.canonical_field_name(node.dig(:field, :name))
25
+ [canonical_name, PlanMyStuff::IssueFieldTranslation.canonical_value(canonical_name, coerce(node))]
26
+ end
23
27
  new(pairs.to_h)
24
28
  end
25
29
 
@@ -3,7 +3,7 @@
3
3
  module PlanMyStuff
4
4
  module VERSION
5
5
  MAJOR = 0
6
- MINOR = 25
6
+ MINOR = 26
7
7
  TINY = 0
8
8
 
9
9
  # Set PRE to nil unless it's a pre-release (beta, rc, etc.)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plan_my_stuff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brands Insurance
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-21 00:00:00.000000000 Z
11
+ date: 2026-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -134,6 +134,7 @@ files:
134
134
  - lib/plan_my_stuff/issue_extractions/viewers.rb
135
135
  - lib/plan_my_stuff/issue_extractions/waiting.rb
136
136
  - lib/plan_my_stuff/issue_field.rb
137
+ - lib/plan_my_stuff/issue_field_translation.rb
137
138
  - lib/plan_my_stuff/issue_field_value_set.rb
138
139
  - lib/plan_my_stuff/issue_metadata.rb
139
140
  - lib/plan_my_stuff/label.rb