mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[PTRun][Enterprise]GPO for plugin enabled state (#27468)
* try code for gpo with pluginID param * fix typo * fixes * update admx * Add second policy to admx * spelling fixes * admx clean up * add gpo code * small fixes * fixes * fix cast * update settings code * bug fixes * fix plugins disabled warning * Info bar in settings * settings ui fixes * code clean up * fix spelling * fix spelling * code optimization * changes * fix code * switch to char* * update comments * validate plugin ID * spell fixes * spell fixes * fix IPlugin interface * Update Directory.Packages.props hopefully fixes unit tests * revert change of nuget pkg * fixes * fix spell check * add todo comment * improve gpo.h * improve gpo.h * update gpo.h * clean up code in gpo.h * fix build * try to fix build * xaml fix * Fix getting string value from the registry * communicate policy state suing settings.json * various changes and gpo docs * spell fixes * PT Run: Policy handling * spell fix * fix logging * fix admx revision * revision fix 2 * review feedback 1 * review feedback 2 * dev docs update * fix typo
This commit is contained in:
@@ -18,6 +18,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
// Use to communicate the state to settings UI (Using int type because we can't reference GPOWrapper.)
|
||||
// This property should never be used inside of PT Run to get the policy state as it can be manipulated by changing the settings.json file.
|
||||
public int EnabledPolicyUiState { get; set; }
|
||||
|
||||
public bool IsGlobal { get; set; }
|
||||
|
||||
public string ActionKeyword { get; set; }
|
||||
|
||||
@@ -238,7 +238,12 @@
|
||||
</controls:SettingsCard>
|
||||
|
||||
|
||||
|
||||
<InfoBar
|
||||
x:Uid="Run_SomePluginsAreGpoManaged"
|
||||
IsClosable="False"
|
||||
IsOpen="{x:Bind ViewModel.ShowPluginsAreGpoManagedInfo, Mode=OneWay}"
|
||||
IsTabStop="{x:Bind ViewModel.ShowPluginsAreGpoManagedInfo, Mode=OneWay}"
|
||||
Severity="Informational" />
|
||||
<InfoBar
|
||||
x:Uid="Run_AllPluginsDisabled"
|
||||
IsClosable="False"
|
||||
@@ -293,7 +298,8 @@
|
||||
Visibility="{x:Bind ShowBadgeOnPluginSettingError}" />
|
||||
</Grid>
|
||||
|
||||
<ToggleSwitch x:Uid="PowerLauncher_EnablePluginToggle" IsOn="{x:Bind Path=Disabled, Converter={StaticResource BoolNegationConverter}, Mode=TwoWay}" />
|
||||
<ToggleSwitch x:Uid="PowerLauncher_EnablePluginToggle" IsOn="{x:Bind Path=Disabled, Converter={StaticResource BoolNegationConverter}, Mode=TwoWay}" IsEnabled="{x:Bind Path=EnabledGpoRuleIsConfigured, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}" />
|
||||
|
||||
</StackPanel>
|
||||
<controls:SettingsExpander.Items>
|
||||
<controls:SettingsCard x:Uid="PowerLauncher_ActionKeyword" IsEnabled="{x:Bind Enabled, Mode=OneWay}">
|
||||
|
||||
@@ -3680,6 +3680,9 @@ Activate by holding the key for the character you want to add an accent to, then
|
||||
<data name="Run_PluginUseFindMorePlugins.Content" xml:space="preserve">
|
||||
<value>Find more plugins</value>
|
||||
</data>
|
||||
<data name="Run_SomePluginsAreGpoManaged.Title" xml:space="preserve">
|
||||
<value>The system administrator is managing the enabled state of some plugins.</value>
|
||||
</data>
|
||||
<data name="AlwaysOnTop_FrameOpacity.Header" xml:space="preserve">
|
||||
<value>Opacity (%)</value>
|
||||
</data>
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
@@ -33,6 +34,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
NotifyPropertyChanged(nameof(AdditionalOptions));
|
||||
};
|
||||
}
|
||||
|
||||
_enabledGpoRuleConfiguration = (GpoRuleConfigured)settings.EnabledPolicyUiState;
|
||||
_enabledGpoRuleIsConfigured = _enabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _enabledGpoRuleConfiguration == GpoRuleConfigured.Enabled;
|
||||
}
|
||||
|
||||
public string Id { get => settings.Id; }
|
||||
@@ -43,11 +47,25 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
public string Author { get => settings.Author; }
|
||||
|
||||
private GpoRuleConfigured _enabledGpoRuleConfiguration;
|
||||
private bool _enabledGpoRuleIsConfigured;
|
||||
|
||||
public bool Disabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings.Disabled;
|
||||
if (_enabledGpoRuleConfiguration == GpoRuleConfigured.Disabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (_enabledGpoRuleConfiguration == GpoRuleConfigured.Enabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return settings.Disabled;
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
@@ -55,6 +73,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
if (settings.Disabled != value)
|
||||
{
|
||||
settings.Disabled = value;
|
||||
|
||||
NotifyPropertyChanged();
|
||||
NotifyPropertyChanged(nameof(ShowNotAccessibleWarning));
|
||||
NotifyPropertyChanged(nameof(Enabled));
|
||||
@@ -67,6 +86,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
public bool Enabled => !Disabled;
|
||||
|
||||
public bool EnabledGpoRuleIsConfigured => _enabledGpoRuleIsConfigured;
|
||||
|
||||
public double DisabledOpacity => Disabled ? 0.5 : 1;
|
||||
|
||||
public bool IsGlobalAndEnabled
|
||||
|
||||
@@ -135,6 +135,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
|
||||
OnPropertyChanged(nameof(ShowAllPluginsDisabledWarning));
|
||||
OnPropertyChanged(nameof(ShowPluginsAreGpoManagedInfo));
|
||||
UpdateSettings();
|
||||
}
|
||||
|
||||
@@ -174,6 +175,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
OnPropertyChanged(nameof(EnablePowerLauncher));
|
||||
OnPropertyChanged(nameof(ShowAllPluginsDisabledWarning));
|
||||
OnPropertyChanged(nameof(ShowPluginsLoadingMessage));
|
||||
OnPropertyChanged(nameof(ShowPluginsAreGpoManagedInfo));
|
||||
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
SendConfigMSG(outgoing.ToString());
|
||||
}
|
||||
@@ -186,6 +188,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
OnPropertyChanged(nameof(EnablePowerLauncher));
|
||||
OnPropertyChanged(nameof(ShowAllPluginsDisabledWarning));
|
||||
OnPropertyChanged(nameof(ShowPluginsLoadingMessage));
|
||||
OnPropertyChanged(nameof(ShowPluginsAreGpoManagedInfo));
|
||||
}
|
||||
|
||||
public bool IsEnabledGpoConfigured
|
||||
@@ -616,9 +619,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowPluginsAreGpoManagedInfo
|
||||
{
|
||||
get => EnablePowerLauncher && settings.Plugins.Any() && Plugins.Any(x => x.EnabledGpoRuleIsConfigured);
|
||||
}
|
||||
|
||||
public bool ShowAllPluginsDisabledWarning
|
||||
{
|
||||
get => EnablePowerLauncher && settings.Plugins.Any() && settings.Plugins.All(x => x.Disabled);
|
||||
get => EnablePowerLauncher && settings.Plugins.Any() && Plugins.All(x => x.Disabled);
|
||||
}
|
||||
|
||||
public bool ShowPluginsLoadingMessage
|
||||
|
||||
Reference in New Issue
Block a user