From 228a1498805fe4cc281d078f7a288cc6e5c10724 Mon Sep 17 00:00:00 2001 From: 24c02 <163450896+24c02@users.noreply.github.com> Date: Fri, 30 Jan 2026 15:05:32 -0500 Subject: [PATCH] mimimmimimi --- app/components/admin/users/show.rb | 29 +++++------------------ app/controllers/admin/users_controller.rb | 7 +++--- app/models/quota.rb | 4 +++- app/models/user.rb | 1 + 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/app/components/admin/users/show.rb b/app/components/admin/users/show.rb index ab27448..1b6c5df 100644 --- a/app/components/admin/users/show.rb +++ b/app/components/admin/users/show.rb @@ -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)" diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 8acc81e..e9d7e0c 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -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 diff --git a/app/models/quota.rb b/app/models/quota.rb index edaaae7..d27120a 100644 --- a/app/models/quota.rb +++ b/app/models/quota.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index d8e3044..43a933a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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