Skip to content

Unify expired subscription message buttons

Diana Zubova requested to merge dz/340811-unify-expired-messages-cta into master

What does this MR do and why?

Unify labels on main CTA so we could spare on translations (the Renew Subsciription has more translations added)

Related to #340811 (closed)

Screenshots or screen recordings

--- Before After
SaaS expiring Screenshot_2021-09-14_at_13.03.40 Screenshot_2021-09-20_at_15.19.15
SaaS expired (0 to 14 days) Screenshot_2021-09-14_at_13.00.52 Screenshot_2021-09-20_at_15.27.29
SaaS expired (15 to 30 days) Screenshot_2021-09-14_at_13.01.26 Screenshot_2021-09-20_at_15.23.16
SelfManaged expired Screenshot_2021-09-20_at_15.34.17 Screenshot_2021-09-20_at_15.28.49

How to set up and validate locally

We don't expect changes to expiration notifications

Both SaaS and SelfManaged notification about subscription expiration should appear as expected.

To check visually that everything is working as it should:

SelfManaged

  1. Apply expired license and check notification

SaaS

  1. Create a new group
  2. Add a Premium/Ultimate subscription to it

We would need to emulate the expired subscription for this group. There is a patch you need to apply under the spoiler. I didn't find a better way for it, please let me know if there is one 😸

Patch
diff --git a/ee/app/models/gitlab_subscription.rb b/ee/app/models/gitlab_subscription.rb
index 7d81f3ebbc5..08be5aed565 100644
--- a/ee/app/models/gitlab_subscription.rb
+++ b/ee/app/models/gitlab_subscription.rb
@@ -81,6 +81,7 @@ def has_a_paid_hosted_plan?(include_trials: false)
   end
 
   def expired?
+    return true
     return false unless end_date
 
     end_date < Date.current
diff --git a/ee/app/presenters/subscription_presenter.rb b/ee/app/presenters/subscription_presenter.rb
index b726876e4aa..08c5ec00f79 100644
--- a/ee/app/presenters/subscription_presenter.rb
+++ b/ee/app/presenters/subscription_presenter.rb
@@ -22,13 +22,15 @@ def notify_users?
   end
 
   def expires_at
-    end_date
+    # end_date
+    end_date - 385
   end
 
   def block_changes_at
     return unless end_date
 
-    end_date + GRACE_PERIOD_EXTENSION_DAYS
+    # end_date + GRACE_PERIOD_EXTENSION_DAYS
+    end_date + GRACE_PERIOD_EXTENSION_DAYS - 385
   end
 
   def remaining_days
diff --git a/ee/lib/gitlab/expiring_subscription_message.rb b/ee/lib/gitlab/expiring_subscription_message.rb
index 76e57d5c1d6..ac6d5e92f63 100644
--- a/ee/lib/gitlab/expiring_subscription_message.rb
+++ b/ee/lib/gitlab/expiring_subscription_message.rb
@@ -9,7 +9,11 @@ class ExpiringSubscriptionMessage
 
     attr_reader :subscribable, :signed_in, :is_admin, :namespace, :force_notification
 
-    delegate :auto_renew, to: :subscribable
+    # delegate :auto_renew, to: :subscribable
+    def auto_renew
+      # We show a different message if auto_renew is enabled
+      return false
+    end
 
     def initialize(subscribable:, signed_in:, is_admin:, namespace: nil, force_notification: false)
       @subscribable = subscribable
@@ -159,7 +163,9 @@ def plan_name
     end
 
     def plan_downgraded?
-      plan_name.downcase == ::Plan::FREE
+      # plan_name.downcase == ::Plan::FREE
+      # we don't show the post expiration message if the group is not yet downgraded
+      return true
     end
 
     def show_downgrade_messaging?
1. Open the group page http://localhost:3000/groups/name-of-the-group and check the notification message

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 Diana Zubova

Merge request reports