Commit 263ab502 authored by Alper Akgun's avatar Alper Akgun

Refactor can_admin_namespace ability allowed

parent d6e64fd9
......@@ -148,15 +148,17 @@ module EE
extend ActiveSupport::Concern
prepended do
can_admin_namespace = ->(namespace, opts) { ::Ability.allowed?(opts[:current_user], :admin_namespace, namespace) }
expose :shared_runners_minutes_limit, if: ->(_, options) { options[:current_user]&.admin? }
expose :extra_shared_runners_minutes_limit, if: ->(_, options) { options[:current_user]&.admin? }
expose :billable_members_count do |namespace, options|
namespace.billable_members_count(options[:requested_hosted_plan])
end
expose :plan, if: ->(namespace, opts) { ::Ability.allowed?(opts[:current_user], :admin_namespace, namespace) } do |namespace, _|
expose :plan, if: can_admin_namespace do |namespace, _|
namespace.actual_plan_name
end
expose :trial_ends_on, if: ->(namespace, opts) { ::Ability.allowed?(opts[:current_user], :admin_namespace, namespace) } do |namespace, _|
expose :trial_ends_on, if: can_admin_namespace do |namespace, _|
namespace.trial_ends_on
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment