Commit 30e8ec41 authored by Miguel Rincon's avatar Miguel Rincon

Merge branch...

Merge branch '337720-storage-feature-flag-remove-the-new_route_storage_purchase-feature-flag' into 'master'

Resolve "[Storage] [Feature flag] Remove the 'new_route_storage_purchase' feature flag"

See merge request gitlab-org/gitlab!80568
parents 4f1e0814 e1d15854
---
name: new_route_storage_purchase
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68834
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/327896
milestone: '14.3'
type: development
group: group::purchase
default_enabled: true
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { helpPagePath } from '~/helpers/help_page_helper'; import { helpPagePath } from '~/helpers/help_page_helper';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { formatUsageSize } from '../utils'; import { formatUsageSize } from '../utils';
...@@ -11,8 +10,7 @@ export default { ...@@ -11,8 +10,7 @@ export default {
GlButton, GlButton,
UsageStatisticsCard, UsageStatisticsCard,
}, },
mixins: [glFeatureFlagsMixin()], inject: ['purchaseStorageUrl', 'buyAddonTargetAttr'],
inject: ['purchaseStorageUrl'],
props: { props: {
rootStorageStatistics: { rootStorageStatistics: {
required: true, required: true,
...@@ -64,7 +62,7 @@ export default { ...@@ -64,7 +62,7 @@ export default {
link: { link: {
text: s__('UsageQuota|Purchase more storage'), text: s__('UsageQuota|Purchase more storage'),
url: this.purchaseStorageUrl, url: this.purchaseStorageUrl,
target: this.glFeatures.newRouteStoragePurchase ? '_self' : '_blank', target: this.buyAddonTargetAttr,
}, },
} }
: null; : null;
......
...@@ -8,7 +8,12 @@ Vue.use(VueApollo); ...@@ -8,7 +8,12 @@ Vue.use(VueApollo);
export default () => { export default () => {
const el = document.getElementById('js-storage-counter-app'); const el = document.getElementById('js-storage-counter-app');
const { namespacePath, purchaseStorageUrl, isTemporaryStorageIncreaseVisible } = el.dataset; const {
namespacePath,
purchaseStorageUrl,
buyAddonTargetAttr,
isTemporaryStorageIncreaseVisible,
} = el.dataset;
const apolloProvider = new VueApollo({ const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(), defaultClient: createDefaultClient(),
...@@ -20,6 +25,7 @@ export default () => { ...@@ -20,6 +25,7 @@ export default () => {
provide: { provide: {
namespacePath, namespacePath,
purchaseStorageUrl, purchaseStorageUrl,
buyAddonTargetAttr,
isTemporaryStorageIncreaseVisible, isTemporaryStorageIncreaseVisible,
helpLinks, helpLinks,
}, },
......
...@@ -5,10 +5,6 @@ class Groups::UsageQuotasController < Groups::ApplicationController ...@@ -5,10 +5,6 @@ class Groups::UsageQuotasController < Groups::ApplicationController
before_action :verify_usage_quotas_enabled! before_action :verify_usage_quotas_enabled!
before_action :push_additional_repo_storage_by_namespace_feature, only: :index before_action :push_additional_repo_storage_by_namespace_feature, only: :index
before_action do
push_frontend_feature_flag(:new_route_storage_purchase, @group, default_enabled: :yaml)
end
layout 'group_settings' layout 'group_settings'
feature_category :purchase feature_category :purchase
......
...@@ -55,7 +55,7 @@ class SubscriptionsController < ApplicationController ...@@ -55,7 +55,7 @@ class SubscriptionsController < ApplicationController
@account_id = result[:account_id] @account_id = result[:account_id]
@active_subscription = result[:active_subscription] @active_subscription = result[:active_subscription]
return render_404 if @group.nil? render_404 if @group.nil?
end end
def buy_storage def buy_storage
...@@ -69,9 +69,7 @@ class SubscriptionsController < ApplicationController ...@@ -69,9 +69,7 @@ class SubscriptionsController < ApplicationController
@account_id = result[:account_id] @account_id = result[:account_id]
@active_subscription = result[:active_subscription] @active_subscription = result[:active_subscription]
return render_404 if @group.nil? render_404 if @group.nil?
render_404 unless Feature.enabled?(:new_route_storage_purchase, @group, default_enabled: :yaml)
end end
def payment_form def payment_form
......
...@@ -40,29 +40,25 @@ module EE ...@@ -40,29 +40,25 @@ module EE
end end
def buy_additional_minutes_path(namespace) def buy_additional_minutes_path(namespace)
return EE::SUBSCRIPTIONS_MORE_MINUTES_URL if use_customers_dot_for_minutes_path?(namespace) return EE::SUBSCRIPTIONS_MORE_MINUTES_URL if use_customers_dot_for_addon_path?(namespace)
buy_minutes_subscriptions_path(selected_group: namespace.id) buy_minutes_subscriptions_path(selected_group: namespace.id)
end end
def buy_additional_minutes_target(namespace) def buy_addon_target_attr(namespace)
use_customers_dot_for_minutes_path?(namespace) ? '_blank' : '_self' use_customers_dot_for_addon_path?(namespace) ? '_blank' : '_self'
end end
def buy_storage_path(namespace) def buy_storage_path(namespace)
return EE::SUBSCRIPTIONS_MORE_STORAGE_URL if use_customers_dot_for_storage_path?(namespace) return EE::SUBSCRIPTIONS_MORE_STORAGE_URL if use_customers_dot_for_addon_path?(namespace)
buy_storage_subscriptions_path(selected_group: namespace.id) buy_storage_subscriptions_path(selected_group: namespace.id)
end end
private private
def use_customers_dot_for_minutes_path?(namespace) def use_customers_dot_for_addon_path?(namespace)
namespace.user_namespace? namespace.user_namespace?
end end
def use_customers_dot_for_storage_path?(namespace)
namespace.user_namespace? || ::Feature.disabled?(:new_route_storage_purchase, namespace, default_enabled: :yaml)
end
end end
end end
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
- page_title s_("UsageQuota|Usage") - page_title s_("UsageQuota|Usage")
- url_to_purchase_storage = buy_storage_path(@group) if purchase_storage_link_enabled?(@group) - url_to_purchase_storage = buy_storage_path(@group) if purchase_storage_link_enabled?(@group)
- buy_addon_target_attr = buy_addon_target_attr(@group) if purchase_storage_link_enabled?(@group)
- pending_members_page_path = pending_members_group_usage_quotas_path(@group) if @group.user_cap_available? - pending_members_page_path = pending_members_group_usage_quotas_path(@group) if @group.user_cap_available?
- pending_members_count = Member.in_hierarchy(@group).with_state("awaiting").count - pending_members_count = Member.in_hierarchy(@group).with_state("awaiting").count
...@@ -37,4 +38,4 @@ ...@@ -37,4 +38,4 @@
= render "namespaces/pipelines_quota/list", = render "namespaces/pipelines_quota/list",
locals: { namespace: @group, projects: @projects } locals: { namespace: @group, projects: @projects }
.tab-pane#storage-quota-tab .tab-pane#storage-quota-tab
#js-storage-counter-app{ data: { namespace_path: @group.full_path, purchase_storage_url: url_to_purchase_storage, is_temporary_storage_increase_visible: temporary_storage_increase_visible?(@group).to_s } } #js-storage-counter-app{ data: { namespace_path: @group.full_path, purchase_storage_url: url_to_purchase_storage, buy_addon_target_attr: buy_addon_target_attr, is_temporary_storage_increase_visible: temporary_storage_increase_visible?(@group).to_s } }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
- if ::Gitlab.com? - if ::Gitlab.com?
= link_to s_('UsageQuota|Buy additional minutes'), = link_to s_('UsageQuota|Buy additional minutes'),
buy_additional_minutes_path(namespace), buy_additional_minutes_path(namespace),
target: buy_additional_minutes_target(namespace), target: buy_addon_target_attr(namespace),
class: 'gl-button btn btn-confirm float-right', class: 'gl-button btn btn-confirm float-right',
data: { track_action: 'click_buy_ci_minutes', track_label: namespace.actual_plan_name, track_property: 'pipeline_quota_page' } data: { track_action: 'click_buy_ci_minutes', track_label: namespace.actual_plan_name, track_property: 'pipeline_quota_page' }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
- page_title s_("UsageQuota|Usage") - page_title s_("UsageQuota|Usage")
- @content_class = "limit-container-width" unless fluid_layout - @content_class = "limit-container-width" unless fluid_layout
- url_to_purchase_storage = purchase_storage_url if purchase_storage_link_enabled?(@namespace) - url_to_purchase_storage = purchase_storage_url if purchase_storage_link_enabled?(@namespace)
- buy_addon_target_attr = buy_addon_target_attr(@namespace) if purchase_storage_link_enabled?(@namespace)
%h3.page-title %h3.page-title
= s_('UsageQuota|Usage Quotas') = s_('UsageQuota|Usage Quotas')
...@@ -27,4 +28,4 @@ ...@@ -27,4 +28,4 @@
= render "namespaces/pipelines_quota/list", = render "namespaces/pipelines_quota/list",
locals: { namespace: @namespace, projects: @projects } locals: { namespace: @namespace, projects: @projects }
.tab-pane#storage-quota-tab .tab-pane#storage-quota-tab
#js-storage-counter-app{ data: { namespace_path: @namespace.full_path, purchase_storage_url: url_to_purchase_storage, is_temporary_storage_increase_visible: temporary_storage_increase_visible?(@namespace).to_s } } #js-storage-counter-app{ data: { namespace_path: @namespace.full_path, purchase_storage_url: url_to_purchase_storage, buy_addon_target_attr: buy_addon_target_attr, is_temporary_storage_increase_visible: temporary_storage_increase_visible?(@namespace).to_s } }
...@@ -146,7 +146,6 @@ RSpec.describe SubscriptionsController do ...@@ -146,7 +146,6 @@ RSpec.describe SubscriptionsController do
context 'with authenticated user' do context 'with authenticated user' do
before do before do
group.add_owner(user) group.add_owner(user)
stub_feature_flags(new_route_storage_purchase: group)
sign_in(user) sign_in(user)
end end
...@@ -195,14 +194,6 @@ RSpec.describe SubscriptionsController do ...@@ -195,14 +194,6 @@ RSpec.describe SubscriptionsController do
expect(assigns(:group)).to eq group expect(assigns(:group)).to eq group
expect(assigns(:account_id)).to eq nil expect(assigns(:account_id)).to eq nil
end end
context 'with :new_route_storage_purchase disabled' do
before do
stub_feature_flags(new_route_storage_purchase: false)
end
it { is_expected.to have_gitlab_http_status(:not_found) }
end
end end
end end
end end
......
...@@ -7,7 +7,7 @@ import { withRootStorageStatistics } from '../mock_data'; ...@@ -7,7 +7,7 @@ import { withRootStorageStatistics } from '../mock_data';
describe('UsageStatistics', () => { describe('UsageStatistics', () => {
let wrapper; let wrapper;
const createComponent = ({ props = {}, provide = {}, newRouteStoragePurchase = false } = {}) => { const createComponent = ({ props = {}, provide = {} } = {}) => {
wrapper = shallowMount(UsageStatistics, { wrapper = shallowMount(UsageStatistics, {
propsData: { propsData: {
rootStorageStatistics: { rootStorageStatistics: {
...@@ -19,9 +19,6 @@ describe('UsageStatistics', () => { ...@@ -19,9 +19,6 @@ describe('UsageStatistics', () => {
...props, ...props,
}, },
provide: { provide: {
glFeatures: {
newRouteStoragePurchase,
},
...provide, ...provide,
}, },
stubs: { stubs: {
...@@ -45,29 +42,12 @@ describe('UsageStatistics', () => { ...@@ -45,29 +42,12 @@ describe('UsageStatistics', () => {
const findPurchasedUsageButton = () => const findPurchasedUsageButton = () =>
getStatisticsCard('purchased-usage').findComponent(GlButton); getStatisticsCard('purchased-usage').findComponent(GlButton);
describe('with purchaseStorageUrl passed and newRouteStoragePurchase flag enabled', () => {
beforeEach(() => {
createComponent({
provide: {
purchaseStorageUrl: 'some-fancy-url',
},
newRouteStoragePurchase: true,
});
});
it('renders button in purchased usage card footer with correct link', () => {
expect(findPurchasedUsageButton().attributes()).toMatchObject({
href: 'some-fancy-url',
target: '_self',
});
});
});
describe('with purchaseStorageUrl passed', () => { describe('with purchaseStorageUrl passed', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
provide: { provide: {
purchaseStorageUrl: 'some-fancy-url', purchaseStorageUrl: 'some-fancy-url',
buyAddonTargetAttr: '_self',
}, },
}); });
}); });
...@@ -89,6 +69,24 @@ describe('UsageStatistics', () => { ...@@ -89,6 +69,24 @@ describe('UsageStatistics', () => {
}); });
it('renders button in purchased usage card footer with correct link', () => { it('renders button in purchased usage card footer with correct link', () => {
expect(findPurchasedUsageButton().attributes()).toMatchObject({
href: 'some-fancy-url',
target: '_self',
});
});
});
describe('with buyAddonTargetAttr passed as _blank', () => {
beforeEach(() => {
createComponent({
provide: {
purchaseStorageUrl: 'some-fancy-url',
buyAddonTargetAttr: '_blank',
},
});
});
it('renders button in purchased usage card footer with correct target', () => {
expect(findPurchasedUsageButton().attributes()).toMatchObject({ expect(findPurchasedUsageButton().attributes()).toMatchObject({
href: 'some-fancy-url', href: 'some-fancy-url',
target: '_blank', target: '_blank',
...@@ -101,6 +99,7 @@ describe('UsageStatistics', () => { ...@@ -101,6 +99,7 @@ describe('UsageStatistics', () => {
createComponent({ createComponent({
provide: { provide: {
purchaseStorageUrl: null, purchaseStorageUrl: null,
buyAddonTargetAttr: '_self',
}, },
}); });
}); });
......
...@@ -156,6 +156,7 @@ export const defaultProjectProvideValues = { ...@@ -156,6 +156,7 @@ export const defaultProjectProvideValues = {
export const defaultNamespaceProvideValues = { export const defaultNamespaceProvideValues = {
namespacePath: 'h5bp', namespacePath: 'h5bp',
purchaseStorageUrl: '', purchaseStorageUrl: '',
buyAddonTargetAttr: '_blank',
isTemporaryStorageIncreaseVisible: false, isTemporaryStorageIncreaseVisible: false,
helpLinks: projectHelpLinks, helpLinks: projectHelpLinks,
}; };
......
...@@ -196,45 +196,18 @@ RSpec.describe EE::NamespacesHelper do ...@@ -196,45 +196,18 @@ RSpec.describe EE::NamespacesHelper do
it { is_expected.to eq buy_storage_subscriptions_path(selected_group: namespace.id) } it { is_expected.to eq buy_storage_subscriptions_path(selected_group: namespace.id) }
context 'new_route_storage_purchase' do context 'when called for a personal namespace' do
context 'when is disabled' do let(:user) { create(:user) }
before do let(:personal_namespace) { build_stubbed(:user_namespace) }
stub_feature_flags(new_route_storage_purchase: false)
end
it { is_expected.to eq EE::SUBSCRIPTIONS_MORE_STORAGE_URL }
end
context 'when new_route_storage_purchase is enabled only for a specific namespace' do
let(:enabled_namespace) { build_stubbed(:group) }
before do
stub_feature_flags(new_route_storage_purchase: false)
stub_feature_flags(new_route_storage_purchase: enabled_namespace)
end
it 'returns the default purchase path for the disabled namespace' do
expect(helper.buy_storage_path(namespace)).to eq EE::SUBSCRIPTIONS_MORE_STORAGE_URL
end
it 'returns GitLab purchase path for the disabled namespace' do
expect(helper.buy_storage_path(enabled_namespace)).to eq buy_storage_subscriptions_path(selected_group: enabled_namespace.id)
end
end
context 'when called for a personal namespace' do
let(:user) { create(:user) }
let(:personal_namespace) { build_stubbed(:user_namespace) }
it 'returns the default purchase' do it 'returns the default purchase' do
expect(helper.buy_storage_path(personal_namespace)).to eq EE::SUBSCRIPTIONS_MORE_STORAGE_URL expect(helper.buy_storage_path(personal_namespace)).to eq EE::SUBSCRIPTIONS_MORE_STORAGE_URL
end
end end
end end
end end
describe '#buy_additional_minutes_target' do describe '#buy_addon_target_attr' do
subject { helper.buy_additional_minutes_target(namespace) } subject { helper.buy_addon_target_attr(namespace) }
let(:namespace) { create(:group) } let(:namespace) { create(:group) }
...@@ -245,7 +218,7 @@ RSpec.describe EE::NamespacesHelper do ...@@ -245,7 +218,7 @@ RSpec.describe EE::NamespacesHelper do
let(:personal_namespace) { build_stubbed(:user_namespace) } let(:personal_namespace) { build_stubbed(:user_namespace) }
it 'returns _blank' do it 'returns _blank' do
expect(helper.buy_additional_minutes_target(personal_namespace)).to eq '_blank' expect(helper.buy_addon_target_attr(personal_namespace)).to eq '_blank'
end end
end end
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