[EnvVar]Mark and disable editing of user variables that are applied by a profile (#29451)
* [EnvVar] Mark profile variable in user variables * Mark backup variables * Add tooltip to icon, put in header and disable editing of applied var * Use completed icon instead * Better var name and comments --------- Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
This commit is contained in:
Родитель
1dde699688
Коммит
66f4f69841
|
@ -24,10 +24,24 @@
|
|||
<DataTemplate x:Key="VariableTemplate" x:DataType="models:Variable">
|
||||
<controls:SettingsCard
|
||||
CommandParameter="{x:Bind (models:Variable)}"
|
||||
Header="{x:Bind Name, Mode=TwoWay}"
|
||||
IsActionIconVisible="False"
|
||||
IsClickEnabled="False"
|
||||
Style="{StaticResource DefaultSettingsExpanderItemStyle}">
|
||||
<controls:SettingsCard.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{x:Bind Name, Mode=TwoWay}" />
|
||||
<FontIcon
|
||||
Margin="6,0,6,0"
|
||||
FontSize="16"
|
||||
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
|
||||
Glyph=""
|
||||
Visibility="{x:Bind IsAppliedFromProfile, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<ToolTipService.ToolTip>
|
||||
<TextBlock x:Uid="VariableIsAppliedByActiveProfileTooltip" TextWrapping="Wrap" />
|
||||
</ToolTipService.ToolTip>
|
||||
</FontIcon>
|
||||
</StackPanel>
|
||||
</controls:SettingsCard.Header>
|
||||
<controls:SettingsCard.Description>
|
||||
<StackPanel HorizontalAlignment="Left">
|
||||
<ItemsControl
|
||||
|
@ -52,7 +66,6 @@
|
|||
Visibility="{x:Bind ShowAsList, Converter={StaticResource BoolToInvertedVisibilityConverter}}" />
|
||||
</StackPanel>
|
||||
</controls:SettingsCard.Description>
|
||||
|
||||
<Button
|
||||
Content="{ui:FontIcon Glyph=}"
|
||||
IsEnabled="{x:Bind IsEditable}"
|
||||
|
|
|
@ -28,12 +28,17 @@ namespace EnvironmentVariables.Models
|
|||
[ObservableProperty]
|
||||
private bool _applyToSystem;
|
||||
|
||||
[JsonIgnore]
|
||||
[property: JsonIgnore]
|
||||
[ObservableProperty]
|
||||
private bool _isAppliedFromProfile; // Used to mark that a variable in a default set is applied by a profile. Used to disable editing / mark it in the UI.
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsEditable
|
||||
{
|
||||
get
|
||||
{
|
||||
return ParentType != VariablesSetType.System || App.GetService<IElevationHelper>().IsElevated;
|
||||
return (ParentType != VariablesSetType.System || App.GetService<IElevationHelper>().IsElevated) && !IsAppliedFromProfile;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -280,4 +280,7 @@
|
|||
<data name="StateProfileNotApplicableMsg" xml:space="preserve">
|
||||
<value>Variables or backup variables are invalid.</value>
|
||||
</data>
|
||||
<data name="VariableIsAppliedByActiveProfileTooltip.Text" xml:space="preserve">
|
||||
<value>This variable is written by the active profile</value>
|
||||
</data>
|
||||
</root>
|
|
@ -67,6 +67,16 @@ namespace EnvironmentVariables.ViewModels
|
|||
foreach (var variable in UserDefaultSet.Variables)
|
||||
{
|
||||
DefaultVariables.Variables.Add(variable);
|
||||
if (AppliedProfile != null)
|
||||
{
|
||||
if (AppliedProfile.Variables.Where(
|
||||
x => (x.Name.Equals(variable.Name, StringComparison.OrdinalIgnoreCase) && x.Values.Equals(variable.Values, StringComparison.OrdinalIgnoreCase))
|
||||
|| variable.Name.Equals(EnvironmentVariablesHelper.GetBackupVariableName(x, AppliedProfile.Name), StringComparison.OrdinalIgnoreCase)).Any())
|
||||
{
|
||||
// If it's a user variable that's also in the profile or is a backup variable, mark it as applied from profile.
|
||||
variable.IsAppliedFromProfile = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var variable in SystemDefaultSet.Variables)
|
||||
|
|
Загрузка…
Ссылка в новой задаче