Commit e1d15854 authored by Vamsi Vempati's avatar Vamsi Vempati Committed by Miguel Rincon

Remove new_route_storage_purchase feature flag

- Rename buy_addon_target to be buy_addon_target_attr
- Add logic to open Customers Portal storage purchase link in new tab

Changelog: other
parent 4d9be902
---
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>
import { GlButton } from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { helpPagePath } from '~/helpers/help_page_helper';
import { s__ } from '~/locale';
import { formatUsageSize } from '../utils';
......@@ -11,8 +10,7 @@ export default {
GlButton,
UsageStatisticsCard,
},
mixins: [glFeatureFlagsMixin()],
inject: ['purchaseStorageUrl'],
inject: ['purchaseStorageUrl', 'buyAddonTargetAttr'],
props: {
rootStorageStatistics: {
required: true,
......@@ -64,7 +62,7 @@ export default {
link: {
text: s__('UsageQuota|Purchase more storage'),
url: this.purchaseStorageUrl,
target: this.glFeatures.newRouteStoragePurchase ? '_self' : '_blank',
target: this.buyAddonTargetAttr,
},
}
: null;
......
......@@ -8,7 +8,12 @@ Vue.use(VueApollo);
export default () => {
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({
defaultClient: createDefaultClient(),
......@@ -20,6 +25,7 @@ export default () => {
provide: {
namespacePath,
purchaseStorageUrl,
buyAddonTargetAttr,
isTemporaryStorageIncreaseVisible,
helpLinks,
},
......
......@@ -5,10 +5,6 @@ class Groups::UsageQuotasController < Groups::ApplicationController
before_action :verify_usage_quotas_enabled!
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'
feature_category :purchase
......
......@@ -55,7 +55,7 @@ class SubscriptionsController < ApplicationController
@account_id = result[:account_id]
@active_subscription = result[:active_subscription]
return render_404 if @group.nil?
render_404 if @group.nil?
end
def buy_storage
......@@ -69,9 +69,7 @@ class SubscriptionsController < ApplicationController
@account_id = result[:account_id]
@active_subscription = result[:active_subscription]
return render_404 if @group.nil?
render_404 unless Feature.enabled?(:new_route_storage_purchase, @group, default_enabled: :yaml)
render_404 if @group.nil?
end
def payment_form
......
......@@ -40,29 +40,25 @@ module EE
end
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)
end
def buy_additional_minutes_target(namespace)
use_customers_dot_for_minutes_path?(namespace) ? '_blank' : '_self'
def buy_addon_target_attr(namespace)
use_customers_dot_for_addon_path?(namespace) ? '_blank' : '_self'
end
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)
end
private
def use_customers_dot_for_minutes_path?(namespace)
def use_customers_dot_for_addon_path?(namespace)
namespace.user_namespace?
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
......@@ -5,6 +5,7 @@
- page_title s_("UsageQuota|Usage")
- 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_count = Member.in_hierarchy(@group).with_state("awaiting").count
......@@ -37,4 +38,4 @@
= render "namespaces/pipelines_quota/list",
locals: { namespace: @group, projects: @projects }
.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 @@
- if ::Gitlab.com?
= link_to s_('UsageQuota|Buy additional minutes'),
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',
data: { track_action: 'click_buy_ci_minutes', track_label: namespace.actual_plan_name, track_property: 'pipeline_quota_page' }
......
......@@ -6,6 +6,7 @@
- page_title s_("UsageQuota|Usage")
- @content_class = "limit-container-width" unless fluid_layout
- 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
= s_('UsageQuota|Usage Quotas')
......@@ -27,4 +28,4 @@
= render "namespaces/pipelines_quota/list",
locals: { namespace: @namespace, projects: @projects }
.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
context 'with authenticated user' do
before do
group.add_owner(user)
stub_feature_flags(new_route_storage_purchase: group)
sign_in(user)
end
......@@ -195,14 +194,6 @@ RSpec.describe SubscriptionsController do
expect(assigns(:group)).to eq group
expect(assigns(:account_id)).to eq nil
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
......
......@@ -7,7 +7,7 @@ import { withRootStorageStatistics } from '../mock_data';
describe('UsageStatistics', () => {
let wrapper;
const createComponent = ({ props = {}, provide = {}, newRouteStoragePurchase = false } = {}) => {
const createComponent = ({ props = {}, provide = {} } = {}) => {
wrapper = shallowMount(UsageStatistics, {
propsData: {
rootStorageStatistics: {
......@@ -19,9 +19,6 @@ describe('UsageStatistics', () => {
...props,
},
provide: {
glFeatures: {
newRouteStoragePurchase,
},
...provide,
},
stubs: {
......@@ -45,29 +42,12 @@ describe('UsageStatistics', () => {
const findPurchasedUsageButton = () =>
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', () => {
beforeEach(() => {
createComponent({
provide: {
purchaseStorageUrl: 'some-fancy-url',
buyAddonTargetAttr: '_self',
},
});
});
......@@ -89,6 +69,24 @@ describe('UsageStatistics', () => {
});
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({
href: 'some-fancy-url',
target: '_blank',
......@@ -101,6 +99,7 @@ describe('UsageStatistics', () => {
createComponent({
provide: {
purchaseStorageUrl: null,
buyAddonTargetAttr: '_self',
},
});
});
......
......@@ -156,6 +156,7 @@ export const defaultProjectProvideValues = {
export const defaultNamespaceProvideValues = {
namespacePath: 'h5bp',
purchaseStorageUrl: '',
buyAddonTargetAttr: '_blank',
isTemporaryStorageIncreaseVisible: false,
helpLinks: projectHelpLinks,
};
......
......@@ -196,45 +196,18 @@ RSpec.describe EE::NamespacesHelper do
it { is_expected.to eq buy_storage_subscriptions_path(selected_group: namespace.id) }
context 'new_route_storage_purchase' do
context 'when is disabled' do
before do
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) }
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
expect(helper.buy_storage_path(personal_namespace)).to eq EE::SUBSCRIPTIONS_MORE_STORAGE_URL
end
it 'returns the default purchase' do
expect(helper.buy_storage_path(personal_namespace)).to eq EE::SUBSCRIPTIONS_MORE_STORAGE_URL
end
end
end
describe '#buy_additional_minutes_target' do
subject { helper.buy_additional_minutes_target(namespace) }
describe '#buy_addon_target_attr' do
subject { helper.buy_addon_target_attr(namespace) }
let(:namespace) { create(:group) }
......@@ -245,7 +218,7 @@ RSpec.describe EE::NamespacesHelper do
let(:personal_namespace) { build_stubbed(:user_namespace) }
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
......
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