diff --git a/src/Converters/ConclusionColorConverter.cs b/src/Converters/ConclusionColorConverter.cs new file mode 100644 index 0000000..b566964 --- /dev/null +++ b/src/Converters/ConclusionColorConverter.cs @@ -0,0 +1,26 @@ +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media; + +namespace GitHubActionsVS.Converters; + +public class ConclusionColorConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + string status = value as string; + return GetConclusionColor(status); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return value; + } + + private SolidColorBrush GetConclusionColor(string status) => status.ToLowerInvariant() switch + { + "success" => new SolidColorBrush(Colors.Green), + "failure" => new SolidColorBrush(Colors.Red), + _ => new SolidColorBrush(Colors.Black), + }; +} diff --git a/src/Converters/ConclusionIconConverter.cs b/src/Converters/ConclusionIconConverter.cs new file mode 100644 index 0000000..057c4f1 --- /dev/null +++ b/src/Converters/ConclusionIconConverter.cs @@ -0,0 +1,26 @@ +using System.Globalization; +using System.Windows.Data; + +namespace GitHubActionsVS.Converters; +public class ConclusionIconConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + string status = value as string; + return GetConclusionIndicator(status); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return value; + } + + private string GetConclusionIndicator(string status) => status.ToLowerInvariant() switch + { + "success" => "\uEBB3 ", + "failure" => "\uEBB4 ", + "cancelled" => "\uEABD ", + "skipped" => "\uEABD ", + _ => "🤷🏽", + }; +} diff --git a/src/GitHubActionsVS.csproj b/src/GitHubActionsVS.csproj index c14dee6..b5f41fe 100644 --- a/src/GitHubActionsVS.csproj +++ b/src/GitHubActionsVS.csproj @@ -47,8 +47,14 @@ + + + + + + diff --git a/src/GitHubActionsVSPackage.cs b/src/GitHubActionsVSPackage.cs index d98dcbe..715d202 100644 --- a/src/GitHubActionsVSPackage.cs +++ b/src/GitHubActionsVSPackage.cs @@ -11,6 +11,7 @@ namespace GitHubActionsVS; [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] [ProvideToolWindow(typeof(ActionsToolWindow.Pane), Style = VsDockStyle.Tabbed, Window = WindowGuids.SolutionExplorer)] +[ProvideOptionPage(typeof(OptionsProvider.ExtensionOptionsOptions), "GitHub Actions for VS", "General", 0, 0, true, SupportsProfiles = true)] [ProvideMenuResource("Menus.ctmenu", 1)] [Guid(PackageGuids.GitHubActionsVSString)] [ProvideBindingPath] diff --git a/src/Models/BaseWorkflowType.cs b/src/Models/BaseWorkflowType.cs new file mode 100644 index 0000000..520fba4 --- /dev/null +++ b/src/Models/BaseWorkflowType.cs @@ -0,0 +1,13 @@ +namespace GitHubActionsVS.Models; + +public abstract class BaseWorkflowType +{ + public string Name { get; set; } + + public abstract string DisplayName { get; } + public string Conclusion { get; set; } + public DateTimeOffset? LogDate { get; set; } + public string DisplayDate => $"{LogDate:g}"; + public string? Url { get; set; } + public string Id { get; set; } +} diff --git a/src/Models/SimpleJob.cs b/src/Models/SimpleJob.cs new file mode 100644 index 0000000..2e2866a --- /dev/null +++ b/src/Models/SimpleJob.cs @@ -0,0 +1,6 @@ +namespace GitHubActionsVS.Models; + +public class SimpleJob : SimpleRun +{ + public override string DisplayName => Name; +} diff --git a/src/Models/SimpleRun.cs b/src/Models/SimpleRun.cs new file mode 100644 index 0000000..4b924c6 --- /dev/null +++ b/src/Models/SimpleRun.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace GitHubActionsVS.Models; +public class SimpleRun : BaseWorkflowType +{ + public List Jobs { get; set; } + public string RunNumber { get; set; } + + public override string DisplayName => $"{Name} #{RunNumber}"; +} diff --git a/src/Options/ExtensionOptions.cs b/src/Options/ExtensionOptions.cs new file mode 100644 index 0000000..657c5f8 --- /dev/null +++ b/src/Options/ExtensionOptions.cs @@ -0,0 +1,20 @@ +using System.ComponentModel; +using System.Runtime.InteropServices; + +namespace GitHubActionsVS; +internal partial class OptionsProvider +{ + // Register the options with this attribute on your package class: + // [ProvideOptionPage(typeof(OptionsProvider.ExtensionOptionsOptions), "GitHubActionsVS", "ExtensionOptions", 0, 0, true, SupportsProfiles = true)] + [ComVisible(true)] + public class ExtensionOptionsOptions : BaseOptionPage { } +} + +public class ExtensionOptions : BaseOptionModel +{ + [Category("Query Settings")] + [DisplayName("Max Runs")] + [Description("The maximum number of runs to retrieve")] + [DefaultValue(10)] + public int MaxRuns { get; set; } = 10; +} diff --git a/src/ToolWindows/GHActionsToolWindow.xaml b/src/ToolWindows/GHActionsToolWindow.xaml index 89c465c..d89f0b5 100644 --- a/src/ToolWindows/GHActionsToolWindow.xaml +++ b/src/ToolWindows/GHActionsToolWindow.xaml @@ -9,6 +9,7 @@ xmlns:catalog="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.ImageCatalog" xmlns:toolkit="clr-namespace:Community.VisualStudio.Toolkit;assembly=Community.VisualStudio.Toolkit" xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" + xmlns:ivc="clr-namespace:GitHubActionsVS.Converters" toolkit:Themes.UseVsTheme="True" mc:Ignorable="d" d:DesignHeight="300" @@ -16,6 +17,8 @@ Name="GHActionToolWindow"> pack://application:,,,/GitHubActionsVS;component/Resources/#codicon + + @@ -40,12 +43,31 @@ + + + + + + - - + + + + + + + - + + + + +