mimimmimimi

This commit is contained in:
24c02 2026-01-30 15:05:32 -05:00
parent bb2bf05e57
commit 228a149880
4 changed files with 13 additions and 28 deletions

View file

@ -109,20 +109,14 @@ class Components::Admin::Users::Show < Components::Base
input(type: "hidden", name: "_method", value: "patch")
input(type: "hidden", name: "authenticity_token", value: helpers.form_authenticity_token)
render(Primer::Alpha::SelectPanel.new(
select_variant: :single,
fetch_strategy: :local,
dynamic_label: true,
dynamic_label_prefix: "Quota Policy",
form_arguments: { name: "user[quota_policy]" }
)) do |panel|
panel.with_show_button(scheme: :secondary, size: :small) { current_quota_label }
panel.with_item(label: "Auto-detect (via HCA)", content_arguments: { data: { value: "" } }, active: @user.quota_policy.nil?)
panel.with_item(label: "Verified", content_arguments: { data: { value: "verified" } }, active: @user.quota_policy == "verified")
panel.with_item(label: "Functionally Unlimited", content_arguments: { data: { value: "functionally_unlimited" } }, active: @user.quota_policy == "functionally_unlimited")
select(name: "user[quota_policy]", class: "form-select", style: "width: auto;") do
option(value: "", selected: @user.quota_policy.nil?) { "Auto-detect (via HCA)" }
Quota::ADMIN_ASSIGNABLE.each do |slug|
option(value: slug.to_s, selected: @user.quota_policy == slug.to_s) { slug.to_s.humanize }
end
end
button(type: "submit", class: "btn btn-sm btn-primary") { "Set Policy" }
button(type: "submit", class: "btn btn-sm btn-primary") { "Update" }
end
end
end
@ -140,17 +134,6 @@ class Components::Admin::Users::Show < Components::Base
end
end
def current_quota_label
case @user.quota_policy&.to_sym
when :functionally_unlimited
"Functionally Unlimited"
when :verified
"Verified"
else
"Auto-detect (via HCA)"
end
end
def progress_bar_color(percentage)
if percentage >= 100
"var(--bgColor-danger-emphasis)"

View file

@ -24,10 +24,9 @@ module Admin
end
def user_params
params.require(:user).permit(:quota_policy).tap do |p|
# Normalize empty string to nil for auto-detect
p[:quota_policy] = nil if p[:quota_policy].blank?
end
permitted = params.fetch(:user, params).permit(:quota_policy)
permitted[:quota_policy] = nil if permitted[:quota_policy].blank?
permitted
end
end
end

View file

@ -4,8 +4,10 @@ class Quota
ALL_POLICIES = [
Policy[:unverified, 10.megabytes, 50.megabytes],
Policy[:verified, 50.megabytes, 50.gigabytes],
Policy[:functionally_unlimited, 200.megabytes, 300.gigabytes]
Policy[:functionally_unlimited, 500.megabytes, 300.gigabytes]
].index_by &:slug
ADMIN_ASSIGNABLE = %i[verified functionally_unlimited].freeze
def self.policy(slug) = ALL_POLICIES.fetch slug
end

View file

@ -13,6 +13,7 @@ class User < ApplicationRecord
scope :admins, -> { where(is_admin: true) }
validates :hca_id, presence: true, uniqueness: true
validates :quota_policy, inclusion: { in: Quota::ADMIN_ASSIGNABLE.map(&:to_s) }, allow_nil: true
encrypts :hca_access_token
has_many :uploads, dependent: :destroy