diff --git a/docs/dev/howto/07-enable-opt-in-features.md b/docs/dev/howto/07-toggle-features.md similarity index 56% rename from docs/dev/howto/07-enable-opt-in-features.md rename to docs/dev/howto/07-toggle-features.md index 9de6e2b28..de9e4c649 100644 --- a/docs/dev/howto/07-enable-opt-in-features.md +++ b/docs/dev/howto/07-toggle-features.md @@ -1,19 +1,9 @@ # How to enable opt-in features -Some features in UP4W are opt-in. While the code is arranged such that CI -always tests with those features enabled, when running UP4W on your machine, -you need to enable them explicitly via the Windows registry. This guide shows -you how to do that. - -## Enable Landscape configuration in the GUI - -1. Open the Windows registry editor: press `Win + R`, type `regedit` and press `Enter`. -1. Navigate to the following key: `HKEY_CURRENT_USER\Software\Canonical\UbuntuPro\`. -1. Create a new DWORD value named `ShowLandscapeConfig` and set it to `1`. - -The next time you open the GUI, you'll find that the Landscape configuration -page can be shown via the set up wizard or by clicking on the 'Configure -Landscape' button. +Some features in UP4W are opt-in or can be toggled on and off via the Windows Registry. +While the code is arranged such that CI always tests with those features enabled, +when running UP4W on your machine, you may need to toggle them on and off +explicitly via the Windows registry. This guide shows you how to do that. ## Enable subscribing via the Microsoft Store @@ -27,3 +17,17 @@ Pro via the Microsoft Store. ```{warning} Beware that can incur in real charges if you proceed with the purchase. ``` + +## Disable Landscape configuration in the GUI + +Landscape configuration page and related buttons are enabled by default, but can be disabled via registry. + +1. Open the Windows registry editor: press `Win + R`, type `regedit` and press `Enter`. +1. Navigate to the following key: `HKEY_CURRENT_USER\Software\Canonical\UbuntuPro\`. +1. Create a new DWORD value named `LandscapeConfigVisibility` and set it to `0`. + +The next time you open the GUI, you'll find that the Landscape configuration +page can be shown via the set up wizard or by clicking on the 'Configure +Landscape' button. +If that value is not present or set to anything other than `0`, Landscape configuration page +and related buttons will be visible. diff --git a/docs/dev/howto/index.md b/docs/dev/howto/index.md index e6e1ad303..b5db4c6a0 100644 --- a/docs/dev/howto/index.md +++ b/docs/dev/howto/index.md @@ -10,6 +10,6 @@ These how-to guides cover key operations and processes in Ubuntu Pro for WSL. Install UP4W <02-install> Restart UP4W <03-restart> Access UP4W logs <06-access-the-logs> -Enable opt-in features <07-enable-opt-in-features> +Enable opt-in features <07-toggle-features> Reset UP4W ``` diff --git a/gui/packages/ubuntupro/lib/core/settings.dart b/gui/packages/ubuntupro/lib/core/settings.dart index 05780bce9..ae73f6bdf 100644 --- a/gui/packages/ubuntupro/lib/core/settings.dart +++ b/gui/packages/ubuntupro/lib/core/settings.dart @@ -9,12 +9,15 @@ class Settings { Settings(SettingsRepository repository) { if (!repository.load()) return; + // Enable store purchase if the registry value is 1. final purchase = repository.readInt(kAllowStorePurchase) == 1 ? Options.withStorePurchase : Options.none; - final landscape = repository.readInt(kShowLandscapeConfig) == 1 - ? Options.withLandscapeConfiguration - : Options.none; + + // Hide Landscape UI if the registry value is 0. + final landscape = repository.readInt(kLandscapeConfigVisibility) == 0 + ? Options.none + : Options.withLandscapeConfiguration; repository.close(); @@ -25,7 +28,8 @@ class Settings { /// Useful for integration testing. Settings.withOptions(this._options); - Options _options = Options.none; + /// By default Landscape is enabled and Store purchase is disabled. + Options _options = Options.withLandscapeConfiguration; bool get isLandscapeConfigurationEnabled => _options & Options.withLandscapeConfiguration; @@ -35,7 +39,7 @@ class Settings { @visibleForTesting static const kAllowStorePurchase = 'AllowStorePurchase'; @visibleForTesting - static const kShowLandscapeConfig = 'ShowLandscapeConfig'; + static const kLandscapeConfigVisibility = 'LandscapeConfigVisibility'; } /// Settings options modelled as an enum with bitwise operations, i.e. flags. diff --git a/gui/packages/ubuntupro/test/core/settings_test.dart b/gui/packages/ubuntupro/test/core/settings_test.dart index 95de37808..59e0a4420 100644 --- a/gui/packages/ubuntupro/test/core/settings_test.dart +++ b/gui/packages/ubuntupro/test/core/settings_test.dart @@ -38,7 +38,8 @@ void main() { test('all', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(true); - when(repository.readInt(Settings.kShowLandscapeConfig)).thenReturn(1); + when(repository.readInt(Settings.kLandscapeConfigVisibility)) + .thenReturn(null); when(repository.readInt(Settings.kAllowStorePurchase)).thenReturn(1); final settings = Settings(repository); @@ -49,7 +50,8 @@ void main() { test('Landscape', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(true); - when(repository.readInt(Settings.kShowLandscapeConfig)).thenReturn(1); + when(repository.readInt(Settings.kLandscapeConfigVisibility)) + .thenReturn(null); when(repository.readInt(Settings.kAllowStorePurchase)).thenReturn(0); final settings = Settings(repository); @@ -60,7 +62,8 @@ void main() { test('purchase', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(true); - when(repository.readInt(Settings.kShowLandscapeConfig)).thenReturn(0); + when(repository.readInt(Settings.kLandscapeConfigVisibility)) + .thenReturn(0); when(repository.readInt(Settings.kAllowStorePurchase)).thenReturn(1); final settings = Settings(repository); @@ -71,7 +74,8 @@ void main() { test('none', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(true); - when(repository.readInt(Settings.kShowLandscapeConfig)).thenReturn(null); + when(repository.readInt(Settings.kLandscapeConfigVisibility)) + .thenReturn(0); when(repository.readInt(Settings.kAllowStorePurchase)).thenReturn(null); final settings = Settings(repository); @@ -79,13 +83,13 @@ void main() { expect(settings.isLandscapeConfigurationEnabled, isFalse); expect(settings.isStorePurchaseAllowed, isFalse); }); - test('unset', () { + test('unset (defaults)', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(false); final settings = Settings(repository); - expect(settings.isLandscapeConfigurationEnabled, isFalse); + expect(settings.isLandscapeConfigurationEnabled, isTrue); expect(settings.isStorePurchaseAllowed, isFalse); }); });