Commit d7d09608 authored by Sean McGivern's avatar Sean McGivern

Merge branch '258189_add_purchase_storage_button_to_storage_banners' into 'master'

Add purchase storage button to storage banners

See merge request gitlab-org/gitlab!45159
parents 35032389 ab8eecc1
...@@ -46,6 +46,15 @@ module EE ...@@ -46,6 +46,15 @@ module EE
end end
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) def namespace_storage_usage_link(namespace)
if namespace.group? if namespace.group?
group_usage_quotas_path(namespace, anchor: 'storage-quota-tab') group_usage_quotas_path(namespace, anchor: 'storage-quota-tab')
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
- style = namespace_storage_alert_style(alert_level) - style = namespace_storage_alert_style(alert_level)
- icon = namespace_storage_alert_icon(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-py-5
.gl-alert.js-namespace-storage-alert{ class: "gl-alert-#{style}", role: 'alert' } .gl-alert.js-namespace-storage-alert{ class: "gl-alert-#{style}", role: 'alert' }
...@@ -24,6 +27,9 @@ ...@@ -24,6 +27,9 @@
= sprite_icon('close', css_class: 'gl-icon') = sprite_icon('close', css_class: 'gl-icon')
.gl-alert-body .gl-alert-body
= payload[:explanation_message] = payload[:explanation_message]
- if link - if show_storage_banner_actions
.gl-alert-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 ...@@ -144,4 +144,40 @@ RSpec.describe EE::NamespaceStorageLimitAlertHelper do
it { is_expected.to eq(result) } it { is_expected.to eq(result) }
end end
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 end
...@@ -21365,6 +21365,9 @@ msgstr "" ...@@ -21365,6 +21365,9 @@ msgstr ""
msgid "Purchase more minutes" msgid "Purchase more minutes"
msgstr "" msgstr ""
msgid "Purchase more storage"
msgstr ""
msgid "Push" msgid "Push"
msgstr "" 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