Fix ci minutes stats colouring on admin pages
What does this MR do and why?
The change is really simple and straightforward. But has a huge footprint.
Previously css classes for admin Group and User views for CI minutes were provided under a .card
selector. That selector is no longer in place. This MR applies those classes directly. So the only visible change in this MR is a change of colours on the Group and User admin views.
maintenancerefactor part: this MR also separates out the presentation data fed to Usage Quota / Pipelines JS (monthly_minutes_used
, monthly_minutes_limit_text
— fed to ee/app/helpers/ee/namespaces_helper.rb
) from the labels used on the admin views (monthly_minutes_label
displayed on ee/app/views/namespaces/_shared_runner_status.html.haml
). This would allow us to handle disabled and unlimited states more freely on the Usage Quota / Pipelines.
Please, see the screenshots section for an extensive set of states on the 4 pages where the data is displayed.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
NOTE: the only change should be in colouring of the CI minutes rows in the admin Group and User pages.
Before | After |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Over quota
diff
diff --git a/ee/app/models/ci/minutes/quota.rb b/ee/app/models/ci/minutes/quota.rb
index 0eea54f2786f..56cf852e51ac 100644
--- a/ee/app/models/ci/minutes/quota.rb
+++ b/ee/app/models/ci/minutes/quota.rb
@@ -20,6 +20,7 @@ def total
end
def monthly
+ return 10
(namespace.shared_runners_minutes_limit || ::Gitlab::CurrentSettings.shared_runners_minutes).to_i
end
strong_memoize_attr :monthly
diff --git a/ee/app/models/ci/minutes/usage.rb b/ee/app/models/ci/minutes/usage.rb
index 8f1775082f71..58bc41d13c76 100644
--- a/ee/app/models/ci/minutes/usage.rb
+++ b/ee/app/models/ci/minutes/usage.rb
@@ -35,6 +35,7 @@ def current_balance
end
def total_minutes_used
+ return 11
current_usage.amount_used.to_i
end
Before | After |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
With purchased minutes
diff
diff --git a/ee/app/models/ci/minutes/quota.rb b/ee/app/models/ci/minutes/quota.rb
index 0eea54f2786f..44573bc50ea9 100644
--- a/ee/app/models/ci/minutes/quota.rb
+++ b/ee/app/models/ci/minutes/quota.rb
@@ -20,11 +20,13 @@ def total
end
def monthly
+ return 10
(namespace.shared_runners_minutes_limit || ::Gitlab::CurrentSettings.shared_runners_minutes).to_i
end
strong_memoize_attr :monthly
def purchased
+ return 10
namespace.extra_shared_runners_minutes_limit.to_i
end
strong_memoize_attr :purchased
diff --git a/ee/app/models/ci/minutes/usage.rb b/ee/app/models/ci/minutes/usage.rb
index 8f1775082f71..29e855e6b328 100644
--- a/ee/app/models/ci/minutes/usage.rb
+++ b/ee/app/models/ci/minutes/usage.rb
@@ -35,6 +35,7 @@ def current_balance
end
def total_minutes_used
+ return 15
current_usage.amount_used.to_i
end
Before | After |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Disabled
diff
diff --git a/ee/app/models/ee/namespace.rb b/ee/app/models/ee/namespace.rb
index 0a7af285c80c..82b2d285b62d 100644
--- a/ee/app/models/ee/namespace.rb
+++ b/ee/app/models/ee/namespace.rb
@@ -401,6 +401,7 @@ def shared_runners_minutes_limit_enabled?
end
def any_project_with_shared_runners_enabled?
+ return false
Rails.cache.fetch([self, :has_project_with_shared_runners_enabled], expires_in: 5.minutes) do
any_project_with_shared_runners_enabled_with_cte?
end
header | header |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Unlimited
diff
diff --git a/ee/app/models/ci/minutes/quota.rb b/ee/app/models/ci/minutes/quota.rb
index 0eea54f2786f..ab25efce5ded 100644
--- a/ee/app/models/ci/minutes/quota.rb
+++ b/ee/app/models/ci/minutes/quota.rb
@@ -20,6 +20,7 @@ def total
end
def monthly
+ return 0
(namespace.shared_runners_minutes_limit || ::Gitlab::CurrentSettings.shared_runners_minutes).to_i
end
strong_memoize_attr :monthly
Before | After |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
How to set up and validate locally
-
Open the following pages:
- group > settings > usage quotas / pipelines (http://localhost:3000/groups/gitlab-org/-/usage_quotas#pipelines-quota-tab)
- profile > preferences > usage quotas / pipelines (http://localhost:3000/-/profile/usage_quotas)
- admin > users > user (http://localhost:3000/admin/users/root)
- admin > groups > group (http://localhost:3000/admin/groups/gitlab-org)
-
Apply the diffs in the screenshots sections to reproduce relevant state