Add logic for manual quarterly co-term banner
What does this MR do and why?
Part of https://gitlab.com/gitlab-org/gitlab/-/issues/346260
This change will add the backend logic for the manual quarterly co-term banner that will be displayed to offline customers that have restricted internet access. The logic is behind a feature flag.
The banner will only be displayed for customers with a self-managed cloud license but have restricted internet access that prevents their instance to do the quarterly co-term automatically and have to take manual action. The condition to determine an offline customer is still under discussion though and therefore not added yet. Since the feature is behind a feature flag, the missing condition can be added at a later time.
The banner will show up for upcoming quarterly co-terms within the next 14 days (notification window) or for overdue quarterly co-terms.
To see the banner, the customer has to be logged in as an admin and can see the banner on the admin dashboard (/admin
) and the subscription page (/admin/subscription
).
Please see the issue for more information.
How to set up and validate locally
The code can be tested in the rails console. Two different upcoming reconciliations have to be created to see the two different versions of the banner message.
- Start a rails console.
- Enable the feature flag:
Feature.enable(:automated_email_provision)
. - Make sure that
Gitlab::CurrentSettings.check_namespace_plan?
returnsfalse
or you won't be able to create a new recordGitlabSubscriptions::UpcomingReconciliation
record later. - If it returns
true
, doApplicationSetting.first.update(check_namespace_plan: false)
. - Check if you already have a
GitlabSubscriptions::UpcomingReconciliation
record:reconciliation = GitlabSubscriptions::UpcomingReconciliation.next
. - If one exists, update it to display the banner:
date = 14.days.from_now; reconciliation.update(next_reconciliation_date: date, display_alert_from: date - 7.days)
- If none exists, create one:
date = 14.days.from_now; reconciliation = GitlabSubscriptions::UpcomingReconciliation.create!(next_reconciliation_date: date, display_alert_from: date - 7.days)
- Call the class
Gitlab::ManualQuarterlyCoTermBannerMessage.new(upcoming_reconciliation: reconciliation).message
and see the appropriate messages. - Update the reconciliation record from above to be overdue:
date = Date.yesterday; reconciliation.update(next_reconciliation_date: date, display_alert_from: date - 7.days)
- Call the class
Gitlab::ManualQuarterlyCoTermBannerMessage.new(upcoming_reconciliation: reconciliation).message
and see the appropriate messages.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.