[GPO][MWB]Add policy to disable service mode (#37366)

* [MWB]Add policy to disable service mode

* Add restart note

* Tweak settings to disable setting

* Tweak infobars

* Policy should be machine only
This commit is contained in:
Jaime Bernardo
2025-02-12 18:49:26 +00:00
committed by GitHub
parent e0cb4018ab
commit 0c7a1dd316
13 changed files with 109 additions and 12 deletions

View File

@@ -93,10 +93,23 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public bool UseService
{
get => Settings.Properties.UseService;
get
{
if (_allowServiceModeGpoConfiguration == GpoRuleConfigured.Disabled)
{
return false;
}
return Settings.Properties.UseService;
}
set
{
if (_allowServiceModeIsGPOConfigured)
{
return;
}
var valueChanged = Settings.Properties.UseService != value;
// Set the UI property itself instantly
@@ -122,6 +135,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public bool UseServiceSettingIsEnabled => _allowServiceModeIsGPOConfigured == false;
public bool ConnectFieldsVisible
{
get => _connectFieldsVisible;
@@ -185,6 +200,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private bool _useOriginalUserInterfaceIsGPOConfigured;
private GpoRuleConfigured _disallowBlockingScreensaverGpoConfiguration;
private bool _disallowBlockingScreensaverIsGPOConfigured;
private GpoRuleConfigured _allowServiceModeGpoConfiguration;
private bool _allowServiceModeIsGPOConfigured;
private GpoRuleConfigured _sameSubnetOnlyGpoConfiguration;
private bool _sameSubnetOnlyIsGPOConfigured;
private GpoRuleConfigured _validateRemoteIpGpoConfiguration;
@@ -507,6 +524,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_disableUserDefinedIpMappingRulesIsGPOConfigured = _disableUserDefinedIpMappingRulesGpoConfiguration == GpoRuleConfigured.Enabled;
// Policies supporting only disabled state
_allowServiceModeGpoConfiguration = GPOWrapper.GetConfiguredMwbAllowServiceModeValue();
_allowServiceModeIsGPOConfigured = _allowServiceModeGpoConfiguration == GpoRuleConfigured.Disabled;
_clipboardSharingEnabledGpoConfiguration = GPOWrapper.GetConfiguredMwbClipboardSharingEnabledValue();
_clipboardSharingEnabledIsGPOConfigured = _clipboardSharingEnabledGpoConfiguration == GpoRuleConfigured.Disabled;
_fileTransferEnabledGpoConfiguration = GPOWrapper.GetConfiguredMwbFileTransferEnabledValue();
@@ -1231,6 +1250,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SendCustomAction("uninstall_service");
}
public bool ShowPolicyConfiguredInfoForServiceSettings
{
get
{
return IsEnabled && _allowServiceModeIsGPOConfigured;
}
}
public bool ShowPolicyConfiguredInfoForBehaviorSettings
{
get
@@ -1248,7 +1275,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public bool ShowInfobarRunAsAdminText
{
get { return !CanToggleUseService && IsEnabled; }
get { return !CanToggleUseService && IsEnabled && !ShowPolicyConfiguredInfoForServiceSettings; }
}
}
}