Skip to content

Update notification logic to be admin controlled

Mohamed Hamda requested to merge reached_notification_limit into master

What does this MR do and why?

This MR relates to https://gitlab.com/gitlab-org/gitlab/-/issues/385725

[BE] Update notification logic to be admin controlled

Once a notification limit is set, the notification will display for any namespace that’s at or above the threshold defined.

Considering the total namespace storage limit (free limit + purchased storage)

  • If the namespace reduces its storage below the active notification limits, it will stop seeing the in-app notifications.

  • If a namespace increases its storage above the notification limit, it will start seeing the in-app notification.

  • If a namespace has been excluded from storage limits (https://gitlab.com/gitlab-org/gitlab/-/issues/385723), do not display any notification

  • Add an extra check for reached_pre_enforcement_notification_limit?

  • Remove the hard-coded value for usage check

Local testing

# Enable feature flag:
::Feature.enable(:namespace_storage_limit_show_preenforcement_banner)

# ensuring we're not enforcing limits, which shows a different banner:
::Gitlab::CurrentSettings.update(enforce_namespace_storage_limit: false)

# set a notification limit (I adjusted this to test different scenarios over/below/0):
my_group.actual_limits.update(notification_limit: 100)

# setup my group to have a storage size greater than my notification limit
my_group.root_storage_statistics.update(storage_size: 1024.megabytes)

Screenshot:

Screenshot_2023-05-04_at_11.46.09

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mohamed Hamda

Merge request reports

Loading