Skip to content

Make storage banner CTA consistent across severity levels

What does this MR do?

Related to #267978 (closed)

Currently our "Manage storage" button mirrors the alert style. This means that once a project is locked, we show a danger style alert and danger style button. Meaning a destructive looking button of "Manage storage" is shown to the user.

This MR locks down the "Manage storage" button into an info button.

We're also conditionally showing a "Purchase more storage" button, but only at the error level. We want to enable users to proactively purchase storage before they run out.

Screenshots

Before After
Screenshot_2020-10-19_at_15.26.17 Screenshot_2020-10-19_at_15.25.46
Screenshot_2020-10-19_at_15.26.11 Screenshot_2020-10-19_at_15.25.35

Testing this locally

Requires EE edition

# Match the 10GB limit on GitLab.com, enable application setting
ApplicationSettings::UpdateService.new(Gitlab::CurrentSettings.current_application_settings, nil, { repository_size_limit: 10240, automatic_purchased_storage_allocation: true }).execute

Feature.enable(:buy_storage_link)
Feature.enable(:additional_repo_storage_by_namespace)

ACCESS_LEVEL_OWNER = 50
PACKAGE_SIZE_IN_MIB = 10240

def create_group_with_usage_and_additional_storage(owner, group_name, nr_of_packs_purchased, usage)
  group = Group.create(name: group_name, path: group_name, type: 'Group')
  GroupMember.add_user(group, owner, ACCESS_LEVEL_OWNER)
  project = ::Projects::CreateService.new(owner, { namespace_id: group.id, name: 'project-' + group_name, path: 'project-' + group_name }).execute

  group.additional_purchased_storage_size = nr_of_packs_purchased * PACKAGE_SIZE_IN_MIB
  group.save!

  project.statistics&.destroy!

  project_statistics = ProjectStatistics.new(
    project_id: project.id,
    namespace_id: group.id,
    commit_count: 12,
    repository_size: usage * 3 / 5,
    lfs_objects_size: usage * 2 / 5
  )

  project_statistics.save!
end

root_user = User.where(username: 'root').first

create_group_with_usage_and_additional_storage(root_user, 'over-free-limit', 0, 20.gigabytes)
create_group_with_usage_and_additional_storage(root_user, 'over-purchased-limit', 1, 30.gigabytes)
create_group_with_usage_and_additional_storage(root_user, 'warning-with-purchase', 1, 17.gigabytes)

Navigate to http://localhost:3000/over-purchased-limit to see alert.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Ragnar Hardarson

Merge request reports