Skip to content

Commit

Permalink
[GPO]Add setting to disallow experimentation (#24131)
Browse files Browse the repository at this point in the history
* [GPO]Add policy to disallow experimentation

* Refresh experimentation setting UI

* Reflect gpo value in Settings UI

* Fix adml errors

* Update src/settings-ui/Settings.UI/Strings/en-us/Resources.resw

* Update src/settings-ui/Settings.UI/Strings/en-us/Resources.resw

* Update src/gpo/assets/en-US/PowerToys.adml

* Small grammar fixes

* Update src/gpo/assets/en-US/PowerToys.adml

---------

Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
  • Loading branch information
jaimecbernardo and htcfreek committed Feb 17, 2023
1 parent df521b4 commit 27d8beb
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 13 deletions.
8 changes: 8 additions & 0 deletions doc/gpo/README.md
Expand Up @@ -31,3 +31,11 @@ If you enable this setting, the utility will be always enabled and the user won'
If you disable this setting, the utility will be always disabled and the user won't be able to enable it.

If you don't configure this setting, users are able to disable or enable the utility.

### Allow experimentation

This policy configures whether PowerToys experimentation is allowed.

Disable this setting to disable the experimentation features in PowerToys, meaning the user won't see the new features being experimented even if it gets selected as part of the test group.

If this setting is not configured, experimentation is allowed.
4 changes: 4 additions & 0 deletions src/common/GPOWrapper/GPOWrapper.cpp
Expand Up @@ -112,4 +112,8 @@ namespace winrt::PowerToys::GPOWrapper::implementation
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredVideoConferenceMuteEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetAllowExperimentationValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getAllowExperimentationValue());
}
}
1 change: 1 addition & 0 deletions src/common/GPOWrapper/GPOWrapper.h
Expand Up @@ -34,6 +34,7 @@ namespace winrt::PowerToys::GPOWrapper::implementation
static GpoRuleConfigured GetConfiguredShortcutGuideEnabledValue();
static GpoRuleConfigured GetConfiguredTextExtractorEnabledValue();
static GpoRuleConfigured GetConfiguredVideoConferenceMuteEnabledValue();
static GpoRuleConfigured GetAllowExperimentationValue();
};
}

Expand Down
1 change: 1 addition & 0 deletions src/common/GPOWrapper/GPOWrapper.idl
Expand Up @@ -38,6 +38,7 @@ namespace PowerToys
static GpoRuleConfigured GetConfiguredShortcutGuideEnabledValue();
static GpoRuleConfigured GetConfiguredTextExtractorEnabledValue();
static GpoRuleConfigured GetConfiguredVideoConferenceMuteEnabledValue();
static GpoRuleConfigured GetAllowExperimentationValue();
}
}
}
6 changes: 6 additions & 0 deletions src/common/utils/gpo.h
Expand Up @@ -46,6 +46,7 @@ namespace powertoys_gpo {
const std::wstring POLICY_CONFIGURE_ENABLED_SHORTCUT_GUIDE = L"ConfigureEnabledUtilityShortcutGuide";
const std::wstring POLICY_CONFIGURE_ENABLED_TEXT_EXTRACTOR = L"ConfigureEnabledUtilityTextExtractor";
const std::wstring POLICY_CONFIGURE_ENABLED_VIDEO_CONFERENCE_MUTE = L"ConfigureEnabledUtilityVideoConferenceMute";
const std::wstring POLICY_ALLOW_EXPERIMENTATION = L"AllowExperimentation";

inline gpo_rule_configured_t getConfiguredValue(const std::wstring& registry_value_name)
{
Expand Down Expand Up @@ -235,4 +236,9 @@ namespace powertoys_gpo {
return getConfiguredValue(POLICY_CONFIGURE_ENABLED_VIDEO_CONFERENCE_MUTE);
}

inline gpo_rule_configured_t getAllowExperimentationValue()
{
return getConfiguredValue(POLICY_ALLOW_EXPERIMENTATION);
}

}
15 changes: 13 additions & 2 deletions src/gpo/assets/PowerToys.admx
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<policyDefinitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.0" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyDefinitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.1" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyNamespaces>
<target prefix="powertoys" namespace="Microsoft.Policies.PowerToys" />
</policyNamespaces>
<resources minRequiredRevision="1.0"/><!-- PowerToys v0.64.0 -->
<resources minRequiredRevision="1.1"/><!-- Last changed with PowerToys v0.68.0 -->
<supportedOn>
<definitions>
<definition name="SUPPORTED_POWERTOYS_0_64_0" displayName="$(string.SUPPORTED_POWERTOYS_0_64_0)"/>
<definition name="SUPPORTED_POWERTOYS_0_68_0" displayName="$(string.SUPPORTED_POWERTOYS_0_68_0)"/>
</definitions>
</supportedOn>
<categories>
Expand Down Expand Up @@ -286,5 +287,15 @@
<decimal value="0" />
</disabledValue>
</policy>
<policy name="AllowExperimentation" class="Both" displayName="$(string.AllowExperimentation)" explainText="$(string.AllowExperimentationDescription)" key="Software\Policies\PowerToys" valueName="AllowExperimentation">
<parentCategory ref="PowerToys" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_68_0" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
</policies>
</policyDefinitions>
10 changes: 9 additions & 1 deletion src/gpo/assets/en-US/PowerToys.adml
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.0" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<policyDefinitionResources xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" revision="1.1" schemaVersion="1.0" xmlns="http://schemas.microsoft.com/GroupPolicy/2006/07/PolicyDefinitions">
<displayName>PowerToys</displayName>
<description>PowerToys</description>
<resources>
<stringTable>
<string id="PowerToys">Microsoft PowerToys</string>

<string id="SUPPORTED_POWERTOYS_0_64_0">PowerToys version 0.64.0 or later</string>
<string id="SUPPORTED_POWERTOYS_0_68_0">PowerToys version 0.68.0 or later</string>

<string id="ConfigureEnabledUtilityDescription">This policy configures the enabled state for a PowerToys utility.

Expand All @@ -27,6 +28,12 @@ If you enable this setting, the utility will be always enabled and the user won'
If you disable this setting, the utility will be always disabled and the user won't be able to enable it.

If you don't configure this setting, users are able to disable or enable the utility.
</string>
<string id="AllowExperimentationDescription">This policy configures whether PowerToys experimentation is allowed. With experimentation allowed the user sees the new features being experimented if it gets selected as part of the test group. (Experimentation will only happen on Windows Insider builds.)

If this setting is not configured or enabled, the user can control experimentation in the PowerToys settings menu.

If this setting is disabled, experimentation is not allowed.
</string>
<string id="ConfigureEnabledUtilityAlwaysOnTop">Always On Top: Configure enabled state</string>
<string id="ConfigureEnabledUtilityAwake">Awake: Configure enabled state</string>
Expand Down Expand Up @@ -55,6 +62,7 @@ If you don't configure this setting, users are able to disable or enable the uti
<string id="ConfigureEnabledUtilityShortcutGuide">Shortcut Guide: Configure enabled state</string>
<string id="ConfigureEnabledUtilityTextExtractor">Text Extractor: Configure enabled state</string>
<string id="ConfigureEnabledUtilityVideoConferenceMute">Video Conference Mute: Configure enabled state</string>
<string id="AllowExperimentation">Allow Experimentation</string>
</stringTable>
</resources>
</policyDefinitionResources>
Expand Down
3 changes: 2 additions & 1 deletion src/settings-ui/Settings.UI/OOBE/Views/OobeShellPage.xaml.cs
Expand Up @@ -6,6 +6,7 @@
using System.Collections.ObjectModel;
using System.Globalization;
using AllExperiments;
using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
Expand Down Expand Up @@ -195,7 +196,7 @@ private void NavigationView_SelectionChanged(Microsoft.UI.Xaml.Controls.Navigati
switch (selectedItem.Tag)
{
case "Overview":
if (ExperimentationToggleSwitchEnabled)
if (ExperimentationToggleSwitchEnabled && GPOWrapper.GetAllowExperimentationValue() != GpoRuleConfigured.Disabled)
{
switch (AllExperiments.Experiments.LandingPageExperiment)
{
Expand Down
10 changes: 8 additions & 2 deletions src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
Expand Up @@ -2922,11 +2922,17 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="Alternate_OOBE_Run_Title.Text" xml:space="preserve">
<value>PowerToys Run</value>
</data>
<data name="General_Experimentation.Header" xml:space="preserve">
<value>Experimentation</value>
</data>
<data name="GeneralPage_EnableExperimentation.Description" xml:space="preserve">
<value>Only affects Windows Insider builds</value>
<value>Note: Only Windows Insider builds may be selected for experimentation</value>
</data>
<data name="GeneralPage_EnableExperimentation.Header" xml:space="preserve">
<value>Enable experimentation</value>
<value>Allow experimentation with new features</value>
</data>
<data name="GPO_ExperimentationIsDisallowed.Title" xml:space="preserve">
<value>The system administrator has disabled experimentation.</value>
</data>
<data name="AllAppsTxt.Text" xml:space="preserve">
<value>All apps</value>
Expand Down
11 changes: 10 additions & 1 deletion src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs
Expand Up @@ -12,6 +12,7 @@
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Threading.Tasks;
using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
Expand Down Expand Up @@ -140,6 +141,8 @@ public GeneralViewModel(ISettingsRepository<GeneralSettings> settingsRepository,
_newAvailableVersionLink = UpdatingSettingsConfig.ReleasePageLink;
_updateCheckedDate = UpdatingSettingsConfig.LastCheckedDateLocalized;

_experimentationIsGpoDisallowed = GPOWrapper.GetAllowExperimentationValue() == GpoRuleConfigured.Disabled;

if (dispatcherAction != null)
{
_fileWatcher = Helper.GetFileWatcher(string.Empty, UpdatingSettings.SettingsFile, dispatcherAction);
Expand All @@ -154,6 +157,7 @@ public GeneralViewModel(ISettingsRepository<GeneralSettings> settingsRepository,

private bool _autoDownloadUpdates;
private bool _enableExperimentation;
private bool _experimentationIsGpoDisallowed;

private UpdatingSettings.UpdatingState _updatingState = UpdatingSettings.UpdatingState.UpToDate;
private string _newAvailableVersion = string.Empty;
Expand Down Expand Up @@ -290,7 +294,7 @@ public bool EnableExperimentation
{
get
{
return _enableExperimentation;
return _enableExperimentation && !_experimentationIsGpoDisallowed;
}

set
Expand All @@ -304,6 +308,11 @@ public bool EnableExperimentation
}
}

public bool IsExperimentationGpoDisallowed
{
get => _experimentationIsGpoDisallowed;
}

public static bool AutoUpdatesEnabled
{
get
Expand Down
23 changes: 17 additions & 6 deletions src/settings-ui/Settings.UI/Views/GeneralPage.xaml
Expand Up @@ -369,12 +369,6 @@
</labs:SettingsCard>
</labs:SettingsExpander.Items>
</labs:SettingsExpander>
<labs:SettingsCard x:Uid="GeneralPage_EnableExperimentation"
HeaderIcon="{ui:BitmapIcon Source=/Assets/FluentIcons/FluentIconsExperimentation.png}">
<ToggleSwitch
x:Uid="ToggleSwitch"
IsOn="{Binding Mode=TwoWay, Path=EnableExperimentation}" />
</labs:SettingsCard>
</controls:SettingsGroup>
<InfoBar
x:Uid="General_SettingsBackupMessageResults"
Expand All @@ -383,6 +377,23 @@
IsOpen="{Binding SettingsBackupRestoreMessageVisible, Mode=OneWay}"
IsTabStop="{Binding SettingsBackupRestoreMessageVisible, Mode=OneWay}"
Severity="{Binding BackupRestoreMessageSeverity, Converter={StaticResource StringToInfoBarSeverityConverter}}" />
<controls:SettingsGroup
x:Uid="General_Experimentation"
Visibility="Visible">
<labs:SettingsCard x:Uid="GeneralPage_EnableExperimentation"
HeaderIcon="{ui:BitmapIcon Source=/Assets/FluentIcons/FluentIconsExperimentation.png}">
<ToggleSwitch
x:Uid="ToggleSwitch"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsExperimentationGpoDisallowed, Converter={StaticResource BoolNegationConverter}}"
IsOn="{Binding Mode=TwoWay, Path=EnableExperimentation}" />
</labs:SettingsCard>
<InfoBar
x:Uid="GPO_ExperimentationIsDisallowed"
IsClosable="False"
IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.IsExperimentationGpoDisallowed}"
IsTabStop="{x:Bind Mode=OneWay, Path=ViewModel.IsExperimentationGpoDisallowed}"
Severity="Informational" />
</controls:SettingsGroup>
</StackPanel>

</controls:SettingsPageControl.ModuleContent>
Expand Down

0 comments on commit 27d8beb

Please sign in to comment.