diff --git a/src/TUI.Engine/Symbols.cs b/src/TUI.Engine/Symbols.cs index b88094e..654907f 100644 --- a/src/TUI.Engine/Symbols.cs +++ b/src/TUI.Engine/Symbols.cs @@ -18,6 +18,8 @@ public static class Symbols public const string Seo = "󰚩"; public const string Auth = ""; public const string NotFound = ""; + public const string Error = ""; + public const string Download = ""; public static class Lines { diff --git a/src/TUI/Controls/Components/VersionComponent.cs b/src/TUI/Controls/Components/VersionComponent.cs index 0f4408b..d8016d4 100644 --- a/src/TUI/Controls/Components/VersionComponent.cs +++ b/src/TUI/Controls/Components/VersionComponent.cs @@ -1,7 +1,9 @@ using System.Text; using TUI.Domain; +using TUI.Engine; using TUI.Engine.Attributes; using TUI.Engine.Components; +using TUI.Engine.Theme; namespace TUI.Controls.Components; @@ -25,16 +27,18 @@ public class VersionComponent : ComponentBase { var builder = new StringBuilder(); - // builder.Append(_type.ToString()); if (_brand is not null) { builder.Append(_brand.ColorLogo()); } + builder.Append(_type.ToImage().Warning()); + builder.Append(Symbols.Space); builder.Append(_version); var sketch = builder.ToString(); return new Sketch(_status.Colorize(sketch)); } -} \ No newline at end of file +} + diff --git a/src/TUI/Controls/Components/VersionExtensions.cs b/src/TUI/Controls/Components/VersionExtensions.cs new file mode 100644 index 0000000..5de4afa --- /dev/null +++ b/src/TUI/Controls/Components/VersionExtensions.cs @@ -0,0 +1,28 @@ +using TUI.Engine.Theme; + +namespace TUI.Controls.Components; + +public static class VersionExtensions +{ + public static string ToImage(this VersionType versionType) + => + versionType switch + { + VersionType.Alpha => "󰀫", + VersionType.Beta => "󰂡", + VersionType.Candidate => "󰑣", + VersionType.Canary => "󱗆", + VersionType.Next => "󰒭", + _ => "" + }; + + public static string Colorize(this VersionStatus versionStatus, string value) => + versionStatus switch + { + VersionStatus.TooOld => value.Warning(), + VersionStatus.ToNew => value.Info(), + VersionStatus.SoGood => value.Hint(), + VersionStatus.BeNice => value.Main(), + _ => value + }; +} \ No newline at end of file diff --git a/src/TUI/Controls/Components/VersionType.cs b/src/TUI/Controls/Components/VersionType.cs index 786c668..a7fac98 100644 --- a/src/TUI/Controls/Components/VersionType.cs +++ b/src/TUI/Controls/Components/VersionType.cs @@ -9,4 +9,4 @@ public enum VersionType Alpha, Beta, Next, -} \ No newline at end of file +} diff --git a/src/TUI/Controls/Components/VersionTypeExtensions.cs b/src/TUI/Controls/Components/VersionTypeExtensions.cs deleted file mode 100644 index 519815b..0000000 --- a/src/TUI/Controls/Components/VersionTypeExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using TUI.Engine.Theme; - -namespace TUI.Controls.Components; - -public static class VersionTypeExtensions -{ - public static string Colorize(this VersionStatus versionStatus, string value) => - versionStatus switch - { - VersionStatus.TooOld => value.Warning(), - VersionStatus.ToNew => value.Info(), - VersionStatus.SoGood => value.Hint(), - VersionStatus.BeNice => value.Main(), - _ => value - }; -} \ No newline at end of file diff --git a/src/TUI/Controls/Containers/DependenciesContainer.cs b/src/TUI/Controls/Containers/DependenciesContainer.cs index 23393c9..ecf373f 100644 --- a/src/TUI/Controls/Containers/DependenciesContainer.cs +++ b/src/TUI/Controls/Containers/DependenciesContainer.cs @@ -16,7 +16,7 @@ public class DependenciesContainer : ContainerBase { public readonly Project? Project; - private const int VersionColumnWidth = 10; + private const int VersionColumnWidth = 11; private const int TitleColumnWidth = 25; @@ -70,6 +70,22 @@ public class DependenciesContainer : ContainerBase _dependencies.Add(stub); } + public void AddError() + { + var size = new Size(25, 1); + var stub = new StubComponent(size, (Symbols.Error + Symbols.Space + " Something went wrong").Error()); + stub.SetPadding(Level.Normal); + stub.SetAlignment(Horizontal.Right); + stub.SetFixed(Orientation.Horizontal, 25); + + if (Project is not null && Project.Legacy) + { + stub.StyleContext = new StyleContext(Palette.DisableColor); + } + + _dependencies.Add(stub); + } + public void AddDependency(Dependency dependency, VersionStatus status = VersionStatus.BeNice) { var version = new VersionComponent(dependency.Version, dependency.Brand, status, dependency.Type); diff --git a/src/TUI/Pages/DependenciesPage.cs b/src/TUI/Pages/DependenciesPage.cs index f2b7f5e..c558011 100644 --- a/src/TUI/Pages/DependenciesPage.cs +++ b/src/TUI/Pages/DependenciesPage.cs @@ -62,20 +62,27 @@ public class DependenciesPage : PageBase var project = projectDependencies.Project; var actualDependencies = _store.ActualDependencies(project).ToArray(); - foreach (var conventionDependency in _store.ConventionDependencies) + if (!actualDependencies.Any()) { - var actualDependency = actualDependencies.SingleOrDefault( - dependency => string.Equals(dependency.Brand.Name, conventionDependency.Brand.Name, - StringComparison.CurrentCultureIgnoreCase)); - - if (actualDependency is null) + projectDependencies.AddError(); + } + else + { + foreach (var conventionDependency in _store.ConventionDependencies) { - projectDependencies.AddDependencyStub(); - continue; + var actualDependency = actualDependencies.SingleOrDefault( + dependency => string.Equals(dependency.Brand.Name, conventionDependency.Brand.Name, + StringComparison.CurrentCultureIgnoreCase)); + + if (actualDependency is null) + { + projectDependencies.AddDependencyStub(); + continue; + } + + var versionType = actualDependency.Comparison(conventionDependency); + projectDependencies.AddDependency(actualDependency, versionType); } - - var versionType = actualDependency.Comparison(conventionDependency); - projectDependencies.AddDependency(actualDependency, versionType); } Render(); diff --git a/src/TUI/Store/DependenciesStore.cs b/src/TUI/Store/DependenciesStore.cs index 6c0c431..8d4b8a9 100644 --- a/src/TUI/Store/DependenciesStore.cs +++ b/src/TUI/Store/DependenciesStore.cs @@ -1,5 +1,6 @@ using TUI.Controls.Components; using TUI.Domain; +using TUI.Engine; using TUI.Engine.Theme; using TUI.Providers.Dependencies; @@ -15,14 +16,15 @@ public class DependenciesStore public IEnumerable ActualDependencies(Project project) { - SpeakerComponent.Instance.Shout("", $"Fetch actual dependencies for project {project.Name.Main()}"); + SpeakerComponent.Instance.Shout(Symbols.Download.Info(), $"Fetch actual dependencies for project {project.Name.Main + ()}"); try { return Repository.ReadActual(project); } catch { - SpeakerComponent.Instance.Shout("", $"Fetch failed for project{project.Name}"); + SpeakerComponent.Instance.Shout(Symbols.Error.Error(), $"Fetch failed for project{project.Name}"); return new List(); } }