plan_my_stuff 0.25.0 → 0.27.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 +4 -4
- data/CHANGELOG.md +33 -0
- data/CONFIGURATION.md +23 -0
- data/app/controllers/plan_my_stuff/issues/closures_controller.rb +10 -2
- data/app/controllers/plan_my_stuff/webhooks/github_controller.rb +13 -4
- data/lib/generators/plan_my_stuff/install/templates/initializer.rb +21 -0
- data/lib/plan_my_stuff/comment.rb +1 -24
- data/lib/plan_my_stuff/configuration.rb +19 -0
- data/lib/plan_my_stuff/issue.rb +42 -5
- data/lib/plan_my_stuff/issue_extractions/waiting.rb +23 -0
- data/lib/plan_my_stuff/issue_field_translation.rb +67 -0
- data/lib/plan_my_stuff/issue_field_value_set.rb +6 -2
- data/lib/plan_my_stuff/pipeline.rb +4 -1
- data/lib/plan_my_stuff/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f4162f792a9b4fbc7cced8a9a91721c21d15010189cf38021b87d20d53dbcb56
|
|
4
|
+
data.tar.gz: 72c6220c9be50c083360357ba28f1cb7225c784ed9c8813430e24e9e27736f04
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af715bae691caff87d81935e140a3bc2d4af7ef49780686f85b8f145ce9e7a6ff32a6ea689c697a4bc6d193ca0612ff7147a850ea5088876282c4a6bf284ab26
|
|
7
|
+
data.tar.gz: 94d67d34bc302ceb3ec4fa815d5420f60323a9be1c6b4003af4948675861328d5c0ae74c7cd71031a9102c30af7e63a7586d72b64136263c865b7f3cdd46d8ce
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.27.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `PlanMyStuff::Issue#mark_responded!(user)` - stamps `metadata.responded_at` on the first support-user engagement of
|
|
8
|
+
any kind. No-ops when the user is blank, not a support user, the issue isn't a PMS issue, or `responded_at` is
|
|
9
|
+
already set.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- `Pipeline.take!` and the `issues.assigned` webhook now stamp `metadata.responded_at` on first support engagement
|
|
14
|
+
(was previously only set by the first support comment) (closes #60).
|
|
15
|
+
|
|
16
|
+
## 0.26.0
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- `PlanMyStuff::Issue#awaiting_reply?` - returns `true` when the issue's `Issue Status` field is `Waiting on Reply`.
|
|
21
|
+
- `config.issue_field_names` (canonical field name => consumer field name) and `config.issue_field_values` (canonical
|
|
22
|
+
field name => `{ canonical value => consumer value }`) let a consuming org rename the native Issue Fields / option
|
|
23
|
+
labels the gem refers to internally. Translation runs via the new `PlanMyStuff::IssueFieldTranslation` module:
|
|
24
|
+
canonical => consumer on writes and filters (`set_issue_fields!`, `Issue.list` / `.count` `issue_fields:` +
|
|
25
|
+
`priority_list:`), consumer => canonical on reads (`Issue#issue_fields`), so internal comparisons like
|
|
26
|
+
`awaiting_reply?` / `priority_list?` keep working regardless of the org's naming. Unmapped names / values pass
|
|
27
|
+
through unchanged (identity fallback, mirroring `config.pipeline_statuses`).
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- The waiting/inactivity lifecycle methods now write the native `Issue Status` issue field alongside their existing
|
|
32
|
+
label/metadata changes (gated on `config.issue_fields_enabled`): `enter_waiting_on_user!` sets `Waiting on Reply`,
|
|
33
|
+
`clear_waiting_on_user!` sets `Open`, and `reopen_by_reply!` sets `Reopened`. No-op when `issue_fields_enabled` is
|
|
34
|
+
`false`.
|
|
35
|
+
|
|
3
36
|
## 0.25.0
|
|
4
37
|
|
|
5
38
|
### 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
|
-
|
|
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
|
-
|
|
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?
|
|
@@ -91,6 +91,10 @@ module PlanMyStuff
|
|
|
91
91
|
# GitHub already records the issue assignment (that's what triggered this webhook), so the gem does not
|
|
92
92
|
# call +assign!+ on the project item -- that would clobber co-assignees on the underlying issue.
|
|
93
93
|
#
|
|
94
|
+
# Regardless of pipeline state, +mark_responded!+ stamps +metadata.responded_at+ when a support user is the
|
|
95
|
+
# assignee -- including self-assigns to issues already in the pipeline. The method's own guards no-op for
|
|
96
|
+
# non-support assignees and already-responded issues.
|
|
97
|
+
#
|
|
94
98
|
# @return [void]
|
|
95
99
|
#
|
|
96
100
|
def handle_issue_assigned
|
|
@@ -101,6 +105,14 @@ module PlanMyStuff
|
|
|
101
105
|
|
|
102
106
|
return if assignee_login.blank?
|
|
103
107
|
|
|
108
|
+
repo = payload_params.dig(:repository, :full_name)
|
|
109
|
+
issue = PlanMyStuff::Issue.find(issue_number, repo: repo)
|
|
110
|
+
assignee_user = PlanMyStuff::UserResolver.from_github_login(assignee_login)
|
|
111
|
+
|
|
112
|
+
# Stamp before the already-in-pipeline early-return so a support user self-assigning to an
|
|
113
|
+
# already-taken issue still records a first response.
|
|
114
|
+
issue.mark_responded!(assignee_user)
|
|
115
|
+
|
|
104
116
|
existing = PlanMyStuff::Pipeline::IssueLinker.find_project_item(issue_number)
|
|
105
117
|
if existing.present?
|
|
106
118
|
Rails.logger.info("[PlanMyStuff] Issue ##{issue_number} already in pipeline project, skipping")
|
|
@@ -108,9 +120,6 @@ module PlanMyStuff
|
|
|
108
120
|
return
|
|
109
121
|
end
|
|
110
122
|
|
|
111
|
-
repo = payload_params.dig(:repository, :full_name)
|
|
112
|
-
issue = PlanMyStuff::Issue.find(issue_number, repo: repo)
|
|
113
|
-
|
|
114
123
|
if issue.approvals_required? && !issue.fully_approved?
|
|
115
124
|
Rails.logger.info("[PlanMyStuff] Issue ##{issue_number} has pending approvals, skipping")
|
|
116
125
|
|
|
@@ -119,7 +128,7 @@ module PlanMyStuff
|
|
|
119
128
|
|
|
120
129
|
number = PlanMyStuff::Pipeline.resolve_pipeline_project_number!
|
|
121
130
|
project_item = PlanMyStuff::ProjectItem.create!(issue, project_number: number)
|
|
122
|
-
PlanMyStuff::Pipeline.take!(project_item, user:
|
|
131
|
+
PlanMyStuff::Pipeline.take!(project_item, user: assignee_user)
|
|
123
132
|
end
|
|
124
133
|
|
|
125
134
|
# Removes the issue from the pipeline project when the LAST assignee is removed. If any assignees remain,
|
|
@@ -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
|
# --------------------------------------------------------------------------
|
|
@@ -91,7 +91,7 @@ module PlanMyStuff
|
|
|
91
91
|
cache_writer: :write_comment,
|
|
92
92
|
)
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
issue.mark_responded!(resolved_user) unless skip_responded
|
|
95
95
|
|
|
96
96
|
comment = build(result, issue: issue)
|
|
97
97
|
PlanMyStuff::Notifications.instrument('comment_created', comment, user: resolved_user)
|
|
@@ -218,29 +218,6 @@ module PlanMyStuff
|
|
|
218
218
|
:internal
|
|
219
219
|
end
|
|
220
220
|
|
|
221
|
-
# Sets responded_at on the issue metadata if this is the first support comment and the issue hasn't been
|
|
222
|
-
# responded to yet.
|
|
223
|
-
#
|
|
224
|
-
# @param issue [PlanMyStuff::Issue] parent issue
|
|
225
|
-
# @param user [Object, nil] resolved user object
|
|
226
|
-
#
|
|
227
|
-
# @return [void]
|
|
228
|
-
#
|
|
229
|
-
def mark_issue_responded_if_first_support_comment!(issue, user)
|
|
230
|
-
return if user.nil?
|
|
231
|
-
|
|
232
|
-
return unless PlanMyStuff::UserResolver.support?(user)
|
|
233
|
-
return unless issue.pms_issue?
|
|
234
|
-
|
|
235
|
-
return if issue.metadata.responded?
|
|
236
|
-
|
|
237
|
-
PlanMyStuff::Issue.update!(
|
|
238
|
-
number: issue.number,
|
|
239
|
-
repo: issue.repo,
|
|
240
|
-
metadata: { responded_at: PlanMyStuff.format_time(Time.now.utc) },
|
|
241
|
-
)
|
|
242
|
-
end
|
|
243
|
-
|
|
244
221
|
# Mutates issue waiting state based on the comment's author. Support users with +waiting_on_reply: true+ enter
|
|
245
222
|
# the issue into waiting-on-user state. Non-support users clear any active waiting-on-user state and
|
|
246
223
|
# auto-reopen issues that were closed by the inactivity sweep.
|
|
@@ -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 }
|
data/lib/plan_my_stuff/issue.rb
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
@@ -879,6 +886,30 @@ module PlanMyStuff
|
|
|
879
886
|
save!(user: user, skip_notification: skip_notification)
|
|
880
887
|
end
|
|
881
888
|
|
|
889
|
+
# Stamps +metadata.responded_at+ on the first support-user engagement with this issue. Centralizes the guards so
|
|
890
|
+
# every engagement path (first support comment, +Pipeline.take!+, self-assign webhook) can funnel through one
|
|
891
|
+
# method. No-ops unless +user+ resolves to a support user on a PMS issue that hasn't been responded to yet.
|
|
892
|
+
#
|
|
893
|
+
# @param user [Object, nil] actor engaging with the issue (resolved via +PlanMyStuff::UserResolver+)
|
|
894
|
+
#
|
|
895
|
+
# @return [void]
|
|
896
|
+
#
|
|
897
|
+
def mark_responded!(user)
|
|
898
|
+
resolved = PlanMyStuff::UserResolver.resolve(user)
|
|
899
|
+
return if resolved.blank?
|
|
900
|
+
|
|
901
|
+
return unless PlanMyStuff::UserResolver.support?(resolved)
|
|
902
|
+
return unless pms_issue?
|
|
903
|
+
|
|
904
|
+
return if metadata.responded?
|
|
905
|
+
|
|
906
|
+
self.class.update!(
|
|
907
|
+
number: number,
|
|
908
|
+
repo: repo,
|
|
909
|
+
metadata: { responded_at: PlanMyStuff.format_time(Time.now.utc) },
|
|
910
|
+
)
|
|
911
|
+
end
|
|
912
|
+
|
|
882
913
|
# Re-fetches this issue from GitHub and updates all local attributes.
|
|
883
914
|
#
|
|
884
915
|
# @return [self]
|
|
@@ -1028,7 +1059,13 @@ module PlanMyStuff
|
|
|
1028
1059
|
raise(PlanMyStuff::IssueFieldsNotEnabledError) unless PlanMyStuff.configuration.issue_fields_enabled
|
|
1029
1060
|
|
|
1030
1061
|
fields_by_name = PlanMyStuff::IssueField.list(org: repo.organization).index_by { |field| field.name.downcase }
|
|
1031
|
-
inputs = updates.map
|
|
1062
|
+
inputs = updates.map do |name, value|
|
|
1063
|
+
build_issue_field_input(
|
|
1064
|
+
fields_by_name,
|
|
1065
|
+
PlanMyStuff::IssueFieldTranslation.consumer_field_name(name),
|
|
1066
|
+
PlanMyStuff::IssueFieldTranslation.consumer_value(name, value),
|
|
1067
|
+
)
|
|
1068
|
+
end
|
|
1032
1069
|
|
|
1033
1070
|
PlanMyStuff.client.graphql(
|
|
1034
1071
|
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
|
|
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
|
|
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
|
|
|
@@ -150,7 +150,8 @@ module PlanMyStuff
|
|
|
150
150
|
locked_statuses.include?(project_item.status)
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
-
# Moves a project item to "Started".
|
|
153
|
+
# Moves a project item to "Started". When +user+ is a support user, also stamps +metadata.responded_at+ on the
|
|
154
|
+
# issue via +Issue#mark_responded!+ (a no-op if it's already responded to / not a PMS issue).
|
|
154
155
|
#
|
|
155
156
|
# @param project_item [PlanMyStuff::ProjectItem]
|
|
156
157
|
# @param user [Object, nil] actor forwarded to the +pipeline_started.plan_my_stuff+ payload
|
|
@@ -162,6 +163,8 @@ module PlanMyStuff
|
|
|
162
163
|
status = resolve_status_name(PlanMyStuff::Pipeline::Status::STARTED)
|
|
163
164
|
result = project_item.move_to!(status)
|
|
164
165
|
|
|
166
|
+
project_item.issue.mark_responded!(user) if user.present?
|
|
167
|
+
|
|
165
168
|
instrument(PlanMyStuff::Pipeline::Status::STARTED, project_item, user: user)
|
|
166
169
|
result
|
|
167
170
|
end
|
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.
|
|
4
|
+
version: 0.27.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-
|
|
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
|