From 3fc8af384263759bd93451b6977fc36536a46a40 Mon Sep 17 00:00:00 2001 From: Serhii Yarynovskyi <syarynovskyi@gitlab.com> Date: Thu, 30 Jun 2022 12:38:43 +0000 Subject: [PATCH] Revert "Merge branch 'sy-add-member-limit-banner-to-usage-quota-seats-page' into 'master'" This reverts merge request !89233 --- .../free_user_cap/alert_component.html.haml | 2 +- .../free_user_cap/alert_component.rb | 4 - .../usage_quota_alert_component.rb | 74 ----------- .../namespaces/free_user_cap/preview.rb | 2 +- .../namespaces/free_user_cap/standard.rb | 10 -- .../views/groups/usage_quotas/index.html.haml | 4 - .../free_user_cap/alert_component_spec.rb | 5 +- .../usage_quota_alert_component_spec.rb | 119 ------------------ ee/spec/features/groups/usage_quotas_spec.rb | 19 --- .../namespaces/free_user_cap/standard_spec.rb | 38 ------ locale/gitlab.pot | 6 - 11 files changed, 3 insertions(+), 280 deletions(-) delete mode 100644 ee/app/components/namespaces/free_user_cap/usage_quota_alert_component.rb delete mode 100644 ee/spec/components/namespaces/free_user_cap/usage_quota_alert_component_spec.rb diff --git a/ee/app/components/namespaces/free_user_cap/alert_component.html.haml b/ee/app/components/namespaces/free_user_cap/alert_component.html.haml index 9a57b3f74991a..19d2ca99791d3 100644 --- a/ee/app/components/namespaces/free_user_cap/alert_component.html.haml +++ b/ee/app/components/namespaces/free_user_cap/alert_component.html.haml @@ -1,4 +1,4 @@ -%div{ class: "#{container_class}" } +.container-fluid.container-limited{ class: "gl-pb-2! gl-pt-6! #{content_class}" } = render Pajamas::AlertComponent.new(variant: variant, alert_options: { class: 'js-user-over-limit-free-plan-alert', data: alert_data }, title: alert_attributes[:title], diff --git a/ee/app/components/namespaces/free_user_cap/alert_component.rb b/ee/app/components/namespaces/free_user_cap/alert_component.rb index ef5bf7ddb2a52..7a5346d93e142 100644 --- a/ee/app/components/namespaces/free_user_cap/alert_component.rb +++ b/ee/app/components/namespaces/free_user_cap/alert_component.rb @@ -109,10 +109,6 @@ def namespace_secondary_cta def link_end '</a>'.html_safe end - - def container_class - "container-fluid container-limited gl-pb-2! gl-pt-6! #{content_class}" - end end end end diff --git a/ee/app/components/namespaces/free_user_cap/usage_quota_alert_component.rb b/ee/app/components/namespaces/free_user_cap/usage_quota_alert_component.rb deleted file mode 100644 index 8c1b4c54359e4..0000000000000 --- a/ee/app/components/namespaces/free_user_cap/usage_quota_alert_component.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true - -module Namespaces - module FreeUserCap - class UsageQuotaAlertComponent < AlertComponent - private - - FREE_GROUP_LIMITED_ALERT = 'free_group_limited_alert' - - def breached_cap_limit? - return false if ::Namespaces::FreeUserCap::Standard.new(namespace).under_limit? - return true if paid_gitlab_subscription_expired? - - namespace.trial_expired? - end - - def base_alert_data - { - track_action: 'render', - track_property: 'free_group_limited_usage_quota_banner', - feature_id: feature_name, - testid: 'free-group-limited-alert' - } - end - - def close_button_data - { - track_action: 'dismiss_banner', - track_property: 'free_group_limited_usage_quota_banner', - testid: 'free-group-limited-dismiss' - } - end - - def feature_name - FREE_GROUP_LIMITED_ALERT - end - - def alert_attributes - { - title: s_('Billing|Your free group is now limited to %{free_user_limit} members') % { - free_user_limit: ::Namespaces::FreeUserCap::FREE_USER_LIMIT - }, - body: s_( - 'Billing|Your group recently changed to use the Free plan. Free groups are limited to ' \ - '%{free_user_limit} members and the remaining members will get a status of over-limit ' \ - 'and lose access to the group. You can free up space for new members by removing ' \ - 'those who no longer need access or toggling them to over-limit. To get an unlimited ' \ - 'number of members, you can %{link_start}upgrade%{link_end} to a paid tier.' - ).html_safe % { - free_user_limit: ::Namespaces::FreeUserCap::FREE_USER_LIMIT, - link_start: '<a data-track-action="click_link" data-track-label="upgrade" ' \ - 'data-track-property="free_group_limited_usage_quota_banner" ' \ - 'href="%{url}">'.html_safe % { url: group_billings_path(namespace) }, - link_end: '</a>'.html_safe - } - } - end - - def container_class - content_class - end - - def paid_gitlab_subscription_expired? - return false unless non_trial_paid_plan? - - namespace.gitlab_subscription.expired? - end - - def non_trial_paid_plan? - namespace.paid? && !namespace.trial? - end - end - end -end diff --git a/ee/app/models/namespaces/free_user_cap/preview.rb b/ee/app/models/namespaces/free_user_cap/preview.rb index b8045bc44302e..59bfec780274a 100644 --- a/ee/app/models/namespaces/free_user_cap/preview.rb +++ b/ee/app/models/namespaces/free_user_cap/preview.rb @@ -7,7 +7,7 @@ class Preview < Standard def over_limit? return false unless enforce_cap? - users_count_over_free_user_limit? + users_count > FREE_USER_LIMIT end private diff --git a/ee/app/models/namespaces/free_user_cap/standard.rb b/ee/app/models/namespaces/free_user_cap/standard.rb index f8a8f6541c051..389e126ca498e 100644 --- a/ee/app/models/namespaces/free_user_cap/standard.rb +++ b/ee/app/models/namespaces/free_user_cap/standard.rb @@ -7,12 +7,6 @@ def initialize(root_namespace) @root_namespace = root_namespace.root_ancestor # just in case the true root isn't passed end - def under_limit? - return false unless feature_enabled? - - !users_count_over_free_user_limit? - end - def reached_limit? return false unless enforce_cap? @@ -40,10 +34,6 @@ def users_count def enforceable_subscription? ::Gitlab::CurrentSettings.should_check_namespace_plan? && root_namespace.has_free_or_no_subscription? end - - def users_count_over_free_user_limit? - users_count > FREE_USER_LIMIT - end end end end diff --git a/ee/app/views/groups/usage_quotas/index.html.haml b/ee/app/views/groups/usage_quotas/index.html.haml index de36bacfb50d1..53c2d9897dd17 100644 --- a/ee/app/views/groups/usage_quotas/index.html.haml +++ b/ee/app/views/groups/usage_quotas/index.html.haml @@ -25,10 +25,6 @@ .tab-content .tab-pane.active#seats-quota-tab - = render Namespaces::FreeUserCap::UsageQuotaAlertComponent.new(namespace: @group.root_ancestor, - user: current_user, - content_class: 'gl-my-3') - #js-seat-usage-app{ data: group_seats_usage_quota_app_data(@group) } .tab-pane#pipelines-quota-tab - if Feature.enabled?(:usage_quotas_pipelines_vue, @group) diff --git a/ee/spec/components/namespaces/free_user_cap/alert_component_spec.rb b/ee/spec/components/namespaces/free_user_cap/alert_component_spec.rb index 049fe8a29193d..aa0a828f86360 100644 --- a/ee/spec/components/namespaces/free_user_cap/alert_component_spec.rb +++ b/ee/spec/components/namespaces/free_user_cap/alert_component_spec.rb @@ -24,13 +24,10 @@ it 'has content for the alert' do render_inline(component) + expect(rendered_component).to have_selector(".#{content_class}") expect(rendered_component).to have_content(title) expect(rendered_component).to have_link('Manage members', href: group_usage_quotas_path(namespace)) expect(rendered_component).to have_link('Explore paid plans', href: group_billings_path(namespace)) - - expect(rendered_component) - .to match("container-fluid container-limited gl-pb-2! gl-pt-6! #{content_class}") - expect(rendered_component) .to have_css("[data-testid='user-over-limit-free-plan-alert']" \ "[data-dismiss-endpoint='#{group_callouts_path}']" \ diff --git a/ee/spec/components/namespaces/free_user_cap/usage_quota_alert_component_spec.rb b/ee/spec/components/namespaces/free_user_cap/usage_quota_alert_component_spec.rb deleted file mode 100644 index 827e8a8dc0f5c..0000000000000 --- a/ee/spec/components/namespaces/free_user_cap/usage_quota_alert_component_spec.rb +++ /dev/null @@ -1,119 +0,0 @@ -# frozen_string_literal: true -require "spec_helper" - -RSpec.describe Namespaces::FreeUserCap::UsageQuotaAlertComponent, :saas, type: :component do - let_it_be(:namespace) { create(:group) } - let_it_be(:user, refind: true) { create(:user) } - let_it_be(:content_class) { '_content_class_' } - - let(:under_limit?) { false } - let!(:gitlab_subscription) { create(:gitlab_subscription, :expired, namespace: namespace) } - - let(:title) do - "Your free group is now limited to #{::Namespaces::FreeUserCap::FREE_USER_LIMIT} members" - end - - let(:body) do - 'Your group recently changed to use the Free plan. Free groups are limited to 5 members and ' \ - 'the remaining members will get a status of over-limit and lose access to the group. You can ' \ - 'free up space for new members by removing those who no longer need access or toggling them ' \ - 'to over-limit. To get an unlimited number of members, you can upgrade to a paid tier.' - end - - subject(:component) { described_class.new(namespace: namespace, user: user, content_class: content_class) } - - before do - allow_next_instance_of(::Namespaces::FreeUserCap::Standard) do |free_user_cap| - allow(free_user_cap).to receive(:under_limit?).and_return(under_limit?) - end - - namespace.add_owner(user) - end - - shared_examples 'renders the alert' do - it 'has the title' do - render_inline(component) - - expect(rendered_component).to have_content(title) - end - end - - shared_examples 'does not render the alert' do - it 'does not have the title' do - render_inline(component) - - expect(rendered_component).not_to have_content(title) - end - end - - context 'when under limit' do - let(:under_limit?) { true } - - it_behaves_like 'does not render the alert' - end - - context 'when over limit' do - context 'when paid subscription' do - context 'when subscription is active' do - let!(:gitlab_subscription) { create(:gitlab_subscription, namespace: namespace) } - - it_behaves_like 'does not render the alert' - end - - context 'when subscription is expired' do - context 'when is not on trial' do - it 'has content for the alert' do - render_inline(component) - - expect(rendered_component).to have_selector(".#{content_class}") - expect(rendered_component).to have_content(title) - expect(rendered_component).to have_content(body) - expect(rendered_component).to have_link('upgrade', href: group_billings_path(namespace)) - - expect(rendered_component) - .to have_css('.js-user-over-limit-free-plan-alert' \ - "[data-dismiss-endpoint='#{group_callouts_path}']" \ - "[data-feature-id='#{described_class::FREE_GROUP_LIMITED_ALERT}']" \ - "[data-group-id='#{namespace.id}']") - end - - it 'renders all the expected tracking items' do - render_inline(component) - - expect(rendered_component).to have_css('[data-testid="free-group-limited-alert"]' \ - '[data-track-action="render"]' \ - '[data-track-property="free_group_limited_usage_quota_banner"]') - expect(rendered_component).to have_css('[data-testid="free-group-limited-dismiss"]' \ - '[data-track-action="dismiss_banner"]' \ - '[data-track-property="free_group_limited_usage_quota_banner"]') - expect(rendered_component).to have_css('[data-track-action="click_link"]' \ - '[data-track-label="upgrade"]' \ - '[data-track-property="free_group_limited_usage_quota_banner"]') - end - end - - context 'when on trial' do - let!(:gitlab_subscription) do - create(:gitlab_subscription, :expired, :active_trial, namespace: namespace) - end - - it_behaves_like 'does not render the alert' - end - end - end - - context 'when free subscription' do - context 'when trial is expired' do - let!(:gitlab_subscription) { create(:gitlab_subscription, :expired_trial, :free, namespace: namespace) } - - it_behaves_like 'renders the alert' - end - - context 'when trial is active' do - let!(:gitlab_subscription) { create(:gitlab_subscription, :active_trial, :free, namespace: namespace) } - - it_behaves_like 'does not render the alert' - end - end - end -end diff --git a/ee/spec/features/groups/usage_quotas_spec.rb b/ee/spec/features/groups/usage_quotas_spec.rb index f67760c581412..0782772b8af6a 100644 --- a/ee/spec/features/groups/usage_quotas_spec.rb +++ b/ee/spec/features/groups/usage_quotas_spec.rb @@ -397,25 +397,6 @@ end end - context 'when on a paid expired plan and over limit' do - let_it_be(:gitlab_subscription) { create(:gitlab_subscription, :expired, namespace: group) } - - let_it_be(:active_members) do - create_list(:group_member, ::Namespaces::FreeUserCap::FREE_USER_LIMIT + 1, source: group) - end - - it 'shows usage quota alert' do - expect(page).to have_content('Your free group is now limited to') - expect(page).to have_link('upgrade') - - page.find("[data-testid='free-group-limited-dismiss']").click - expect(page).not_to have_content('Your free group is now limited to') - - page.refresh - expect(page).not_to have_content('Your free group is now limited to') - end - end - context 'when on a trial' do let_it_be(:gitlab_subscription) { create(:gitlab_subscription, :active_trial, seats_in_use: 4, seats: 10, namespace: group) } diff --git a/ee/spec/models/namespaces/free_user_cap/standard_spec.rb b/ee/spec/models/namespaces/free_user_cap/standard_spec.rb index 94fe1729d280d..c8a1691430fe6 100644 --- a/ee/spec/models/namespaces/free_user_cap/standard_spec.rb +++ b/ee/spec/models/namespaces/free_user_cap/standard_spec.rb @@ -11,44 +11,6 @@ stub_ee_application_setting(should_check_namespace_plan: should_check_namespace_plan) end - describe '#under_limit?' do - let(:free_plan_members_count) { Namespaces::FreeUserCap::FREE_USER_LIMIT } - - subject(:reached_limit?) { described_class.new(namespace).under_limit? } - - before do - allow(namespace).to receive(:free_plan_members_count).and_return(free_plan_members_count) - end - - context 'when :free_user_cap is disabled' do - before do - stub_feature_flags(free_user_cap: false) - end - - it { is_expected.to be false } - end - - context 'when :free_user_cap is enabled' do - before do - stub_feature_flags(free_user_cap: true) - end - - it { is_expected.to be true } - - context 'when under the number of free users limit' do - let(:free_plan_members_count) { Namespaces::FreeUserCap::FREE_USER_LIMIT - 1 } - - it { is_expected.to be true } - end - - context 'when over the number of free users limit' do - let(:free_plan_members_count) { Namespaces::FreeUserCap::FREE_USER_LIMIT + 1 } - - it { is_expected.to be false } - end - end - end - describe '#reached_limit?' do let(:free_plan_members_count) { Namespaces::FreeUserCap::FREE_USER_LIMIT + 1 } diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 5eefa0cd93058..1841e86f690e5 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -6219,12 +6219,6 @@ msgstr "" msgid "Billing|You can begin moving members in %{namespaceName} now. A member loses access to the group when you turn off %{strongStart}In a seat%{strongEnd}. If over 5 members have %{strongStart}In a seat%{strongEnd} enabled after June 22, 2022, we'll select the 5 members who maintain access. We'll first count members that have Owner and Maintainer roles, then the most recently active members until we reach 5 members. The remaining members will get a status of Over limit and lose access to the group." msgstr "" -msgid "Billing|Your free group is now limited to %{free_user_limit} members" -msgstr "" - -msgid "Billing|Your group recently changed to use the Free plan. Free groups are limited to %{free_user_limit} members and the remaining members will get a status of over-limit and lose access to the group. You can free up space for new members by removing those who no longer need access or toggling them to over-limit. To get an unlimited number of members, you can %{link_start}upgrade%{link_end} to a paid tier." -msgstr "" - msgid "Bitbucket Server Import" msgstr "" -- GitLab