Skip to content

Commit

Permalink
Merge branch 'alpha' of https://github.com/IvanJosipovic/KubeUI into …
Browse files Browse the repository at this point in the history
…alpha
  • Loading branch information
IvanJosipovic committed Sep 9, 2024
2 parents bdc83e4 + cbb0afb commit 18efe19
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/KubeUI.Desktop/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<key>LSEnvironment</key>
<dict>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:</string>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin</string>
</dict>
</dict>
</plist>
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
2 changes: 1 addition & 1 deletion tests/KubeUI.Tests/KubeUI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.71" />
<PackageReference Include="xunit" Version="2.9.0" />
Expand Down

0 comments on commit 18efe19

Please sign in to comment.