diff options
Diffstat (limited to 'app/helpers/storage_helper.rb')
-rw-r--r-- | app/helpers/storage_helper.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/app/helpers/storage_helper.rb b/app/helpers/storage_helper.rb index 34ba66db444..a075ccc38f5 100644 --- a/app/helpers/storage_helper.rb +++ b/app/helpers/storage_helper.rb @@ -25,16 +25,17 @@ module StorageHelper end def storage_enforcement_banner_info(namespace) + return unless can?(current_user, :admin_namespace, namespace) return if namespace.paid? return unless namespace.storage_enforcement_date && namespace.storage_enforcement_date >= Date.today return if user_dismissed_storage_enforcement_banner?(namespace) { text: html_escape_once(s_("UsageQuota|From %{storage_enforcement_date} storage limits will apply to this namespace. " \ - "View and manage your usage in %{strong_start}Group Settings > Usage quotas%{strong_end}.")).html_safe % - { storage_enforcement_date: namespace.storage_enforcement_date, strong_start: "<strong>".html_safe, strong_end: "</strong>".html_safe }, + "View and manage your usage in %{strong_start}%{namespace_type} settings > Usage quotas%{strong_end}.")).html_safe % + { storage_enforcement_date: namespace.storage_enforcement_date, strong_start: "<strong>".html_safe, strong_end: "</strong>".html_safe, namespace_type: namespace.type }, variant: 'warning', - callouts_path: group_callouts_path, + callouts_path: namespace.user_namespace? ? callouts_path : group_callouts_path, callouts_feature_name: storage_enforcement_banner_user_callouts_feature_name(namespace), learn_more_link: link_to(_('Learn more.'), help_page_path('/'), rel: 'noopener noreferrer', target: '_blank') # TBD: https://gitlab.com/gitlab-org/gitlab/-/issues/350632 } @@ -52,13 +53,17 @@ module StorageHelper return :first if days_to_enforcement_date > 30 return :second if days_to_enforcement_date > 15 && days_to_enforcement_date <= 30 return :third if days_to_enforcement_date > 7 && days_to_enforcement_date <= 15 - return :fourth if days_to_enforcement_date > 0 && days_to_enforcement_date <= 7 + return :fourth if days_to_enforcement_date >= 0 && days_to_enforcement_date <= 7 end def user_dismissed_storage_enforcement_banner?(namespace) return false unless current_user - current_user.dismissed_callout_for_group?(feature_name: storage_enforcement_banner_user_callouts_feature_name(namespace), - group: namespace) + if namespace.user_namespace? + current_user.dismissed_callout?(feature_name: storage_enforcement_banner_user_callouts_feature_name(namespace)) + else + current_user.dismissed_callout_for_group?(feature_name: storage_enforcement_banner_user_callouts_feature_name(namespace), + group: namespace) + end end end |