Skip to content

Commit

Permalink
Added Icons to primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
dyatlov-a committed Sep 22, 2024
1 parent 1f40ccd commit 480ae6c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 31 deletions.
15 changes: 15 additions & 0 deletions src/Inc.TeamAssistant.Primitives/Icons.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Inc.TeamAssistant.Primitives;

public static class Icons
{
public static readonly string TrendUp = "👍";
public static readonly string TrendDown = "👎";
public static readonly string Alert = "❗";
public static readonly string Waiting = "⏳";
public static readonly string InProgress = "🤩";
public static readonly string OnCorrection = "😱";
public static readonly string Accept = "🤝";
public static readonly string Comment = "💬";
public static readonly string Start = "⭐";
public static readonly string Ok = "👌";
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public async Task<NotificationMessage> Build(
if (!await _service.HasTeammate(draft.TeamId, draft.TargetPersonId.Value, token))
{
messageBuilder.AppendLine();
messageBuilder.Append('❗');
messageBuilder.Append(Icons.Alert);
messageBuilder.Append(await _messageBuilder.Build(
Messages.Reviewer_PreviewCheckTeammate,
languageId,
Expand All @@ -144,7 +144,7 @@ public async Task<NotificationMessage> Build(
if (!_service.HasDescriptionAndLinks(draft.Description))
{
messageBuilder.AppendLine();
messageBuilder.Append('❗');
messageBuilder.Append(Icons.Alert);
messageBuilder.Append(await _messageBuilder.Build(Messages.Reviewer_PreviewCheckDescription, languageId));
messageBuilder.AppendLine();
}
Expand Down Expand Up @@ -194,33 +194,30 @@ await _messageBuilder.Build(Messages.Reviewer_PreviewRemoveDraft, languageId),
}

private async Task<NotificationMessage> MessageForTeam(
TaskForReview taskForReview,
TaskForReview task,
Person reviewer,
Person owner,
ReviewTeamMetrics metricsByTeam,
ReviewTeamMetrics metricsByTask,
CancellationToken token)
{
ArgumentNullException.ThrowIfNull(taskForReview);
ArgumentNullException.ThrowIfNull(task);
ArgumentNullException.ThrowIfNull(reviewer);
ArgumentNullException.ThrowIfNull(owner);
ArgumentNullException.ThrowIfNull(metricsByTeam);
ArgumentNullException.ThrowIfNull(metricsByTask);

Func<NotificationMessage, NotificationMessage> attachPersons = n => n;
var languageId = await _teamAccessor.GetClientLanguage(taskForReview.BotId, owner.Id, token);
var state = taskForReview.State switch
var languageId = await _teamAccessor.GetClientLanguage(task.BotId, owner.Id, token);
var state = task.State switch
{
TaskForReviewState.New => "⏳",
TaskForReviewState.InProgress => "🤩",
TaskForReviewState.OnCorrection => "😱",
TaskForReviewState.Accept => "🤝",
_ => throw new ArgumentOutOfRangeException(
nameof(TaskForReviewState),
taskForReview.State,
"State out of range.")
TaskForReviewState.New => Icons.Waiting,
TaskForReviewState.InProgress => Icons.InProgress,
TaskForReviewState.OnCorrection => Icons.OnCorrection,
TaskForReviewState.Accept => Icons.Accept,
_ => throw new ArgumentOutOfRangeException(nameof(TaskForReviewState), task.State, "State out of range.")
};
var reviewerTargetMessageKey = taskForReview.HasConcreteReviewer
var reviewerTargetMessageKey = task.HasConcreteReviewer
? Messages.Reviewer_TargetManually
: Messages.Reviewer_TargetAutomatically;

Expand All @@ -233,11 +230,11 @@ private async Task<NotificationMessage> MessageForTeam(
messageBuilder.AppendLine();

messageBuilder.AppendLine();
messageBuilder.AppendLine(taskForReview.Description);
messageBuilder.AppendLine(task.Description);
messageBuilder.AppendLine(state);

var stats = await _reviewStatsBuilder.Build(
taskForReview,
task,
metricsByTeam,
metricsByTask,
languageId,
Expand All @@ -246,13 +243,13 @@ private async Task<NotificationMessage> MessageForTeam(
messageBuilder.Append(stats);

var message = messageBuilder.ToString();
var notification = taskForReview.MessageId.HasValue
? NotificationMessage.Edit(new ChatMessage(taskForReview.ChatId, taskForReview.MessageId.Value), message)
var notification = task.MessageId.HasValue
? NotificationMessage.Edit(new ChatMessage(task.ChatId, task.MessageId.Value), message)
: NotificationMessage
.Create(taskForReview.ChatId, message)
.Create(task.ChatId, message)
.AddHandler((c, p) => new AttachMessageCommand(
c,
taskForReview.Id,
task.Id,
int.Parse(p),
MessageType.Shared.ToString()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ namespace Inc.TeamAssistant.Reviewer.Application.Services;

internal sealed class ReviewStatsBuilder
{
private const string TrendUp = "👍";
private const string TrendDown = "👎";

private readonly IMessageBuilder _messageBuilder;

public ReviewStatsBuilder(IMessageBuilder messageBuilder)
Expand Down Expand Up @@ -45,15 +42,19 @@ public async Task<StringBuilder> Build(
{
if (hasReviewMetrics)
{
var firstTouchTrend = metricsByTask.FirstTouch <= metricsByTeam.FirstTouch ? TrendUp : TrendDown;
var firstTouchTrend = metricsByTask.FirstTouch <= metricsByTeam.FirstTouch
? Icons.TrendUp
: Icons.TrendDown;
var firstTouchMessage = await _messageBuilder.Build(
Messages.Reviewer_StatsFirstTouch,
languageId,
metricsByTask.FirstTouch.ToString(GlobalSettings.TimeFormat),
metricsByTeam.FirstTouch.ToString(GlobalSettings.TimeFormat));
builder.AppendLine($"{firstTouchMessage} {firstTouchTrend}");

var reviewTrend = metricsByTask.Review <= metricsByTeam.Review ? TrendUp : TrendDown;
var reviewTrend = metricsByTask.Review <= metricsByTeam.Review
? Icons.TrendUp
: Icons.TrendDown;
var reviewMessage = await _messageBuilder.Build(
Messages.Reviewer_StatsReview,
languageId,
Expand All @@ -64,7 +65,9 @@ public async Task<StringBuilder> Build(

if (hasCorrectionMetrics && attempts.HasValue)
{
var correctionTrend = metricsByTask.Correction <= metricsByTeam.Correction ? TrendUp : TrendDown;
var correctionTrend = metricsByTask.Correction <= metricsByTeam.Correction
? Icons.TrendUp
: Icons.TrendDown;
var correctionMessage = await _messageBuilder.Build(
Messages.Reviewer_StatsCorrection,
languageId,
Expand Down
10 changes: 6 additions & 4 deletions src/Inc.TeamAssistant.WebUI/Features/Main/MainPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@page "/en"
@page "/ru"

@using Inc.TeamAssistant.Primitives

@inject IRenderContext RenderContext
@inject ResourcesManager Resources
@inject LinkBuilder LinkBuilder
Expand All @@ -19,13 +21,13 @@
</h1>
<br/>
<p class="about-bots__description">
<span class="about-bots__item">👌 @Resources[Messages.GUI_ToolAppraiser]</span>
<span class="about-bots__item">@Icons.Ok @Resources[Messages.GUI_ToolAppraiser]</span>
<br/>
<span class="about-bots__item">🤝 @Resources[Messages.GUI_ToolReviewer]</span>
<span class="about-bots__item">@Icons.Accept @Resources[Messages.GUI_ToolReviewer]</span>
<br/>
<span class="about-bots__item">💬 @Resources[Messages.GUI_ToolRandomCoffee]</span>
<span class="about-bots__item">@Icons.Comment @Resources[Messages.GUI_ToolRandomCoffee]</span>
<br/>
<span class="about-bots__item"> @Resources[Messages.GUI_ToolCheckIn]</span>
<span class="about-bots__item">@Icons.Start @Resources[Messages.GUI_ToolCheckIn]</span>
</p>
<div class="about-bots__actions">
<a
Expand Down

0 comments on commit 480ae6c

Please sign in to comment.