Skip to content

Commit

Permalink
feat(Events): highlight Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJosipovic committed Sep 9, 2024
1 parent 8dbf69c commit e3c8bfe
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/KubeUI/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
<StyleInclude Source="avares://Semi.Avalonia/Themes/Index.axaml" />
<u-semi:SemiTheme Locale="en-US" />
<styling:FluentAvaloniaTheme />
<!-- https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Accents/BaseColorsPalette.xaml -->
<!--
https://theme.xaml.live/
https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Accents/BaseColorsPalette.xaml
-->
<FluentTheme DensityStyle="Compact">
<FluentTheme.Palettes>
<ColorPaletteResources
Expand Down
25 changes: 25 additions & 0 deletions src/KubeUI/ViewModels/ResourceListViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Collections.Specialized;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using Avalonia.Data.Converters;
using Avalonia.Styling;
using Dock.Model.Core;
using DynamicData;
using DynamicData.Binding;
Expand Down Expand Up @@ -353,6 +355,27 @@ private void SelectedNamespaces_CollectionChanged(object? sender, NotifyCollecti
Width = "80"
},
];

definition.SetStyle = () => [
new Style<DataGridRow>()
.Setter(DataGridRow.ForegroundProperty, new Binding("Value.Type")
{
Converter = new FuncValueConverter<string, IBrush>(x =>
{
if (string.Equals(x, "Warning", StringComparison.Ordinal))
{
return Brushes.Red;
}

if (Application.Current.ActualThemeVariant == ThemeVariant.Light)
{
return Brushes.Black; //todo reference style
}

return Brushes.White; //todo reference style
}),
}),
];
}
else if (resourceType == typeof(V1Pod))
{
Expand Down Expand Up @@ -1161,4 +1184,6 @@ public class ResourceListViewMenuItem
public bool ShowNamespaces { get; set; } = true;

public bool ShowNewResource { get; set; } = true;

public Func<StyleGroup>? SetStyle { get; set; } = () => [];
}
7 changes: 6 additions & 1 deletion src/KubeUI/Views/ResourceListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void GenerateGrid()
{
try
{
var columnDisplay = (Func<T,string>)columnDefinition.GetType().GetProperty(nameof(ResourceListViewDefinitionColumn<T, string>.Display)).GetValue(columnDefinition);
var columnDisplay = (Func<T, string>)columnDefinition.GetType().GetProperty(nameof(ResourceListViewDefinitionColumn<T, string>.Display)).GetValue(columnDefinition);

var columnField = columnDefinition.GetType().GetProperty(nameof(ResourceListViewDefinitionColumn<T, string>.Field)).GetValue(columnDefinition);

Expand Down Expand Up @@ -216,6 +216,11 @@ private List<Style> GenerateStyles(ResourceListViewMenuItem menu, int level = 0)
return styles;
}

protected override StyleGroup? BuildStyles()
{
return ViewModel.ViewDefinition.SetStyle.Invoke();
}

protected override object Build(ResourceListViewModel<T>? vm)
{
var controls = new Grid()
Expand Down

0 comments on commit e3c8bfe

Please sign in to comment.