diff --git a/.rubocop_todo/layout/first_hash_element_indentation.yml b/.rubocop_todo/layout/first_hash_element_indentation.yml index 2f20d2ec239ef1587face8933fafc0106421bf28..e1ac4ccb650669fda03da60de9b6af3df83f676f 100644 --- a/.rubocop_todo/layout/first_hash_element_indentation.yml +++ b/.rubocop_todo/layout/first_hash_element_indentation.yml @@ -196,7 +196,6 @@ Layout/FirstHashElementIndentation: - 'ee/spec/requests/api/members_spec.rb' - 'ee/spec/requests/api/merge_requests_spec.rb' - 'ee/spec/requests/groups/group_members_controller_spec.rb' - - 'ee/spec/requests/groups/usage_quotas_spec.rb' - 'ee/spec/requests/projects/issue_feature_flags_controller_spec.rb' - 'ee/spec/serializers/issues/linked_issue_feature_flag_entity_spec.rb' - 'ee/spec/serializers/license_entity_spec.rb' diff --git a/.rubocop_todo/rspec/context_wording.yml b/.rubocop_todo/rspec/context_wording.yml index 7131626d15b51b1425b91ca5192abeac26943e00..5a01f22948246cad78d268d28913bdbf3822c70b 100644 --- a/.rubocop_todo/rspec/context_wording.yml +++ b/.rubocop_todo/rspec/context_wording.yml @@ -145,7 +145,6 @@ RSpec/ContextWording: - 'ee/spec/features/merge_requests/user_filters_by_approvers_spec.rb' - 'ee/spec/features/oncall_schedules/user_creates_schedule_spec.rb' - 'ee/spec/features/profiles/account_spec.rb' - - 'ee/spec/features/profiles/usage_quotas_spec.rb' - 'ee/spec/features/projects/active_tabs_spec.rb' - 'ee/spec/features/projects/audit_events_spec.rb' - 'ee/spec/features/projects/custom_projects_template_spec.rb' diff --git a/.rubocop_todo/rspec/empty_line_after_hook.yml b/.rubocop_todo/rspec/empty_line_after_hook.yml index 041eaa1a1a1018334939c898f8632db6a6846258..263fde8f38e5cc7a4bbf8cd32ccd7b1ffd673c34 100644 --- a/.rubocop_todo/rspec/empty_line_after_hook.yml +++ b/.rubocop_todo/rspec/empty_line_after_hook.yml @@ -5,7 +5,6 @@ RSpec/EmptyLineAfterHook: - 'ee/spec/controllers/projects/integrations/zentao/issues_controller_spec.rb' - 'ee/spec/controllers/projects/push_rules_controller_spec.rb' - 'ee/spec/features/issues/user_bulk_edits_issues_spec.rb' - - 'ee/spec/features/profiles/usage_quotas_spec.rb' - 'ee/spec/lib/ee/api/entities/user_with_admin_spec.rb' - 'ee/spec/lib/ee/gitlab/auth/ldap/sync/group_spec.rb' - 'ee/spec/lib/ee/gitlab/scim/provisioning_service_spec.rb' diff --git a/.rubocop_todo/style/class_and_module_children.yml b/.rubocop_todo/style/class_and_module_children.yml index 9b5f27229a4adf37d9691abeb4967a0e95db1614..c15095a7e726189d4ee891549bf1da3183202125 100644 --- a/.rubocop_todo/style/class_and_module_children.yml +++ b/.rubocop_todo/style/class_and_module_children.yml @@ -422,12 +422,10 @@ Style/ClassAndModuleChildren: - 'ee/app/controllers/groups/security/merge_commit_reports_controller.rb' - 'ee/app/controllers/groups/sso_controller.rb' - 'ee/app/controllers/groups/todos_controller.rb' - - 'ee/app/controllers/groups/usage_quotas_controller.rb' - 'ee/app/controllers/groups/wikis_controller.rb' - 'ee/app/controllers/oauth/geo_auth_controller.rb' - 'ee/app/controllers/profiles/billings_controller.rb' - 'ee/app/controllers/profiles/slacks_controller.rb' - - 'ee/app/controllers/profiles/usage_quotas_controller.rb' - 'ee/app/controllers/projects/analytics/issues_analytics_controller.rb' - 'ee/app/controllers/projects/analytics/merge_request_analytics_controller.rb' - 'ee/app/controllers/projects/approver_groups_controller.rb' diff --git a/ee/app/controllers/profiles/usage_quotas_controller.rb b/ee/app/controllers/profiles/usage_quotas_controller.rb index 7d16c067968d827750e3b6bbbef456581f51cf2a..ff99d6ddda32372c88e643c0136aff685e125dae 100644 --- a/ee/app/controllers/profiles/usage_quotas_controller.rb +++ b/ee/app/controllers/profiles/usage_quotas_controller.rb @@ -1,22 +1,24 @@ # frozen_string_literal: true -class Profiles::UsageQuotasController < Profiles::ApplicationController - include OneTrustCSP - include GoogleAnalyticsCSP +module Profiles + class UsageQuotasController < Profiles::ApplicationController + include OneTrustCSP + include GoogleAnalyticsCSP - feature_category :purchase - urgency :low + feature_category :purchase + urgency :low - before_action :push_feature_flags, only: :index + before_action :push_feature_flags, only: :index - def index - @hide_search_settings = true - @namespace = current_user.namespace - end + def index + @hide_search_settings = true + @namespace = current_user.namespace + end - private + private - def push_feature_flags - push_frontend_feature_flag(:gitlab_gtm_datalayer, type: :ops) + def push_feature_flags + push_frontend_feature_flag(:gitlab_gtm_datalayer, type: :ops) + end end end diff --git a/ee/app/views/namespaces/pipelines_quota/_ci_minutes_report.html.haml b/ee/app/views/namespaces/pipelines_quota/_ci_minutes_report.html.haml deleted file mode 100644 index c8926bb9348793b6df9a7e1f15ddc3a9036c443c..0000000000000000000000000000000000000000 --- a/ee/app/views/namespaces/pipelines_quota/_ci_minutes_report.html.haml +++ /dev/null @@ -1,38 +0,0 @@ -- namespace = locals.fetch(:namespace) -- minutes_usage = namespace.ci_minutes_usage -- minutes_usage_presenter = Ci::Minutes::UsagePresenter.new(minutes_usage) - -.pipeline-quota.container-fluid - .row - .col-sm-6.offset-sm-6 - - if ::Gitlab.com? - = link_to s_('UsageQuota|Buy additional minutes'), - buy_additional_minutes_path(namespace), - target: buy_addon_target_attr(namespace), - class: 'gl-button btn btn-confirm float-right js-buy-additional-minutes', - data: { track_action: 'click_buy_ci_minutes', track_label: namespace.actual_plan_name, track_property: 'pipeline_quota_page', qa_selector: 'buy_ci_minutes' } - - .row - .col-sm-6 - %strong - - last_reset = minutes_usage.reset_date - - if last_reset - = sprintf(s_('UsageQuota|CI/CD minutes usage since %{timeElapsed}'), { timeElapsed: last_reset.strftime('%b %d, %Y') }) - - else - = s_('UsageQuota|Current period usage') - %div{ data: { qa_selector: "plan_ci_minutes" } } - = ci_minutes_report(minutes_usage_presenter.monthly_minutes_report) - minutes - = link_to sprite_icon('question-o'), help_page_path('ci/pipelines/cicd_minutes'), target: '_blank', 'aria-label': _('Shared runners help link') - - .col-sm-6.right - - if minutes_usage_presenter.display_minutes_available_data? - #{minutes_usage_presenter.monthly_percent_used}% used - - elsif !minutes_usage_presenter.any_project_enabled? - 0% used - - else - = s_('UsageQuota|Unlimited') - - = ci_minutes_progress_bar(minutes_usage_presenter.monthly_percent_used) - - = render 'namespaces/pipelines_quota/extra_shared_runners_minutes_quota', namespace: namespace diff --git a/ee/app/views/namespaces/pipelines_quota/_extra_shared_runners_minutes_quota.html.haml b/ee/app/views/namespaces/pipelines_quota/_extra_shared_runners_minutes_quota.html.haml deleted file mode 100644 index 0994f55a7be1fae7057cb6848623f2857b01fdf7..0000000000000000000000000000000000000000 --- a/ee/app/views/namespaces/pipelines_quota/_extra_shared_runners_minutes_quota.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -- return unless Gitlab.com? - -- minutes_usage = namespace.ci_minutes_usage -- minutes_usage_presenter = Ci::Minutes::UsagePresenter.new(minutes_usage) -- return unless minutes_usage_presenter.display_minutes_available_data? && minutes_usage_presenter.purchased_minutes_report.limit > 0 - -.row - .col-sm-6 - %strong - = _("Additional minutes") - %div{ data: { qa_selector: "additional_ci_minutes" } } - = ci_minutes_report(minutes_usage_presenter.purchased_minutes_report) - minutes - = link_to sprite_icon('question-o'), help_page_path('ci/pipelines/cicd_minutes', anchor: 'purchase-additional-cicd-minutes-free-saas'), target: '_blank', rel: 'noopener noreferrer' - .col-sm-6.right - #{minutes_usage_presenter.purchased_percent_used}% used - = ci_minutes_progress_bar(minutes_usage_presenter.purchased_percent_used) diff --git a/ee/app/views/namespaces/pipelines_quota/_list.html.haml b/ee/app/views/namespaces/pipelines_quota/_list.html.haml deleted file mode 100644 index 2a73be1cd465cead661428409d518ac1e9350d56..0000000000000000000000000000000000000000 --- a/ee/app/views/namespaces/pipelines_quota/_list.html.haml +++ /dev/null @@ -1,56 +0,0 @@ -- namespace = locals.fetch(:namespace) -- projects_usage = locals.fetch(:projects_usage) -- minutes_usage = namespace.ci_minutes_usage -- minutes_usage_presenter = Ci::Minutes::UsagePresenter.new(minutes_usage) -- last_reset = minutes_usage.reset_date - -= render Pajamas::AlertComponent.new(variant: :info, dismissible: false, - alert_options: { class: 'gl-mt-6 gl-mb-3', - data: { testid: 'project-usage-info-alert' }}) do |c| - = c.body do - - if last_reset - = sprintf(s_('UsageQuota|The table below shows usage since %{timeElapsed}'), { timeElapsed: last_reset.strftime('%b %d, %Y') }) - - else - = s_('UsageQuota|The table below shows current period usage') - -%table.table.pipeline-project-metrics - %thead - %tr - %th - = _('Project') - %th - = s_('UsageQuota|Shared runner duration') - %th - = s_('UsageQuota|CI/CD minutes usage') - - %tbody - - if !minutes_usage_presenter.any_project_enabled? - %tr - %td{ colspan: 3 } - .nothing-here-block - - runners_doc_path = help_page_path('ci/runners/index.md') - - help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: runners_doc_path } - = s_('UsageQuota|%{help_link_start}Shared runners%{help_link_end} are disabled, so there are no limits set on pipeline usage').html_safe % { help_link_start: help_link_start, help_link_end: '</a>'.html_safe } - - else - - projects_usage.each do |project_usage| - %tr - %td - .avatar-container.s20.d-none.d-sm-block - = project_icon(project_usage.project, alt: '', class: 'avatar project-avatar s20') - %strong{ data: {testid: "pipelines-quota-tab-project-name" } } - = link_to project_usage.project.full_name, project_usage.project - %td{ 'data-testid': 'project_shared_runner_duration' } - = project_usage.shared_runners_duration.seconds.in_minutes.round - %td{ 'data-testid': 'project_amount_used' } - = project_usage.amount_used.to_i - - if projects_usage.blank? - %tr - %td{ colspan: 3 } - .nothing-here-block - = s_('UsageQuota|This namespace has no projects which used shared runners in the current period') - %tr - %td{ colspan: 3 } - .col-sm-12.center - = s_('UsageQuota|This table omits projects that used 0 CI/CD minutes or 0 shared runners duration') - -= paginate projects_usage, theme: "gitlab" diff --git a/ee/spec/features/profiles/usage_quotas_spec.rb b/ee/spec/features/profiles/usage_quotas_spec.rb index 243e300a14e9e6be03873239a6ce76e22dc0da6e..659b9ba697c72aae877f4f8f828c47430a70d2ab 100644 --- a/ee/spec/features/profiles/usage_quotas_spec.rb +++ b/ee/spec/features/profiles/usage_quotas_spec.rb @@ -64,7 +64,7 @@ end end - context 'pagination' do + context 'with pagination' do let(:per_page) { 1 } let(:item_selector) { '.js-project-link' } let(:prev_button_selector) { '[data-testid="prevButton"]' } @@ -75,14 +75,15 @@ allow(Kaminari.config).to receive(:default_per_page).and_return(per_page) end - context 'storage tab' do + context 'on storage tab' do before do visit_usage_quotas_page('storage-quota-tab') end + it_behaves_like 'correct pagination' end - context 'pipelines tab' do + context 'on pipelines tab' do let(:item_selector) { '[data-testid="pipelines-quota-tab-project-name"]' } before do diff --git a/ee/spec/requests/groups/usage_quotas_spec.rb b/ee/spec/requests/groups/usage_quotas_spec.rb index e9305eb68008857172b41f526e2380d583eec669..537858a533e27db8a293e6a84473fee7c28920a1 100644 --- a/ee/spec/requests/groups/usage_quotas_spec.rb +++ b/ee/spec/requests/groups/usage_quotas_spec.rb @@ -16,16 +16,18 @@ end context 'when storage size is over limit' do - let(:usage_message) { FFaker::Lorem.sentence } + let(:payload) do + { + alert_level: :info, + usage_message: FFaker::Lorem.sentence, + explanation_message: "Explanation", + root_namespace: group.root_ancestor + } + end before do allow_next_instance_of(EE::Namespace::Storage::Notification, group, user) do |notification| - allow(notification).to receive(:payload).and_return({ - alert_level: :info, - usage_message: usage_message, - explanation_message: "Explanation", - root_namespace: group.root_ancestor - }) + allow(notification).to receive(:payload).and_return(payload) end end @@ -33,7 +35,7 @@ send_request expect(response).to have_gitlab_http_status(:ok) - expect(response.body).not_to include(usage_message) + expect(response.body).not_to include(payload[:usage_message]) end end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 26784602b0b5e0fb54744939a37330585be338a9..44ba0b20a0bbf5ab39ac825c345f5b772e8233a0 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -44125,9 +44125,6 @@ msgstr "" msgid "UsageQuotas|This project-level storage statistic does not include savings for site-wide deduplication and is not used to calculate total namespace storage." msgstr "" -msgid "UsageQuota|%{help_link_start}Shared runners%{help_link_end} are disabled, so there are no limits set on pipeline usage" -msgstr "" - msgid "UsageQuota|%{linkStart}Shared runners%{linkEnd} are disabled, so there are no limits set on pipeline usage" msgstr "" @@ -44164,9 +44161,6 @@ msgstr "" msgid "UsageQuota|CI/CD minutes usage" msgstr "" -msgid "UsageQuota|CI/CD minutes usage since %{timeElapsed}" -msgstr "" - msgid "UsageQuota|CI/CD minutes usage since %{usageSince}" msgstr "" @@ -44176,9 +44170,6 @@ msgstr "" msgid "UsageQuota|Container Registry" msgstr "" -msgid "UsageQuota|Current period usage" -msgstr "" - msgid "UsageQuota|Dependency proxy" msgstr "" @@ -44305,12 +44296,6 @@ msgstr "" msgid "UsageQuota|The namespace is currently using %{strong_start}%{used_storage}%{strong_end} of namespace storage. View and manage your usage from %{strong_start}%{usage_quotas_nav_instruction}%{strong_end}. %{docs_link_start}Learn more%{link_end} about how to reduce your storage." msgstr "" -msgid "UsageQuota|The table below shows current period usage" -msgstr "" - -msgid "UsageQuota|The table below shows usage since %{timeElapsed}" -msgstr "" - msgid "UsageQuota|The table below shows usage since %{usageSince}" msgstr "" @@ -44335,9 +44320,6 @@ msgstr "" msgid "UsageQuota|Total namespace storage used" msgstr "" -msgid "UsageQuota|Unlimited" -msgstr "" - msgid "UsageQuota|Uploads" msgstr "" diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml index 26e9cd6cbd91f0b1d9719add1feee459a048d186..489ed89c048b832edd0889aecad00f637a46379f 100644 --- a/spec/support/rspec_order_todo.yml +++ b/spec/support/rspec_order_todo.yml @@ -257,7 +257,6 @@ - './ee/spec/features/boards/user_visits_board_spec.rb' - './ee/spec/features/burndown_charts_spec.rb' - './ee/spec/features/burnup_charts_spec.rb' -- './ee/spec/features/ci/ci_minutes_spec.rb' - './ee/spec/features/ci_shared_runner_settings_spec.rb' - './ee/spec/features/ci_shared_runner_warnings_spec.rb' - './ee/spec/features/clusters/cluster_detail_page_spec.rb' @@ -414,7 +413,6 @@ - './ee/spec/features/profiles/account_spec.rb' - './ee/spec/features/profiles/billing_spec.rb' - './ee/spec/features/profiles/password_spec.rb' -- './ee/spec/features/profiles/usage_quotas_spec.rb' - './ee/spec/features/profiles/user_visits_public_profile_spec.rb' - './ee/spec/features/projects/active_tabs_spec.rb' - './ee/spec/features/projects/audit_events_spec.rb' @@ -2410,7 +2408,6 @@ - './ee/spec/requests/groups/roadmap_controller_spec.rb' - './ee/spec/requests/groups/security/credentials_controller_spec.rb' - './ee/spec/requests/groups/settings/reporting_controller_spec.rb' -- './ee/spec/requests/groups/usage_quotas_spec.rb' - './ee/spec/requests/jwt_controller_spec.rb' - './ee/spec/requests/lfs_http_spec.rb' - './ee/spec/requests/lfs_locks_api_spec.rb'