studio-engine 0.44.1 → 0.45.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/app/services/studio/email_preview_target.rb +40 -11
- data/lib/studio/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d2291a2d35bfd35a6f54666fd0e3590a9a59275e453cf5ff81ddd2af49717301
|
|
4
|
+
data.tar.gz: 5ca713c12be81b7353ebd98f281ef89017a02e6fd348e77d6468383e8d85a90d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d8bc026356b0f6e2e1d0b0781719960001dc7fd5bb629b6fd3e7e59a7d3b1ac298f94dc4b88941c709956f49368675089e507ace0851a6f234321f14b5868f07
|
|
7
|
+
data.tar.gz: cceface91adc12a32ad02246d67a58a93306fd44dce24a12ffd8a54a4350d840f52c8e7537634cddd524d0a5372d5ab4ff216fc6c9760bd725fc4a408ef11f55
|
|
@@ -67,14 +67,18 @@ module Studio
|
|
|
67
67
|
class << self
|
|
68
68
|
# Every target the page can offer, admin first.
|
|
69
69
|
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
70
|
+
# TWO REAL PEOPLE: the operator admin and an ordinary member.
|
|
71
|
+
#
|
|
72
|
+
# A third, SYNTHETIC "No name on file" entry used to be appended here so
|
|
73
|
+
# the name-free fallback header could be previewed. Mr. McRitchie asked for
|
|
74
|
+
# the list to be just the two, knowing what it costs: the "header for
|
|
75
|
+
# someone with no name on file" field stays in the editor and still ships
|
|
76
|
+
# to strangers, it simply cannot be previewed from this page any more.
|
|
77
|
+
# Do not quietly re-add the sample to make that field previewable — if
|
|
78
|
+
# that needs solving, solve it somewhere this decision is not reversed by
|
|
79
|
+
# accident.
|
|
76
80
|
def all
|
|
77
|
-
[find_admin, find_member
|
|
81
|
+
[find_admin, find_member].compact.uniq(&:id)
|
|
78
82
|
end
|
|
79
83
|
|
|
80
84
|
# The one to preview as. Falls back to the first available rather than
|
|
@@ -123,16 +127,41 @@ module Studio
|
|
|
123
127
|
# `admin` may be a column, a method, or absent entirely. Only the column
|
|
124
128
|
# can be queried; anything else is filtered in Ruby over a bounded slice,
|
|
125
129
|
# because a preview must not table-scan a production users table.
|
|
130
|
+
# THE HOUSE STANDARD, preferred over whoever happens to sort first. Every
|
|
131
|
+
# McRitchie app seeds an "alex" admin and a "mack" member, and without a
|
|
132
|
+
# preference this offered whatever the id order gave: McRitchie Studio
|
|
133
|
+
# showed team@ instead of alex@, and turf-monster showed a test-fixture
|
|
134
|
+
# row (jordan@) instead of Mack.
|
|
135
|
+
#
|
|
136
|
+
# Matched on the email LOCAL PART, so an app's own-domain admin counts too
|
|
137
|
+
# — alex@turfmonster.media and alex@mcritchie.industries are the same
|
|
138
|
+
# person as alex@mcritchie.studio for this purpose.
|
|
139
|
+
#
|
|
140
|
+
# Preference only. An app that seeds neither still gets its first admin
|
|
141
|
+
# and first member, which is what this did before.
|
|
142
|
+
PREFERRED_ADMIN_LOCAL = "alex"
|
|
143
|
+
PREFERRED_MEMBER_LOCAL = "mack"
|
|
144
|
+
|
|
145
|
+
def local_part(record) = record.try(:email).to_s.split("@").first.to_s.downcase
|
|
146
|
+
|
|
147
|
+
def prefer(candidates, local)
|
|
148
|
+
candidates.detect { |user| local_part(user) == local } || candidates.first
|
|
149
|
+
end
|
|
150
|
+
|
|
126
151
|
def admins(model)
|
|
127
|
-
|
|
152
|
+
if model.column_names.include?("admin")
|
|
153
|
+
return prefer(model.where(admin: true).limit(50).to_a, PREFERRED_ADMIN_LOCAL)
|
|
154
|
+
end
|
|
128
155
|
|
|
129
|
-
model.limit(50).
|
|
156
|
+
prefer(model.limit(50).select { |user| user.try(:admin?) }, PREFERRED_ADMIN_LOCAL)
|
|
130
157
|
end
|
|
131
158
|
|
|
132
159
|
def members(model)
|
|
133
|
-
|
|
160
|
+
if model.column_names.include?("admin")
|
|
161
|
+
return prefer(model.where(admin: [ false, nil ]).limit(50).to_a, PREFERRED_MEMBER_LOCAL)
|
|
162
|
+
end
|
|
134
163
|
|
|
135
|
-
model.limit(50).
|
|
164
|
+
prefer(model.limit(50).reject { |user| user.try(:admin?) }, PREFERRED_MEMBER_LOCAL)
|
|
136
165
|
end
|
|
137
166
|
|
|
138
167
|
def from_record(record, id_prefix:, label:, admin:)
|
data/lib/studio/version.rb
CHANGED