diff --git a/gui/packages/ubuntupro/lib/pages/subscription_status/subscribe_now_page.dart b/gui/packages/ubuntupro/lib/pages/subscription_status/subscribe_now_page.dart index aa75c1fab..559290e0f 100644 --- a/gui/packages/ubuntupro/lib/pages/subscription_status/subscribe_now_page.dart +++ b/gui/packages/ubuntupro/lib/pages/subscription_status/subscribe_now_page.dart @@ -28,11 +28,11 @@ class SubscribeNowPage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, children: [ Tooltip( - message: model.isPurchaseAllowed() + message: model.purchaseAllowed() ? '' : lang.subscribeNowTooltipDisabled, child: ElevatedButton( - onPressed: model.isPurchaseAllowed() + onPressed: model.purchaseAllowed() ? () async { final subs = await model.purchaseSubscription(); diff --git a/gui/packages/ubuntupro/lib/pages/subscription_status/subscription_status_model.dart b/gui/packages/ubuntupro/lib/pages/subscription_status/subscription_status_model.dart index 2171412e5..fea939ac5 100644 --- a/gui/packages/ubuntupro/lib/pages/subscription_status/subscription_status_model.dart +++ b/gui/packages/ubuntupro/lib/pages/subscription_status/subscription_status_model.dart @@ -105,7 +105,7 @@ class SubscribeNowModel extends SubscriptionStatusModel { /// Returns true if the environment variable 'UP4W_ALLOW_STORE_PURCHASE' has been set. /// Since this reading won't change during the app lifetime, even if the user changes /// it's value from outside, the value is cached so we don't check the environment more than once. - bool isPurchaseAllowed() { + bool purchaseAllowed() { return _isPurchaseAllowed ??= ['true', '1', 'on'] .contains(Environment()['UP4W_ALLOW_STORE_PURCHASE']?.toLowerCase()); } diff --git a/gui/packages/ubuntupro/test/pages/subscription_status/subscription_status_model_test.dart b/gui/packages/ubuntupro/test/pages/subscription_status/subscription_status_model_test.dart index 71aafac2d..af164fa7c 100644 --- a/gui/packages/ubuntupro/test/pages/subscription_status/subscription_status_model_test.dart +++ b/gui/packages/ubuntupro/test/pages/subscription_status/subscription_status_model_test.dart @@ -99,7 +99,7 @@ void main() { test('disabled by default', () { final model = SubscribeNowModel(client); - expect(model.isPurchaseAllowed(), isFalse); + expect(model.purchaseAllowed(), isFalse); }); test('expected failure', () async {