Commit 3c580a7e authored by nicolasdular's avatar nicolasdular

Replace pipeline quota with usage quota

Replaces the pipeline quota page with a usage quota page for
user namespaces. With that change users will also be able to see
their storage usage.
parent cbd70dcf
......@@ -360,7 +360,6 @@ linters:
- "ee/app/views/notify/send_unsubscribed_notification.html.haml"
- "ee/app/views/notify/unapproved_merge_request_email.html.haml"
- "ee/app/views/oauth/geo_auth/error.html.haml"
- "ee/app/views/profiles/pipeline_quota/index.haml"
- "ee/app/views/projects/commits/_mirror_status.html.haml"
- "ee/app/views/projects/jobs/_shared_runner_limit_warning.html.haml"
- "ee/app/views/projects/merge_requests/_approvals_count.html.haml"
......
......@@ -152,10 +152,6 @@
= link_to audit_log_profile_path do
%strong.fly-out-top-item-name
= _('Authentication Log')
- if Feature.enabled?(:user_usage_quota)
= render_if_exists 'layouts/nav/sidebar/profile_usage_quotas_link'
- else
= render_if_exists 'layouts/nav/sidebar/profile_pipeline_quota_link'
= render 'shared/sidebar_toggle_button'
# frozen_string_literal: true
class Profiles::PipelineQuotaController < Profiles::ApplicationController
def index
return redirect_to(profile_usage_quotas_path) if Feature.enabled?(:user_usage_quota)
@namespace = current_user.namespace
@projects = @namespace.projects.with_shared_runners_limit_enabled.page(params[:page])
end
end
......@@ -2,8 +2,6 @@
class Profiles::UsageQuotasController < Profiles::ApplicationController
def index
return redirect_to(profile_pipeline_quota_path) if Feature.disabled?(:user_usage_quota)
@namespace = current_user.namespace
@projects = @namespace.projects.with_shared_runners_limit_enabled.page(params[:page])
end
......
- return unless show_buy_ci_minutes?(project, namespace)
%li
= link_to profile_pipeline_quota_path,
= link_to profile_usage_quotas_path,
class: 'ci-minutes-emoji js-buy-ci-minutes-link',
data: { 'track-event': 'click_buy_ci_minutes', 'track-label': current_user.namespace.actual_plan_name, 'track-property': 'user_dropdown' } do
= s_("CurrentUser|Buy CI minutes")
......
= nav_link(path: 'profiles#pipeline_quota') do
= link_to profile_pipeline_quota_path do
.nav-icon-container
= custom_icon('pipeline')
%span.nav-item-name
= _('Pipeline quota')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(path: 'profiles#pipeline_quota', html_options: { class: "fly-out-top-item" } ) do
= link_to profile_pipeline_quota_path do
%strong.fly-out-top-item-name
= _('Pipeline quota')
- page_title 'Personal pipelines quota'
- @content_class = "limit-container-width" unless fluid_layout
.user-settings-pipeline-quota.row
.profile-settings-sidebar.col-lg-3
%h4
Personal pipelines quota
= link_to icon('question-circle'), help_page_path("user/admin_area/settings/continuous_integration", anchor: "shared-runners-build-minutes-quota"), target: '_blank'
%p.light
Monthly build minutes usage across shared Runners
.col-lg-9
= render "namespaces/pipelines_quota/list",
locals: { namespace: @namespace, projects: @projects }
---
title: Replace pipeline quota with usage quotas for user namespaces
merge_request: 29806
author:
type: added
......@@ -8,7 +8,6 @@ resource :profile, only: [] do
end
end
resources :pipeline_quota, only: [:index]
resources :usage_quotas, only: [:index]
resources :billings, only: [:index]
end
......
# frozen_string_literal: true
require 'spec_helper'
describe Profiles::PipelineQuotaController do
let_it_be(:user) { create(:user) }
before do
sign_in(user)
end
describe 'GET index' do
context 'when feature flag user_usage_quota is enabled' do
it 'redirects to usage quota page' do
get :index
expect(subject).to redirect_to(profile_usage_quotas_path)
end
end
context 'when feature flag user_usage_quota is disabled' do
before do
stub_feature_flags(user_usage_quota: false)
end
it 'renders pipeline quota page' do
get :index
expect(subject).to render_template(:index)
end
end
end
end
......@@ -10,24 +10,10 @@ describe Profiles::UsageQuotasController do
end
describe 'GET index' do
context 'when feature flag user_usage_quota is disabled' do
before do
stub_feature_flags(user_usage_quota: false)
end
it 'renders usage quota page' do
get :index
it 'redirects to pipeline quota page' do
get :index
expect(subject).to redirect_to(profile_pipeline_quota_path)
end
end
context 'when feature flag user_usage_quota is enabled' do
it 'renders usage quota page' do
get :index
expect(subject).to render_template(:index)
end
expect(subject).to render_template(:index)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'Profile > Pipeline Quota' do
using RSpec::Parameterized::TableSyntax
let_it_be(:user, reload: true) { create(:user) }
let_it_be(:namespace, reload: true) { user.namespace }
let_it_be(:statistics, reload: true) { create(:namespace_statistics, namespace: namespace) }
let_it_be(:project, reload: true) { create(:project, namespace: namespace) }
let_it_be(:other_project) { create(:project, namespace: namespace, shared_runners_enabled: false) }
before do
gitlab_sign_in(user)
stub_feature_flags(user_usage_quota: false)
end
it 'is linked within the profile page' do
visit profile_path
page.within('.nav-sidebar') do
expect(page).to have_selector(:link_or_button, 'Pipeline quota')
end
end
describe 'shared runners use' do
where(:shared_runners_enabled, :used, :quota, :usage_class, :usage_text) do
false | 300 | 500 | 'success' | '300 / Unlimited minutes 0% used'
true | 300 | nil | 'success' | '300 / Unlimited minutes Unlimited'
true | 300 | 500 | 'success' | '300 / 500 minutes 60% used'
true | 1000 | 500 | 'danger' | '1000 / 500 minutes 200% used'
end
with_them do
let(:no_shared_runners_text) { 'Shared runners are disabled, so there are no limits set on pipeline usage' }
before do
project.update!(shared_runners_enabled: shared_runners_enabled)
statistics.update!(shared_runners_seconds: used.minutes.to_i)
namespace.update!(shared_runners_minutes_limit: quota)
visit profile_pipeline_quota_path
end
it 'shows the correct quota status' do
page.within('.pipeline-quota') do
expect(page).to have_content(usage_text)
expect(page).to have_selector(".bg-#{usage_class}")
end
end
it 'shows the correct per-project metrics' do
page.within('.pipeline-project-metrics') do
expect(page).not_to have_content(other_project.name)
if shared_runners_enabled
expect(page).to have_content(project.name)
expect(page).not_to have_content(no_shared_runners_text)
else
expect(page).not_to have_content(project.name)
expect(page).to have_content(no_shared_runners_text)
end
end
end
end
end
end
......@@ -14731,9 +14731,6 @@ msgstr ""
msgid "Pipeline minutes quota"
msgstr ""
msgid "Pipeline quota"
msgstr ""
msgid "Pipeline subscriptions"
msgstr ""
......
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