Usage quota storage alert

What does this MR do?

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/247839

As part of the storage usage we want explanatory text for the user at the top of the Usage Quota page.

Screenshots

No purchase, below free limit

Screenshot_2020-10-07_at_19.54.16

No purchase, above free limit

Screenshot_2020-10-07_at_19.52.34

Has purchase, below free limit

Screenshot_2020-10-07_at_19.52.37

Has purchase, approaching extra storage limit (75% usage)

Screenshot_2020-10-07_at_19.52.40

Has purchase, above purchased limit

Screenshot_2020-10-07_at_19.52.52

Testing this locally

Requires EE version.

Apply the following two patches to this branch

Run the following in your bin/rails console

ACCESS_LEVEL_OWNER = 50
def create_group_with_usage_and_additional_storage(owner, group_name, additional_storage, 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 = additional_storage
  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

create_group_with_usage_and_additional_storage(root_user, 'over-free-limit', 0, 2.074e+10)
create_group_with_usage_and_additional_storage(root_user, 'under-free-limit-no-purchase', 0, 0.074e+10)
create_group_with_usage_and_additional_storage(root_user, 'over-purchased-limit', 1.074e+10, 3.074e+10)
create_group_with_usage_and_additional_storage(root_user, 'warning-with-purchase', 1.074e+10, 2.001e+10)
create_group_with_usage_and_additional_storage(root_user, 'under-free-limit-with-purchase', 1.074e+10, 0.5e+10)

Log in as root

Navigate to Usage Quota of your newly created groups, for example http://localhost:3000/groups/over-purchased-limit/-/usage_quotas#storage-quota-tab

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

Loading