Skip to content

Commit 498a3ad

Browse files
committed
chore: change stale agent colour to yellow
1 parent acc89ee commit 498a3ad

File tree

3 files changed

+313
-310
lines changed

3 files changed

+313
-310
lines changed
Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
using System;
2-
using Windows.UI;
3-
using Coder.Desktop.App.ViewModels;
4-
using Microsoft.UI.Xaml.Data;
5-
using Microsoft.UI.Xaml.Media;
6-
7-
namespace Coder.Desktop.App.Converters;
8-
9-
public class AgentStatusToColorConverter : IValueConverter
10-
{
11-
private static readonly SolidColorBrush Green = new(Color.FromArgb(255, 52, 199, 89));
12-
private static readonly SolidColorBrush Red = new(Color.FromArgb(255, 255, 59, 48));
13-
private static readonly SolidColorBrush Gray = new(Color.FromArgb(255, 142, 142, 147));
14-
15-
public object Convert(object value, Type targetType, object parameter, string language)
16-
{
17-
if (value is not AgentConnectionStatus status) return Gray;
18-
19-
return status switch
20-
{
21-
AgentConnectionStatus.Green => Green,
22-
AgentConnectionStatus.Red => Red,
23-
_ => Gray,
24-
};
25-
}
26-
27-
public object ConvertBack(object value, Type targetType, object parameter, string language)
28-
{
29-
throw new NotImplementedException();
30-
}
31-
}
1+
using System;
2+
using Windows.UI;
3+
using Coder.Desktop.App.ViewModels;
4+
using Microsoft.UI.Xaml.Data;
5+
using Microsoft.UI.Xaml.Media;
6+
7+
namespace Coder.Desktop.App.Converters;
8+
9+
public class AgentStatusToColorConverter : IValueConverter
10+
{
11+
private static readonly SolidColorBrush Green = new(Color.FromArgb(255, 52, 199, 89));
12+
private static readonly SolidColorBrush Red = new(Color.FromArgb(255, 255, 59, 48));
13+
private static readonly SolidColorBrush Gray = new(Color.FromArgb(255, 142, 142, 147));
14+
private static readonly SolidColorBrush Yellow = new(Color.FromArgb(255, 204, 1, 0));
15+
16+
public object Convert(object value, Type targetType, object parameter, string language)
17+
{
18+
if (value is not AgentConnectionStatus status) return Gray;
19+
20+
return status switch
21+
{
22+
AgentConnectionStatus.Green => Green,
23+
AgentConnectionStatus.Red => Red,
24+
AgentConnectionStatus.Yellow => Yellow,
25+
_ => Gray,
26+
};
27+
}
28+
29+
public object ConvertBack(object value, Type targetType, object parameter, string language)
30+
{
31+
throw new NotImplementedException();
32+
}
33+
}

App/ViewModels/AgentViewModel.cs

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
1-
using Windows.ApplicationModel.DataTransfer;
2-
using CommunityToolkit.Mvvm.Input;
3-
using Microsoft.UI.Xaml;
4-
using Microsoft.UI.Xaml.Controls;
5-
using Microsoft.UI.Xaml.Controls.Primitives;
6-
7-
namespace Coder.Desktop.App.ViewModels;
8-
9-
public enum AgentConnectionStatus
10-
{
11-
Green,
12-
Red,
13-
Gray,
14-
}
15-
16-
public partial class AgentViewModel
17-
{
18-
public required string Hostname { get; set; }
19-
20-
public required string HostnameSuffix { get; set; } // including leading dot
21-
22-
public required AgentConnectionStatus ConnectionStatus { get; set; }
23-
24-
public string FullHostname => Hostname + HostnameSuffix;
25-
26-
public required string DashboardUrl { get; set; }
27-
28-
[RelayCommand]
29-
private void CopyHostname(object parameter)
30-
{
31-
var dataPackage = new DataPackage
32-
{
33-
RequestedOperation = DataPackageOperation.Copy,
34-
};
35-
dataPackage.SetText(FullHostname);
36-
Clipboard.SetContent(dataPackage);
37-
38-
if (parameter is not FrameworkElement frameworkElement) return;
39-
40-
var flyout = new Flyout
41-
{
42-
Content = new TextBlock
43-
{
44-
Text = "DNS Copied",
45-
Margin = new Thickness(4),
46-
},
47-
};
48-
FlyoutBase.SetAttachedFlyout(frameworkElement, flyout);
49-
FlyoutBase.ShowAttachedFlyout(frameworkElement);
50-
}
51-
}
1+
using Windows.ApplicationModel.DataTransfer;
2+
using CommunityToolkit.Mvvm.Input;
3+
using Microsoft.UI.Xaml;
4+
using Microsoft.UI.Xaml.Controls;
5+
using Microsoft.UI.Xaml.Controls.Primitives;
6+
7+
namespace Coder.Desktop.App.ViewModels;
8+
9+
public enum AgentConnectionStatus
10+
{
11+
Green,
12+
Red,
13+
Yellow,
14+
Gray,
15+
}
16+
17+
public partial class AgentViewModel
18+
{
19+
public required string Hostname { get; set; }
20+
21+
public required string HostnameSuffix { get; set; } // including leading dot
22+
23+
public required AgentConnectionStatus ConnectionStatus { get; set; }
24+
25+
public string FullHostname => Hostname + HostnameSuffix;
26+
27+
public required string DashboardUrl { get; set; }
28+
29+
[RelayCommand]
30+
private void CopyHostname(object parameter)
31+
{
32+
var dataPackage = new DataPackage
33+
{
34+
RequestedOperation = DataPackageOperation.Copy,
35+
};
36+
dataPackage.SetText(FullHostname);
37+
Clipboard.SetContent(dataPackage);
38+
39+
if (parameter is not FrameworkElement frameworkElement) return;
40+
41+
var flyout = new Flyout
42+
{
43+
Content = new TextBlock
44+
{
45+
Text = "DNS Copied",
46+
Margin = new Thickness(4),
47+
},
48+
};
49+
FlyoutBase.SetAttachedFlyout(frameworkElement, flyout);
50+
FlyoutBase.ShowAttachedFlyout(frameworkElement);
51+
}
52+
}

0 commit comments

Comments
 (0)