[New+, Enterprise]Policy for showing filename extension (#35000)

* add gpo: admx, gpo utils

* todo note

* BugReport tool

* implement policy in utility

* settings ui

* remove todo comment

* code fixes

* code fixes 2

* spell fix
This commit is contained in:
Heiko
2024-09-24 17:33:01 +02:00
committed by GitHub
parent b927b340ec
commit 734b0f8a54
10 changed files with 87 additions and 5 deletions

View File

@@ -68,9 +68,19 @@
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="NewPlus_Display_Options" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsCard x:Uid="NewPlus_Hide_File_Extension_Toggle">
<tkcontrols:SettingsCard x:Uid="NewPlus_Hide_File_Extension_Toggle" IsEnabled="{x:Bind ViewModel.IsHideFileExtSettingsCardEnabled, Mode=OneWay}">
<ToggleSwitch x:Uid="HideFileExtensionToggle" IsOn="{x:Bind ViewModel.HideFileExtension, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<InfoBar
x:Uid="GPO_SettingIsManaged"
IsClosable="False"
IsOpen="{x:Bind ViewModel.IsHideFileExtSettingGPOConfigured, Mode=OneWay}"
IsTabStop="{x:Bind ViewModel.IsHideFileExtSettingGPOConfigured, Mode=OneWay}"
Severity="Informational">
<!-- InfoBar.IconSource>
<FontIconSource FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE72E;" />
</InfoBar.IconSource-->
</InfoBar>
<tkcontrols:SettingsCard x:Uid="NewPlus_Hide_Starting_Digits_Toggle">
<ToggleSwitch x:Uid="HideStartingDigitsToggle" IsOn="{x:Bind ViewModel.HideStartingDigits, Mode=TwoWay}" />
<tkcontrols:SettingsCard.Description>

View File

@@ -51,6 +51,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_hideStartingDigits = Settings.HideStartingDigits;
_templateLocation = Settings.TemplateLocation;
InitializeEnabledValue();
InitializeGpoValues();
// set the callback functions value to handle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc;
@@ -71,6 +72,13 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
private void InitializeGpoValues()
{
// Policy for hide file extension setting
_hideFileExtensionGpoRuleConfiguration = GPOWrapper.GetConfiguredNewPlusHideTemplateFilenameExtensionValue();
_hideFileExtensionIsGPOConfigured = _hideFileExtensionGpoRuleConfiguration == GpoRuleConfigured.Disabled || _hideFileExtensionGpoRuleConfiguration == GpoRuleConfigured.Enabled;
}
public bool IsEnabled
{
get => _isNewPlusEnabled;
@@ -82,6 +90,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
GeneralSettingsConfig.Enabled.NewPlus = value;
OnPropertyChanged(nameof(IsEnabled));
OnPropertyChanged(nameof(IsHideFileExtSettingsCardEnabled));
OnPropertyChanged(nameof(IsHideFileExtSettingGPOConfigured));
OutGoingGeneralSettings outgoingMessage = new OutGoingGeneralSettings(GeneralSettingsConfig);
SendConfigMSG(outgoingMessage.ToString());
@@ -121,10 +131,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public bool HideFileExtension
{
get => _hideFileExtension;
get
{
if (_hideFileExtensionIsGPOConfigured)
{
return _hideFileExtensionGpoRuleConfiguration == GpoRuleConfigured.Enabled;
}
return _hideFileExtension;
}
set
{
if (_hideFileExtension != value)
if (_hideFileExtension != value && !_hideFileExtensionIsGPOConfigured)
{
_hideFileExtension = value;
Settings.HideFileExtension = value;
@@ -137,6 +156,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public bool IsHideFileExtSettingsCardEnabled => _isNewPlusEnabled && !_hideFileExtensionIsGPOConfigured;
public bool IsHideFileExtSettingGPOConfigured => _isNewPlusEnabled && _hideFileExtensionIsGPOConfigured;
public bool HideStartingDigits
{
get => _hideStartingDigits;
@@ -209,13 +232,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
private GpoRuleConfigured _enabledGpoRuleConfiguration;
private bool _enabledStateIsGPOConfigured;
private bool _isNewPlusEnabled;
private string _templateLocation;
private bool _hideFileExtension;
private bool _hideStartingDigits;
private GpoRuleConfigured _enabledGpoRuleConfiguration;
private bool _enabledStateIsGPOConfigured;
private GpoRuleConfigured _hideFileExtensionGpoRuleConfiguration;
private bool _hideFileExtensionIsGPOConfigured;
public void RefreshEnabledState()
{
InitializeEnabledValue();