Skip to content

Commit fc16e3a

Browse files
Merge branch 'main' into make-wise-generally-available
2 parents 346b53e + af55874 commit fc16e3a

File tree

8 files changed

+85
-141
lines changed

8 files changed

+85
-141
lines changed

app/controllers/features_controller.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,9 @@
22

33
class FeaturesController < ApplicationController
44
FEATURES = { # the keys are current feature flags, the values are emojis that show when-enabled.
5-
receipt_bin_2023_04_07: %w[🧾 🗑️ 💰],
6-
sms_receipt_notifications_2022_11_23: %w[📱 🧾 🔔 💬],
75
hcb_code_popovers_2023_06_16: nil,
86
transactions_background_2024_06_05: %w[🌈 🔴 🟢],
9-
rename_on_homepage_2023_12_06: %w[🖊️ ⌨️],
10-
command_bar_2024_02_05: %w[🔍 🔎 💸],
11-
user_permissions_2024_03_09: %w[📛 🧑‍💼 🪪 🎉],
12-
recently_on_hcb_2024_05_23: %w[👀 🤑 🙈],
13-
spending_controls_2024_06_03: %w[ 💷],
14-
two_factor_authentication_2024_05_22: %w[🔒],
15-
totp_2024_06_13: %w[🔒 ],
167
event_home_page_redesign_2024_09_21: %w[🏠 📊 📉 💸],
17-
card_logos_2024_08_27: %w[🌈 💳 📸],
18-
donation_tiers_2025_06_24: %w[💖 🥇 🥈 🥉],
198
sudo_mode_2015_07_21: %w[🔐 🔒 🔑 🔓]
209
}.freeze
2110

@@ -43,18 +32,6 @@ def disable_feature
4332

4433
if FEATURES.key?(@feature.to_sym) || admin_signed_in?
4534
if Flipper.disable_actor(@feature, @actor)
46-
# If it's the user permissions feature, make all the users & invites in the org managers.
47-
if @feature == "user_permissions_2024_03_09" && @actor.is_a?(Event)
48-
# Disable all spending controls
49-
@actor.organizer_positions.each { |op| op.active_spending_control&.deactivate }
50-
Flipper.disable_actor("spending_controls_2024_06_03", @actor)
51-
52-
@actor.organizer_positions.update_all(role: :manager)
53-
@actor.organizer_position_invites.pending.update_all(role: :manager)
54-
elsif @feature == "spending_controls_2024_06_03" && @actor.is_a?(Event)
55-
# Disable all controls
56-
@actor.organizer_positions.each { |op| op.active_spending_control&.deactivate }
57-
end
5835
flash[:success] = "You've opted out of this beta; please let us know if you had any feedback."
5936
else
6037
flash[:error] = "Error while opting out of this beta. Please contact us or try again."

app/policies/organizer_position/spending/control_policy.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ class OrganizerPosition
44
module Spending
55
class ControlPolicy < ApplicationPolicy
66
def index?
7-
return unless enabled?
8-
97
user.auditor? || (
108
current_user_manager? || own_control?
119
)
1210
end
1311

1412
def create?
15-
return unless enabled?
16-
1713
user.admin? || (
1814
current_user_manager? &&
1915
!record.organizer_position.manager?
@@ -24,11 +20,7 @@ def create?
2420
end
2521

2622
def destroy?
27-
return unless enabled?
28-
29-
user.admin? ||
30-
current_user_manager?
31-
23+
user.admin? || current_user_manager?
3224
end
3325

3426
private
@@ -41,10 +33,6 @@ def own_control?
4133
user == record.organizer_position.user
4234
end
4335

44-
def enabled?
45-
Flipper.enabled?(:spending_controls_2024_06_03, record.organizer_position.event)
46-
end
47-
4836
end
4937
end
5038

app/views/events/settings/_donations.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,5 @@
115115
</div>
116116
<% end %>
117117

118-
<% if Flipper.enabled?(:donation_tiers_2025_06_24, event) %>
119-
<%= render "events/settings/donation_tiers", event:, frame: %>
120-
<% end %>
118+
<%= render "events/settings/donation_tiers", event:, frame: %>
121119
<% end %>

app/views/events/settings/_features.html.erb

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,41 @@
99
event:
1010
} if Flipper.enabled?(:event_home_page_redesign_2024_09_21, event) %>
1111

12-
<%= render partial: "features/preview", locals: {
13-
id: "card-logo",
14-
classes: ["feature-generic"],
15-
feature_flag: :card_logos_2024_08_27,
16-
name: "HCB Card Logo",
17-
description: "Add a custom logo to every HCB card printed for your organization.",
18-
event:
19-
} %>
20-
21-
<%= render partial: "features/preview", locals: {
22-
id: "transaction-tags",
23-
classes: ["feature-transaction-tags"],
24-
feature_flag: :transaction_tags_2022_07_29,
25-
name: "Transaction Tags",
26-
description: "Categorize and filter transactions using tags!",
27-
event:
28-
} %>
29-
30-
<% active_spending_control_count = event.organizer_positions.map(&:active_spending_control).compact.count %>
31-
<%= render partial: "features/preview", locals: {
32-
id: "spending-controls",
33-
classes: ["feature-spending-controls", "feature-generic"],
34-
feature_flag: :spending_controls_2024_06_03,
35-
name: "Spending Controls",
36-
description: content_tag(:span) do
37-
concat "Control your members' spending with preauthorized card limits!"
38-
end,
39-
event:,
40-
disable_warning: active_spending_control_count > 0 ? "⚠️ #{active_spending_control_count} users have spending controls in place ⚠️\n\nAre you sure you want to disable this feature?" : nil
41-
42-
} %>
43-
4412
<details>
4513
<summary class="mb2">Past feature previews</summary>
14+
4615
<%= render partial: "features/preview", locals: {
4716
id: "donation-tiers",
4817
classes: ["feature-generic"],
4918
feature_flag: :donation_tiers_2025_06_24,
50-
name: "Donation Tiers",
5119
fully_shipped: true,
20+
name: "Donation Tiers",
5221
description: "Offer preset monthly donation options with custom names, prices, and perks.",
5322
event:
5423
} %>
5524

25+
<%= render partial: "features/preview", locals: {
26+
id: "card-logo",
27+
classes: ["feature-generic"],
28+
fully_shipped: true,
29+
name: "HCB Card Logo",
30+
feature_flag: :card_logos_2024_08_27,
31+
description: "Add a custom logo to every HCB card printed for your organization.",
32+
event:
33+
} %>
34+
35+
<%= render partial: "features/preview", locals: {
36+
id: "spending-controls",
37+
classes: ["feature-spending-controls", "feature-generic"],
38+
fully_shipped: true,
39+
name: "Spending Controls",
40+
feature_flag: :spending_controls_2024_06_03,
41+
description: content_tag(:span) do
42+
concat "Control your members' spending with preauthorized card limits!"
43+
end,
44+
event:
45+
} %>
46+
5647
<%= render partial: "features/preview", locals: {
5748
id: "transaction-tags",
5849
classes: ["feature-transaction-tags"],

app/views/organizer_position_invites/_role_and_control_form.html.erb

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,26 @@
2525

2626
<p class="muted mb1"><span class="bold info">Readers</span> have read-only access to the organization.</p>
2727

28-
<% if Flipper.enabled?(:spending_controls_2024_06_03, @event || invite.event) %>
29-
<div x-show="role === 'member'" x-cloak x-transition.duration.500ms class="my-4">
30-
<%= form.label :enable_controls, class: "mb1 inline-flex flex-col" do %>
31-
Enable spending controls?
32-
<span class="muted h6">You can always enable & configure spending controls after, too.</span>
28+
<div x-show="role === 'member'" x-cloak x-transition.duration.500ms class="my-4">
29+
<%= form.label :enable_controls, class: "mb1 inline-flex flex-col" do %>
30+
Enable spending controls?
31+
<span class="muted h6">You can always enable & configure spending controls after, too.</span>
32+
<% end %>
33+
34+
<div class="field field--options">
35+
<%= form.radio_button :enable_controls, false, "x-model": "spendingControls" %>
36+
<%= form.label :enable_controls, value: false do %>
37+
<strong>No</strong>
38+
<% end %>
39+
40+
<%= form.radio_button :enable_controls, true, "x-model": "spendingControls" %>
41+
<%= form.label :enable_controls, value: true do %>
42+
<strong>Yes</strong>
3343
<% end %>
44+
</div>
3445

35-
<div class="field field--options">
36-
<%= form.radio_button :enable_controls, false, "x-model": "spendingControls" %>
37-
<%= form.label :enable_controls, value: false do %>
38-
<strong>No</strong>
39-
<% end %>
40-
41-
<%= form.radio_button :enable_controls, true, "x-model": "spendingControls" %>
42-
<%= form.label :enable_controls, value: true do %>
43-
<strong>Yes</strong>
44-
<% end %>
45-
</div>
46-
47-
<div x-show="spendingControls === 'true'" x-cloak x-transition.duration.500ms class="mb1">
48-
<%= form.label :initial_control_allowance_amount, value: "Initial allowance amount" %>
49-
<%= form.number_field :initial_control_allowance_amount, placeholder: "500.00", step: 0.01, min: 0.00, data: { controller: "truncate-decimal", action: "truncate-decimal#truncate blur->truncate-decimal#pad" } %>
50-
</div>
46+
<div x-show="spendingControls === 'true'" x-cloak x-transition.duration.500ms class="mb1">
47+
<%= form.label :initial_control_allowance_amount, value: "Initial allowance amount" %>
48+
<%= form.number_field :initial_control_allowance_amount, placeholder: "500.00", step: 0.01, min: 0.00, data: { controller: "truncate-decimal", action: "truncate-decimal#truncate blur->truncate-decimal#pad" } %>
5149
</div>
52-
<% end %>
50+
</div>

app/views/organizer_positions/_organizer_position.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</div>
4545
<% end %>
4646
<% end %>
47-
<% if policy(organizer_position).view_allowances? && Flipper.enabled?(:spending_controls_2024_06_03, @event) %>
47+
<% if policy(organizer_position).view_allowances? %>
4848
<%= pop_icon_to "payment", event_organizer_position_spending_controls_path(organizer_position_id: organizer_position), data: { turbo: false } %>
4949
<% end %>
5050
<% if organizer_position.organizer_position_deletion_requests.under_review.exists? %>

app/views/organizer_positions/_organizer_position_row.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</div>
8484
<% end %>
8585
<% end %>
86-
<% if policy(organizer_position).view_allowances? && Flipper.enabled?(:spending_controls_2024_06_03, @event) %>
86+
<% if policy(organizer_position).view_allowances? %>
8787
<%= pop_icon_to "payment", event_organizer_position_spending_controls_path(organizer_position_id: organizer_position) %>
8888
<% end %>
8989
<% if policy(organizer_position).destroy? %>

app/views/users/edit.html.erb

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -119,46 +119,39 @@
119119
</div>
120120
</div>
121121
<% else %>
122-
123122
<% title "Account Settings" %>
124123
<% page_md %>
124+
<% disabled = !policy(@user).update? %>
125+
125126
<%= render "users/nav", selected: :settings %>
126127
<h1>Settings</h1>
127128
<turbo-frame id="settings" autoscroll data-autoscroll-behavior="smooth">
128129
<%= render "settings_nav", active: "general" unless @onboarding %>
129130
<section>
130-
<% if @onboarding %>
131-
<p>Complete your profile to get started.</p>
132-
<% end %>
133131
<%= form_with(model: @user, local: true, html: { onsubmit: "onSubmit()" }, data: { turbo_frame: "_top" }) do |form| %>
134132
<%= form_errors @user, "profile", "We couldn't update your" %>
135133
<% if current_season(override_preference: true) %>
136134
<div class="field field--checkbox">
137-
<%= form.check_box :seasonal_themes_enabled %>
135+
<%= form.check_box :seasonal_themes_enabled, disabled: %>
138136
<%= form.label :seasonal_themes_enabled, "#{by_season "✨", override_preference: true, fall: "🎃", winter: "🎄"} Enable #{current_season(override_preference: true)} theme", class: "h3 bold" %>
139137
</div>
140138
<% end %>
141139

142140
<div class="field">
143141
<%= form.label :full_name %>
144-
<%= form.text_field :full_name, required: true, placeholder: "Fiona Hackworth III", pattern: '^\S+.+' %>
142+
<%= form.text_field :full_name, required: true, placeholder: "Fiona Hackworth III", pattern: '^\S+.+', disabled: %>
145143
<% @user.errors.full_messages_for(:full_name).each do |message| %>
146144
<div class="primary"><%= message %></div>
147145
<% end %>
148146
</div>
149147
<div class="field">
150148
<%= form.label :preferred_name %>
151149
<p class="h5 muted mt0 mb1">If you go by a different name.</p>
152-
<%= form.text_field :preferred_name, placeholder: @user.full_name.presence || "FiFi Hacks", maxlength: 30 %>
150+
<%= form.text_field :preferred_name, placeholder: @user.full_name.presence || "FiFi Hacks", maxlength: 30, disabled: %>
153151
</div>
154152

155153
<div class="field">
156154
<%= form.label :phone_number, "Mobile phone number" %>
157-
<% if @onboarding %>
158-
<p class="h5 muted mt0 mb1">
159-
To contact you on short notice.
160-
</p>
161-
<% end %>
162155
<% if @user.use_sms_auth %>
163156
<p class="h5 muted mt0 mb1">
164157
Changing your number will turn off SMS login codes.
@@ -183,17 +176,18 @@
183176
start_year: Date.today.year,
184177
end_year: Date.today.year - 100,
185178
order: [:month, :day, :year],
186-
prompt: @user.birthday.nil? %>
179+
prompt: @user.birthday.nil?,
180+
disabled: %>
187181
<% unless @user.birthday.nil? %>
188182
<% admin_tool do %>
189-
<%= @user.birthday > 19.years.ago ? "✅ Teenager" : "Not a teenager" %>
183+
<%= @user.teenager? ? "✅ Teenager" : "Not a teenager" %>
190184
<% end %>
191185
<% end %>
192186
</div>
193187
</div>
194188
<div class="field">
195189
<%= form.label :email %>
196-
<%= form.email_field :email %>
190+
<%= form.email_field :email, disabled: %>
197191
<% if @user.email_updates.active.any? %>
198192
<p style="max-width: 420px;">
199193
<small>
@@ -221,44 +215,42 @@
221215
</p>
222216
<div class="field field--fileupload">
223217
<%= form.label :profile_picture, "Upload picture", class: "field--fileupload__label" %>
224-
<%= form.file_field :profile_picture, accept: "image/png, image/jpeg", class: "field--fileupload__field" %>
218+
<%= form.file_field :profile_picture, accept: "image/png, image/jpeg", class: "field--fileupload__field", disabled: %>
225219
</div>
226220
</div>
227221

228-
<% unless @onboarding %>
229-
<% if @user.has_discord_account? %>
230-
<div class="card max-w-6xl">
231-
<p class="medium">Connected Discord account</p>
232-
<p class="h5 muted mt-0 mb-3">
233-
You've set up the HCB discord bot
234-
</p>
235-
<p>@<%= @user.discord_account.username %></p>
236-
</div>
237-
<% end %>
238-
239-
<fieldset>
240-
<legend class="medium">Share usage data with HCB</legend>
222+
<% if @user.has_discord_account? %>
223+
<div class="card max-w-6xl">
224+
<p class="medium">Connected Discord account</p>
241225
<p class="h5 muted mt-0 mb-3">
242-
Help us improve HCB by sending usage data.
243-
Off by default.
226+
You've set up the HCB discord bot
244227
</p>
245-
<div class="field field--options">
246-
<%= form.radio_button :sessions_reported, true %>
247-
<%= form.label :sessions_reported, value: true do %>
248-
<%= inline_icon "support", size: 28 %>
249-
<strong>Sure thing!</strong>
250-
<% end %>
251-
<%= form.radio_button :sessions_reported, false %>
252-
<%= form.label :sessions_reported, value: false do %>
253-
<%= inline_icon "thumbsdown", size: 28 %>
254-
<strong>No thanks</strong>
255-
<% end %>
256-
</div>
257-
</fieldset>
228+
<p>@<%= @user.discord_account.username %></p>
229+
</div>
258230
<% end %>
259231

232+
<fieldset>
233+
<legend class="medium">Share usage data with HCB</legend>
234+
<p class="h5 muted mt-0 mb-3">
235+
Help us improve HCB by sending usage data.
236+
Off by default.
237+
</p>
238+
<div class="field field--options">
239+
<%= form.radio_button :sessions_reported, true, disabled: %>
240+
<%= form.label :sessions_reported, value: true do %>
241+
<%= inline_icon "support", size: 28 %>
242+
<strong>Sure thing!</strong>
243+
<% end %>
244+
<%= form.radio_button :sessions_reported, false, disabled: %>
245+
<%= form.label :sessions_reported, value: false do %>
246+
<%= inline_icon "thumbsdown", size: 28 %>
247+
<strong>No thanks</strong>
248+
<% end %>
249+
</div>
250+
</fieldset>
251+
260252
<div class="actions flex">
261-
<%= form.submit @onboarding ? "Start using HCB" : "Save settings" %>
253+
<%= form.submit "Save settings", disabled: %>
262254
</div>
263255
<% end %>
264256
<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.13/js/intlTelInput.min.js" integrity="sha512-QMUqEPmhXq1f3DnAVdXvu40C8nbTgxvBGvNruP6RFacy3zWKbNTmx7rdQVVM2gkd2auCWhlPYtcW2tHwzso4SA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

0 commit comments

Comments
 (0)