From f80a78f8cb32f10abc5912a61884a411bd7b3753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9A=D0=BE=D0=BB=D0=BE=D1=81=D0=BE=D0=B2?= Date: Mon, 1 Apr 2024 18:37:40 +0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20title=20for=20project=20depen?= =?UTF-8?q?dency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Domain/NewFile1.txt => docs/Features.txt | 66 +++++++++++++------ src/TUI.Engine/Components/Sketch.cs | 3 + src/TUI.Engine/SymbolExtensions.cs | 2 +- src/TUI.Engine/Symbols.cs | 2 +- src/TUI/Controls/Components/ProjectTitle.cs | 47 +++++++++++++ src/TUI/Controls/Components/Tag.cs | 61 ----------------- .../Controls/Containers/DashboardContainer.cs | 3 +- .../Containers/DependenciesContainer.cs | 3 +- src/TUI/Controls/Statics/Hints/TagHints.cs | 2 +- src/TUI/Domain/Hub.cs | 6 ++ src/TUI/Domain/Project.cs | 12 ++++ src/TUI/Pages/DependenciesPage.cs | 22 +++++-- .../Dependencies/DependencyRepository.cs | 20 +++++- src/TUI/Store/DependenciesStore.cs | 51 ++++++++------ src/TUI/TUI.csproj | 3 - src/TUI/UserInterface/Icons.cs | 2 +- 16 files changed, 186 insertions(+), 119 deletions(-) rename src/TUI/Domain/NewFile1.txt => docs/Features.txt (63%) create mode 100644 src/TUI/Controls/Components/ProjectTitle.cs delete mode 100644 src/TUI/Controls/Components/Tag.cs create mode 100644 src/TUI/Domain/Hub.cs create mode 100644 src/TUI/Domain/Project.cs diff --git a/src/TUI/Domain/NewFile1.txt b/docs/Features.txt similarity index 63% rename from src/TUI/Domain/NewFile1.txt rename to docs/Features.txt index e9fb9e2..49b2b06 100644 --- a/src/TUI/Domain/NewFile1.txt +++ b/docs/Features.txt @@ -9,35 +9,52 @@  be nice 󰚩 SEO  site 󰬟 too old  VCS  api - 󰦖 wait 󰲽 build 󱓞 release - 󱔢 reopen 󱞈 testing 󰶯 hotfix - 󱞇 in progress 󰦕 done  publish - 󱞇 review 󱄊 cancel - -   releases 󱓟  Fact  2023 -   releases 󱓟  Fact -   releases 󱓟  Planned -   releases 󱓟  Planned  2024-12-31 xfirm -   competencies 󰧑 -   growth zone 󰶼 -   dependencies  +   󱓟 releases  Fact  2023 +   󱓟 releases  Fact +   󱓟 releases  Planned +   󱓟 releases  Planned  2024-12-31 xfirm +   󰧑 competencies +   󰶼 growth zone +    dependencies +   󱁤 tools + + + +󰦖 wait 󰲽 build +󱔢 reopen 󱞈 testing +󱞇 in progress 󰦕 done +󱞇 review 󱄊 cancel ┌──────────────────────────────────────────────────────────────────────── Planned release ─────────────────────────────────────────────────────────────────┐ -│ 2024-12-31 4/11 xfirm [############# ] //green - done, blue - test, pink review/build, orange WIP -│ 4/11 xfirm [###############.......] //green - done, blue - test, pink review/build -│ 2024-12-31 4/11 xfirm [###############.......] //green - done, blue - test, pink review/build -│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build -│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build -│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build -│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build -│ 2024-12-31 xfirm 4/11 [############..........] //green - done, blue - test, pink review/build +│ 󱓟 Planned 󱜜 󰲌 application  Tasks +│ 2024-12-31 1d elk-site 4/11 󰦕 󰦕 󰦕 󰦕 󱞇 󱞇 󱞇 󱞈 󱞈 󱔢 󰦖 󰦖 󰦖 +│ elk-site 2/5 󰦕 󰦕 󰦖 󰦖 󰦖 +│ elk-site 22/22 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󰦕 󱞇 󱞇 󱞇 󱞈 󱞈 󱞈 󱔢 󰦖 󰦖 󰦖 +│ 2024-12-31 12d xfirm 4/12 󰦕 󰦕 󰦕 󰦕 󱞇 󱞇 󱞇 󱞈 󱞈 󱞈 󱔢 󰦖 󰦖 󰦖 └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + + + +󰨑 show stopper 󰦖 wait 󰲽 build  feature +󰨑 first of all 󱔢 reopen 󱞈 testing  bug +󰨑 just do it 󱞇 in progress 󰦕 done +󰨑 doesn't rush 󱞇 review 󱄊 cancel + ┌──────────────────────────────────────────────────────────────────────── checkperson-site ────────────────────────────────────────────────────────────────┐ │ 󰨑 󰦖  ELK-3628 Create new menu.  Anna P. 󰵮 Petrov A. 󰙨 Ivanov I. │ 󰨑 󰦕  XF-12 Change input hover.  Alex K. 󰵮 Ivanov I. 󰙨 Petrov A., Petrov B. │ 󰨑 󱞇  ELK-3628 Crete new project with menu, profile, issues and #  Anna P. 󰵮 Ivanov I. 󰙨 Petrov A., Petrov B. └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ + + + + publish +󱓞 release +󰶯 hotfix +󱓞 release candidate + ┌─────────────────────────────────────────────────────────────────────────── Actual releases 2023 ─────────────────────────────────────────────────────────┐ │ Jan Feb Mar Apl May Jun Jul Aug Sep Oct Nov Dec │ ├─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤ @@ -48,5 +65,12 @@ + GA4  Jaeger 󰡾 Fallback  Screenshots  Connected  Auth +Я YM  Prometheus 󰉼 Renovate  End2End  Disconnected 󰖟 WWW +󰩃 Husky 󱎴 Sentry 󱉕 Lighthouse  Unit  Not implemented 󰚩 SEO + Probs  Grafana 󱂅 Kibana  Coverage  No need - +┌─────────────────────────────────────────────────────────────────────────── Tools ──────────────────────────────────┐ +│   Я  󰉼 󰩃 󱎴 󱉕   󱂅     󰖟 󰚩  󰡾 +│ elk-site                    +└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ diff --git a/src/TUI.Engine/Components/Sketch.cs b/src/TUI.Engine/Components/Sketch.cs index 6cd7da4..ed96902 100644 --- a/src/TUI.Engine/Components/Sketch.cs +++ b/src/TUI.Engine/Components/Sketch.cs @@ -1,3 +1,4 @@ +using System.Text; using TUI.Engine.Attributes; namespace TUI.Engine.Components; @@ -8,6 +9,8 @@ public sealed class Sketch : IEnumerable public Sketch(string content) => ContentRows = content.Split(Symbols.LineBreak); + public Sketch(StringBuilder builder) => ContentRows = builder.ToString().Split(Symbols.LineBreak); + public IEnumerator GetEnumerator() => ContentRows.GetEnumerator(); public IEnumerable Crop(Size maxSize) => ContentRows diff --git a/src/TUI.Engine/SymbolExtensions.cs b/src/TUI.Engine/SymbolExtensions.cs index 86e6a65..9454063 100644 --- a/src/TUI.Engine/SymbolExtensions.cs +++ b/src/TUI.Engine/SymbolExtensions.cs @@ -18,7 +18,7 @@ public static class SymbolExtensions { Symbols.Api, "7F52FF" }, { Symbols.DockerImage, "086DD7" }, { Symbols.NpmPackage, "CB0000" }, - { Symbols.SEO, "4285F4" }, + { Symbols.Seo, "4285F4" }, { Symbols.Auth, "FFD700" }, }; } \ No newline at end of file diff --git a/src/TUI.Engine/Symbols.cs b/src/TUI.Engine/Symbols.cs index a96a98f..b88094e 100644 --- a/src/TUI.Engine/Symbols.cs +++ b/src/TUI.Engine/Symbols.cs @@ -15,7 +15,7 @@ public static class Symbols public const string Api = ""; public const string DockerImage = ""; public const string NpmPackage = ""; - public const string SEO = "󰚩"; + public const string Seo = "󰚩"; public const string Auth = ""; public const string NotFound = ""; diff --git a/src/TUI/Controls/Components/ProjectTitle.cs b/src/TUI/Controls/Components/ProjectTitle.cs new file mode 100644 index 0000000..2a75355 --- /dev/null +++ b/src/TUI/Controls/Components/ProjectTitle.cs @@ -0,0 +1,47 @@ +using System.Text; +using TUI.Domain; +using TUI.Engine; +using TUI.Engine.Attributes; +using TUI.Engine.Components; +using TUI.Engine.Theme; +using TUI.UserInterface; +using static TUI.Engine.Symbols; + +namespace TUI.Controls.Components; + +public class ProjectTitle : ComponentBase +{ + private readonly Project _project; + + public ProjectTitle(Project project) + { + _project = project; + } + + protected override Sketch DrawComponent(Size minSize) + { + var builder = new StringBuilder(); + builder.Append(GetHub().Colorized()); + builder.Append(Space); + builder.Append((_project.IsPublicNetwork ? NetworkPublic : NetworkPrivate).Colorized()); + builder.Append(Space); + builder.Append(_project.SeoDependent ? Seo.Colorized() : Seo.Disable()); + builder.Append(Space); + builder.Append(_project.HasAuth ? Auth.Colorized() : Auth.Disable()); + builder.Append(Space); + builder.Append(GetApplicationType().Colorized()); + builder.Append(Space); + builder.Append(_project.Name.Disable()); + return new Sketch(builder); + } + + private string GetHub() => _project.Hub == "gitlab" ? GitLab : GitHub; + + private string GetApplicationType() + { + foreach (var application in Icons.Applications.Where(application => _project.Tags.Have(application.Value))) + return application.Key; + + return Undefined.Hint(); + } +} \ No newline at end of file diff --git a/src/TUI/Controls/Components/Tag.cs b/src/TUI/Controls/Components/Tag.cs deleted file mode 100644 index 392064c..0000000 --- a/src/TUI/Controls/Components/Tag.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Text; -using TUI.Engine; -using TUI.Engine.Attributes; -using TUI.Engine.Attributes.Alignments; -using TUI.Engine.Components; -using TUI.Engine.Theme; -using TUI.UserInterface; - -namespace TUI.Controls.Components; - -public class Tag : ComponentBase -{ - private IEnumerable _tags; - private string _gitType; - - public void Bind(IEnumerable tags, string gitType) - { - _tags = tags; - _gitType = gitType; - } - - public void Render(Horizontal horizontal, Size size) - { - var tagBuilder = new StringBuilder(); - - tagBuilder.Append(GetGitTypeImage(_gitType)); - tagBuilder.Append(Symbols.Space); - tagBuilder.Append(_tags.Have("public") ? Symbols.NetworkPublic : Symbols.NetworkPrivate); - tagBuilder.Append(Symbols.Space); - tagBuilder.Append(_tags.Have("seo") ? Symbols.SEO : Symbols.SEO.Disable()); - tagBuilder.Append(Symbols.Space); - tagBuilder.Append(_tags.Have("auth") ? Symbols.Auth : Symbols.Auth.Disable()); - tagBuilder.Append(Symbols.Space); - tagBuilder.Append(GetApplicationType()); - tagBuilder.Append(Symbols.Space); - - // base.Render(tagBuilder, position, size); - } - - private string GetApplicationType() - { - foreach (var application in Icons.Applications) - if (_tags.Have(application.Value)) - return application.Key; - - return Symbols.Undefined; - } - - private static string GetGitTypeImage(string gitType) => - gitType switch - { - "gitlab" => Symbols.GitLab, - "github" => Symbols.GitHub, - _ => Symbols.Git - }; - - protected override Sketch DrawComponent(Size minSize) - { - throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/src/TUI/Controls/Containers/DashboardContainer.cs b/src/TUI/Controls/Containers/DashboardContainer.cs index e083c49..d2ab1d0 100644 --- a/src/TUI/Controls/Containers/DashboardContainer.cs +++ b/src/TUI/Controls/Containers/DashboardContainer.cs @@ -13,8 +13,7 @@ public class DashboardContainer : ContainerBase public DashboardContainer() { - // var panel = new PanelComponent("Dependencies ".Info() + Symbols.Node.Colorized()); - var panel = new PanelComponent("Dependencies".Info()); + var panel = new PanelComponent(" ".Info() + "Dependencies".Main()); _content = new ContentContainer(); _content.SetOrientationVertical(); SetOrientationVertical(); diff --git a/src/TUI/Controls/Containers/DependenciesContainer.cs b/src/TUI/Controls/Containers/DependenciesContainer.cs index 37b9c8f..a6be9db 100644 --- a/src/TUI/Controls/Containers/DependenciesContainer.cs +++ b/src/TUI/Controls/Containers/DependenciesContainer.cs @@ -14,7 +14,7 @@ namespace TUI.Controls.Containers; public class DependenciesContainer : ContainerBase { private const int VersionColumnWidth = 10; - private const int TitleColumnWidth = 20; + private const int TitleColumnWidth = 25; private readonly Nodes _dependencies = new(); @@ -31,6 +31,7 @@ public class DependenciesContainer : ContainerBase { title.SetPadding(Level.Normal); title.SetFixed(Orientation.Horizontal, TitleColumnWidth); + title.SetAlignment(Horizontal.Left); _dependencies.Add(title); } diff --git a/src/TUI/Controls/Statics/Hints/TagHints.cs b/src/TUI/Controls/Statics/Hints/TagHints.cs index 912c605..8ee1a95 100644 --- a/src/TUI/Controls/Statics/Hints/TagHints.cs +++ b/src/TUI/Controls/Statics/Hints/TagHints.cs @@ -11,7 +11,7 @@ public class TagHints : StaticComponentBase { { Symbols.Auth, "Auth" }, { Symbols.NetworkPublic, "WWW" }, - { Symbols.SEO, "SEO" }, + { Symbols.Seo, "SEO" }, { Symbols.Git, "VCS" } }; diff --git a/src/TUI/Domain/Hub.cs b/src/TUI/Domain/Hub.cs new file mode 100644 index 0000000..ff0a924 --- /dev/null +++ b/src/TUI/Domain/Hub.cs @@ -0,0 +1,6 @@ +namespace TUI.Domain; + +public record Hub +{ + +} \ No newline at end of file diff --git a/src/TUI/Domain/Project.cs b/src/TUI/Domain/Project.cs new file mode 100644 index 0000000..1764c0b --- /dev/null +++ b/src/TUI/Domain/Project.cs @@ -0,0 +1,12 @@ +namespace TUI.Domain; + +public record Project(int Id, string Name, IEnumerable Tags, string Hub) +{ + private IEnumerable Dependencies => new List(); + + public bool IsPublicNetwork => Tags.Contains("public"); + + public bool HasAuth => Tags.Contains("auth"); + + public bool SeoDependent => Tags.Contains("seo"); +} \ No newline at end of file diff --git a/src/TUI/Pages/DependenciesPage.cs b/src/TUI/Pages/DependenciesPage.cs index bd1862a..aa2ecd1 100644 --- a/src/TUI/Pages/DependenciesPage.cs +++ b/src/TUI/Pages/DependenciesPage.cs @@ -1,10 +1,12 @@ using System.Diagnostics; +using TUI.Controls.Components; using TUI.Controls.Containers; using TUI.Controls.Layouts; using TUI.Controls.Statics; using TUI.Domain; using TUI.Engine.Rendering.Canvas; using TUI.Providers.Dependencies; +using TUI.Store; namespace TUI.Pages; @@ -31,7 +33,7 @@ public abstract class PageBase : IPage public class DependenciesPage : PageBase { - private IEnumerable ConventionDependencies; + private DependenciesStore _store; public override void Render() { @@ -43,23 +45,31 @@ public class DependenciesPage : PageBase var dependenciesHeader = new DependenciesContainer(); dependenciesHeader.AddTitleStub(); - foreach (var conventionDependency in ConventionDependencies) + foreach (var conventionDependency in _store.ConventionDependencies) { dependenciesHeader.AddDependency(conventionDependency); } dashboard.AddChildren(dependenciesHeader); - // CommandLine = new CommandLine(); - // DependenciesView = new DependenciesView(); + + foreach (var project in _store.Projects) + { + var projectDependencies = new DependenciesContainer(); + projectDependencies.AddTitle(new ProjectTitle(project)); + dashboard.AddChildren(projectDependencies); + } var layout = new DashboardLayout(header, dashboard, copyright); canvas.Draw(layout); + + // CommandLine = new CommandLine(); + // DependenciesView = new DependenciesView(); } public override void Bind() { - var repo = new DependencyRepository(); - ConventionDependencies = repo.Read("javascript"); + _store = new DependenciesStore(); + _store.Bind(); } // private bool _commandLineInDisplay; diff --git a/src/TUI/Providers/Dependencies/DependencyRepository.cs b/src/TUI/Providers/Dependencies/DependencyRepository.cs index 9b2845d..80d5c91 100644 --- a/src/TUI/Providers/Dependencies/DependencyRepository.cs +++ b/src/TUI/Providers/Dependencies/DependencyRepository.cs @@ -29,7 +29,7 @@ public class DependencyRepository } } - public IEnumerable Read(string stackName) + public IEnumerable ReadConventions(string stackName) { return DependenciesDto.Stacks .Single(stack => stack.Name == stackName) @@ -40,4 +40,22 @@ public class DependencyRepository return new Dependency(convention.Version, brand); }); } + + public IEnumerable ReadProjects(string stackName) + { + var projects = new List(); + + var hubs = DependenciesDto.Stacks + .Single(stack => stack.Name == stackName) + .Hubs; + + foreach (var hub in hubs) + { + projects.AddRange(hub + .Projects + .Select(proj => new Project(proj.Id, proj.Name, proj.Tags, hub.Type))); + } + + return projects; + } } \ No newline at end of file diff --git a/src/TUI/Store/DependenciesStore.cs b/src/TUI/Store/DependenciesStore.cs index d7f4388..e32d540 100644 --- a/src/TUI/Store/DependenciesStore.cs +++ b/src/TUI/Store/DependenciesStore.cs @@ -1,30 +1,41 @@ -using System.Text.Json; +using TUI.Domain; using TUI.Providers.Dependencies; namespace TUI.Store; -public static class DependenciesStore +public class DependenciesStore { - private readonly static Dictionary Packages = new(); + public IEnumerable ConventionDependencies; - private static Package DownloadPackage(ProjectDto projectDto) + public IEnumerable Projects; + + public void Bind() { - // var endpoint = projectDto.Tags.Have("gitlab") ? GetGitlabEndpoint(projectDto) : projectDto.Repo; - var endpoint = ""; - if (Packages.TryGetValue(endpoint, out var downloadPackage)) return downloadPackage; - - using HttpClient client = new(); - var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult(); - var package = JsonSerializer.Deserialize(json); - Packages.Add(endpoint, package); - return package; + var repo = new DependencyRepository(); + ConventionDependencies = repo.ReadConventions("javascript"); + Projects = repo.ReadProjects("javascript"); } - private static string GetGitlabEndpoint(ProjectDto projectDto) - { - var token = Environment.GetEnvironmentVariable("TLD_GITLAB_PAT"); - // return $"{projectDto.Repo}/api/v4/projects/{projectDto.ProjectId}/repository/files/package.json/raw?" + - // $"private_token={token}&ref=dev"; - return ""; - } + // private readonly static Dictionary Packages = new(); + // + // private static Package DownloadPackage(ProjectDto projectDto) + // { + // // var endpoint = projectDto.Tags.Have("gitlab") ? GetGitlabEndpoint(projectDto) : projectDto.Repo; + // var endpoint = ""; + // if (Packages.TryGetValue(endpoint, out var downloadPackage)) return downloadPackage; + // + // using HttpClient client = new(); + // var json = client.GetStringAsync(endpoint).GetAwaiter().GetResult(); + // var package = JsonSerializer.Deserialize(json); + // Packages.Add(endpoint, package); + // return package; + // } + // + // private static string GetGitlabEndpoint(ProjectDto projectDto) + // { + // var token = Environment.GetEnvironmentVariable("TLD_GITLAB_PAT"); + // // return $"{projectDto.Repo}/api/v4/projects/{projectDto.ProjectId}/repository/files/package.json/raw?" + + // // $"private_token={token}&ref=dev"; + // return ""; + // } } \ No newline at end of file diff --git a/src/TUI/TUI.csproj b/src/TUI/TUI.csproj index f38e70b..8cf2073 100644 --- a/src/TUI/TUI.csproj +++ b/src/TUI/TUI.csproj @@ -30,8 +30,5 @@ - - - diff --git a/src/TUI/UserInterface/Icons.cs b/src/TUI/UserInterface/Icons.cs index e904383..1819575 100644 --- a/src/TUI/UserInterface/Icons.cs +++ b/src/TUI/UserInterface/Icons.cs @@ -10,7 +10,7 @@ public static class Icons { { Symbols.NpmPackage.Colorized(), "package" }, { Symbols.DockerImage.Colorized(), "image" }, - { Symbols.Site.Pastel("666666"), "site" }, + { Symbols.Site.Colorized(), "site" }, { Symbols.Api, "api" } }; } \ No newline at end of file