Add freeze tag for project.

This commit is contained in:
Kolosov Alexandr 2024-12-10 19:23:46 +05:00
parent 1bc1af71c9
commit 8e518ee19e
3 changed files with 55 additions and 33 deletions

View File

@ -11,25 +11,25 @@ public static class Palette
public const string ErrorColor = "CA3433"; public const string ErrorColor = "CA3433";
public const string WarningColor = "EC9706"; public const string WarningColor = "EC9706";
public const string InfoColor = "25799F"; public const string InfoColor = "25799F";
public static string Main(this string currentText, bool isFocused = true) => public static string Main(this string currentText, bool isFocused = true) =>
isFocused isFocused
? currentText.Pastel(PrimaryColor) ? currentText.Pastel(PrimaryColor)
: Hint(currentText); : Hint(currentText);
public static string Hint(this string currentText) => currentText.Pastel(HintColor); public static string Hint(this string currentText) => currentText.Pastel(HintColor);
public static string Hint(this char currentText) => currentText.ToString().Pastel(HintColor); public static string Hint(this char currentText) => currentText.ToString().Pastel(HintColor);
public static string Disable(this string currentText) => currentText.RemoveColors().Pastel(HintColor); public static string Disable(this string currentText) => currentText.RemoveColors().Pastel(HintColor);
public static string Warning(this string currentText) => currentText.Pastel(WarningColor); public static string Warning(this string currentText) => currentText.Pastel(WarningColor);
public static string Error(this string currentText) => currentText.Pastel(ErrorColor); public static string Error(this string currentText) => currentText.Pastel(ErrorColor);
public static string Info(this string currentText) => currentText.Pastel(InfoColor); public static string Info(this string currentText) => currentText.Pastel(InfoColor);
public static string Info(this char currentText) => currentText.ToString().Pastel(InfoColor); public static string Info(this char currentText) => currentText.ToString().Pastel(InfoColor);
public static string Info(this int currentText) => currentText.ToString().Pastel(InfoColor); public static string Info(this int currentText) => currentText.ToString().Pastel(InfoColor);
} }

View File

@ -15,45 +15,50 @@ namespace TUI.Controls.Containers;
public class DependenciesContainer : ContainerBase public class DependenciesContainer : ContainerBase
{ {
public readonly Project? Project; public readonly Project? Project;
private const int VersionColumnWidth = 11; private const int VersionColumnWidth = 11;
private const int TitleColumnWidth = 25; private const int TitleColumnWidth = 25;
private readonly Nodes _dependencies = new(); private readonly Nodes _dependencies = new();
public DependenciesContainer() public DependenciesContainer()
{ {
} }
public DependenciesContainer(Project project) public DependenciesContainer(Project project)
{ {
Project = project; Project = project;
} }
public void AddTitleStub() public void AddTitleStub()
{ {
var size = new Size(TitleColumnWidth, 1); var size = new Size(TitleColumnWidth, 1);
var title = new StubComponent(size); var title = new StubComponent(size);
title.SetPadding(Level.Normal); title.SetPadding(Level.Normal);
_dependencies.Add(title); _dependencies.Add(title);
} }
public void AddTitle(IComponent title) public void AddTitle(IComponent title)
{ {
title.SetPadding(Level.Normal); title.SetPadding(Level.Normal);
title.SetFixed(Orientation.Horizontal, TitleColumnWidth); title.SetFixed(Orientation.Horizontal, TitleColumnWidth);
title.SetAlignment(Horizontal.Left); title.SetAlignment(Horizontal.Left);
if (Project is not null && Project.Legacy) if (Project is not null && Project.Legacy)
{ {
title.StyleContext = new StyleContext(Palette.DisableColor); title.StyleContext = new StyleContext(Palette.DisableColor);
} }
if (Project is not null && Project.Freeze)
{
title.StyleContext = new StyleContext(Palette.InfoColor);
}
_dependencies.Add(title); _dependencies.Add(title);
} }
public void AddDependencyStub() public void AddDependencyStub()
{ {
var size = new Size(VersionColumnWidth, 1); var size = new Size(VersionColumnWidth, 1);
@ -61,15 +66,20 @@ public class DependenciesContainer : ContainerBase
stub.SetPadding(Level.Normal); stub.SetPadding(Level.Normal);
stub.SetAlignment(Horizontal.Right); stub.SetAlignment(Horizontal.Right);
stub.SetFixed(Orientation.Horizontal, VersionColumnWidth); stub.SetFixed(Orientation.Horizontal, VersionColumnWidth);
if (Project is not null && Project.Legacy) if (Project is not null && Project.Legacy)
{ {
stub.StyleContext = new StyleContext(Palette.DisableColor); stub.StyleContext = new StyleContext(Palette.DisableColor);
} }
if (Project is not null && Project.Freeze)
{
stub.StyleContext = new StyleContext(Palette.InfoColor);
}
_dependencies.Add(stub); _dependencies.Add(stub);
} }
public void AddError() public void AddError()
{ {
var size = new Size(25, 1); var size = new Size(25, 1);
@ -77,29 +87,39 @@ public class DependenciesContainer : ContainerBase
stub.SetPadding(Level.Normal); stub.SetPadding(Level.Normal);
stub.SetAlignment(Horizontal.Right); stub.SetAlignment(Horizontal.Right);
stub.SetFixed(Orientation.Horizontal, 25); stub.SetFixed(Orientation.Horizontal, 25);
if (Project is not null && Project.Legacy) if (Project is not null && Project.Legacy)
{ {
stub.StyleContext = new StyleContext(Palette.DisableColor); stub.StyleContext = new StyleContext(Palette.DisableColor);
} }
if (Project is not null && Project.Freeze)
{
stub.StyleContext = new StyleContext(Palette.InfoColor);
}
_dependencies.Add(stub); _dependencies.Add(stub);
} }
public void AddDependency(Dependency dependency, VersionStatus status = VersionStatus.BeNice) public void AddDependency(Dependency dependency, VersionStatus status = VersionStatus.BeNice)
{ {
var version = new VersionComponent(dependency.Version, dependency.Brand, status, dependency.Type); var version = new VersionComponent(dependency.Version, dependency.Brand, status, dependency.Type);
version.SetPadding(Level.Normal); version.SetPadding(Level.Normal);
version.SetAlignment(Horizontal.Right); version.SetAlignment(Horizontal.Right);
version.SetFixed(Orientation.Horizontal, VersionColumnWidth); version.SetFixed(Orientation.Horizontal, VersionColumnWidth);
if (Project is not null && Project.Legacy) if (Project is not null && Project.Legacy)
{ {
version.StyleContext = new StyleContext(Palette.DisableColor); version.StyleContext = new StyleContext(Palette.DisableColor);
} }
if (Project is not null && Project.Freeze)
{
version.StyleContext = new StyleContext(Palette.InfoColor);
}
_dependencies.Add(version); _dependencies.Add(version);
} }
public override Nodes GetNodes() => _dependencies; public override Nodes GetNodes() => _dependencies;
} }

View File

@ -3,12 +3,14 @@ namespace TUI.Domain;
public record Project(int Id, string Name, IEnumerable<string> Tags, Hub Hub) public record Project(int Id, string Name, IEnumerable<string> Tags, Hub Hub)
{ {
private IEnumerable<Dependency> Dependencies => new List<Dependency>(); private IEnumerable<Dependency> Dependencies => new List<Dependency>();
public bool IsPublicNetwork => Tags.Contains("public"); public bool IsPublicNetwork => Tags.Contains("public");
public bool HasAuth => Tags.Contains("auth"); public bool HasAuth => Tags.Contains("auth");
public bool SeoDependent => Tags.Contains("seo"); public bool SeoDependent => Tags.Contains("seo");
public bool Legacy => Tags.Contains("legacy"); public bool Legacy => Tags.Contains("legacy");
public bool Freeze => Tags.Contains("freeze");
} }