From 1d968436695609d378cb14c81ad84560c4e3f614 Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Wed, 28 Aug 2024 16:40:51 -0300 Subject: [PATCH 1/3] Swaps the registry key for Landscape enablement s/ShowLandscapeConfig/HideLandscapeConfig/g If nothing is set, then: - Landscape is enabled - Store purchase is disabled. If HideLandscapeConfig is 1, Landscape configuration UI elements are hidden. --- gui/packages/ubuntupro/lib/core/settings.dart | 11 ++++++----- gui/packages/ubuntupro/test/core/settings_test.dart | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gui/packages/ubuntupro/lib/core/settings.dart b/gui/packages/ubuntupro/lib/core/settings.dart index 05780bce9..782bc2e31 100644 --- a/gui/packages/ubuntupro/lib/core/settings.dart +++ b/gui/packages/ubuntupro/lib/core/settings.dart @@ -12,9 +12,9 @@ class Settings { final purchase = repository.readInt(kAllowStorePurchase) == 1 ? Options.withStorePurchase : Options.none; - final landscape = repository.readInt(kShowLandscapeConfig) == 1 - ? Options.withLandscapeConfiguration - : Options.none; + final landscape = repository.readInt(kHideLandscapeConfig) == 1 + ? Options.none + : Options.withLandscapeConfiguration; repository.close(); @@ -25,7 +25,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 +36,7 @@ class Settings { @visibleForTesting static const kAllowStorePurchase = 'AllowStorePurchase'; @visibleForTesting - static const kShowLandscapeConfig = 'ShowLandscapeConfig'; + static const kHideLandscapeConfig = 'HideLandscapeConfig'; } /// 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..649b2ced5 100644 --- a/gui/packages/ubuntupro/test/core/settings_test.dart +++ b/gui/packages/ubuntupro/test/core/settings_test.dart @@ -38,7 +38,7 @@ void main() { test('all', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(true); - when(repository.readInt(Settings.kShowLandscapeConfig)).thenReturn(1); + when(repository.readInt(Settings.kHideLandscapeConfig)).thenReturn(null); when(repository.readInt(Settings.kAllowStorePurchase)).thenReturn(1); final settings = Settings(repository); @@ -49,7 +49,7 @@ void main() { test('Landscape', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(true); - when(repository.readInt(Settings.kShowLandscapeConfig)).thenReturn(1); + when(repository.readInt(Settings.kHideLandscapeConfig)).thenReturn(null); when(repository.readInt(Settings.kAllowStorePurchase)).thenReturn(0); final settings = Settings(repository); @@ -60,7 +60,7 @@ void main() { test('purchase', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(true); - when(repository.readInt(Settings.kShowLandscapeConfig)).thenReturn(0); + when(repository.readInt(Settings.kHideLandscapeConfig)).thenReturn(1); when(repository.readInt(Settings.kAllowStorePurchase)).thenReturn(1); final settings = Settings(repository); @@ -71,7 +71,7 @@ void main() { test('none', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(true); - when(repository.readInt(Settings.kShowLandscapeConfig)).thenReturn(null); + when(repository.readInt(Settings.kHideLandscapeConfig)).thenReturn(1); when(repository.readInt(Settings.kAllowStorePurchase)).thenReturn(null); final settings = Settings(repository); @@ -85,7 +85,7 @@ void main() { final settings = Settings(repository); - expect(settings.isLandscapeConfigurationEnabled, isFalse); + expect(settings.isLandscapeConfigurationEnabled, isTrue); expect(settings.isStorePurchaseAllowed, isFalse); }); }); From 26cd15a2b14286388c8898acde749d3dea5348de Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Wed, 28 Aug 2024 16:53:07 -0300 Subject: [PATCH 2/3] Update dev docs Move the Landscape section downwards, as I doubt people finds relevant how to disable it. Update the related verbiage and registry value name. Update the filename as it's now for disabling features as well. --- ...t-in-features.md => 07-toggle-features.md} | 32 +++++++++++-------- docs/dev/howto/index.md | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) rename docs/dev/howto/{07-enable-opt-in-features.md => 07-toggle-features.md} (56%) 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..dcb57f248 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 `HideLandscapeConfig` 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. +If that value is not present or set to anything other than `1`, 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 ``` From a6c025d387a56b3957ac74412f197c77fbd9189c Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Fri, 30 Aug 2024 10:33:46 -0300 Subject: [PATCH 3/3] [NEW!!!] Renames reg to LandscapeConfigVisibility That doesn't necessarily convey what the default is. Thus we can more freely switch without surprising new users. LandscapeConfigVisibility == 0 => Hides the UI Otherwise, enabled (the default). --- docs/dev/howto/07-toggle-features.md | 4 ++-- gui/packages/ubuntupro/lib/core/settings.dart | 7 +++++-- .../ubuntupro/test/core/settings_test.dart | 14 +++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/dev/howto/07-toggle-features.md b/docs/dev/howto/07-toggle-features.md index dcb57f248..de9e4c649 100644 --- a/docs/dev/howto/07-toggle-features.md +++ b/docs/dev/howto/07-toggle-features.md @@ -24,10 +24,10 @@ Landscape configuration page and related buttons are enabled by default, but can 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 `HideLandscapeConfig` and set it to `1`. +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 `1`, Landscape configuration page +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/gui/packages/ubuntupro/lib/core/settings.dart b/gui/packages/ubuntupro/lib/core/settings.dart index 782bc2e31..ae73f6bdf 100644 --- a/gui/packages/ubuntupro/lib/core/settings.dart +++ b/gui/packages/ubuntupro/lib/core/settings.dart @@ -9,10 +9,13 @@ 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(kHideLandscapeConfig) == 1 + + // Hide Landscape UI if the registry value is 0. + final landscape = repository.readInt(kLandscapeConfigVisibility) == 0 ? Options.none : Options.withLandscapeConfiguration; @@ -36,7 +39,7 @@ class Settings { @visibleForTesting static const kAllowStorePurchase = 'AllowStorePurchase'; @visibleForTesting - static const kHideLandscapeConfig = 'HideLandscapeConfig'; + 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 649b2ced5..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.kHideLandscapeConfig)).thenReturn(null); + 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.kHideLandscapeConfig)).thenReturn(null); + 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.kHideLandscapeConfig)).thenReturn(1); + 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.kHideLandscapeConfig)).thenReturn(1); + when(repository.readInt(Settings.kLandscapeConfigVisibility)) + .thenReturn(0); when(repository.readInt(Settings.kAllowStorePurchase)).thenReturn(null); final settings = Settings(repository); @@ -79,7 +83,7 @@ void main() { expect(settings.isLandscapeConfigurationEnabled, isFalse); expect(settings.isStorePurchaseAllowed, isFalse); }); - test('unset', () { + test('unset (defaults)', () { final repository = MockSettingsRepository(); when(repository.load()).thenReturn(false);