Commit ab8eecc1 authored by Corinna Wiesner's avatar Corinna Wiesner Committed by Sean McGivern

Add purchase storage button to storage banners

Add a button to purchase storage to the new version of the storage
banners.
parent ca29a313
......@@ -46,6 +46,15 @@ module EE
end
end
def namespace_storage_purchase_link(namespace)
return unless ::Gitlab.dev_env_or_com?
return unless ::Gitlab::CurrentSettings.automatic_purchased_storage_allocation?
return unless ::Feature.enabled?(:buy_storage_link)
return unless ::Feature.enabled?(:additional_repo_storage_by_namespace, namespace)
EE::SUBSCRIPTIONS_MORE_STORAGE_URL
end
def namespace_storage_usage_link(namespace)
if namespace.group?
group_usage_quotas_path(namespace, anchor: 'storage-quota-tab')
......
......@@ -12,7 +12,10 @@
- style = namespace_storage_alert_style(alert_level)
- icon = namespace_storage_alert_icon(alert_level)
- link = namespace_storage_usage_link(root_namespace)
- purchase_link = namespace_storage_purchase_link(root_namespace)
- show_purchase_link = purchase_link && alert_level == :error
- usage_link = namespace_storage_usage_link(root_namespace)
- show_storage_banner_actions = show_purchase_link || usage_link
.gl-py-5
.gl-alert.js-namespace-storage-alert{ class: "gl-alert-#{style}", role: 'alert' }
......@@ -24,6 +27,9 @@
= sprite_icon('close', css_class: 'gl-icon')
.gl-alert-body
= payload[:explanation_message]
- if link
- if show_storage_banner_actions
.gl-alert-actions
= link_to(_('Manage storage usage'), link, class: "btn gl-alert-action btn-md gl-button btn-#{style}")
- if show_purchase_link
= link_to(_('Purchase more storage'), purchase_link, class: "btn gl-alert-action btn-md gl-button btn-success")
- if usage_link
= link_to(_('Manage storage usage'), usage_link, class: "btn gl-alert-action btn-md gl-button btn-#{style}")
......@@ -144,4 +144,40 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do
it { is_expected.to eq(result) }
end
end
describe '#namespace_storage_purchase_link' do
subject { helper.namespace_storage_purchase_link(namespace) }
let(:namespace) { build(:namespace) }
where(:is_dev_or_com, :auto_storage_allocation_enabled, :buy_storage_link_enabled, :additional_storage_enabled, :result) do
true | true | true | true | EE::SUBSCRIPTIONS_MORE_STORAGE_URL
true | true | true | false | nil
true | true | false | true | nil
true | true | false | false | nil
true | false | true | true | nil
true | false | true | false | nil
true | false | false | true | nil
true | false | false | false | nil
false | true | true | true | nil
false | true | true | false | nil
false | true | false | true | nil
false | true | false | false | nil
false | false | true | true | nil
false | false | true | false | nil
false | false | false | true | nil
false | false | false | false | nil
end
with_them do
before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(is_dev_or_com)
stub_application_setting(automatic_purchased_storage_allocation: auto_storage_allocation_enabled)
stub_feature_flags(additional_repo_storage_by_namespace: additional_storage_enabled)
stub_feature_flags(buy_storage_link: buy_storage_link_enabled)
end
it { is_expected.to eq(result) }
end
end
end
......@@ -21281,6 +21281,9 @@ msgstr ""
msgid "Purchase more minutes"
msgstr ""
msgid "Purchase more storage"
msgstr ""
msgid "Push"
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