Skip to content

Commit

Permalink
Refactoring ResourcesManager
Browse files Browse the repository at this point in the history
  • Loading branch information
dyatlov-a committed Sep 24, 2024
1 parent 2b339a5 commit 9fb9701
Show file tree
Hide file tree
Showing 17 changed files with 268 additions and 258 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using Inc.TeamAssistant.Appraiser.Domain;
using Inc.TeamAssistant.Primitives.FeatureProperties;
using Inc.TeamAssistant.Primitives.Languages;

namespace Inc.TeamAssistant.Appraiser.Application.Services;

internal sealed class AppraiserSettingSectionProvider : ISettingSectionProvider
{
private readonly IReadOnlyDictionary<StoryType, string> _storyType = new Dictionary<StoryType, string>
private readonly IReadOnlyDictionary<StoryType, MessageId> _storyType = new Dictionary<StoryType, MessageId>
{
[StoryType.Fibonacci] = "Constructor_FormSectionSetSettingsFibonacciDescription",
[StoryType.TShirt] = "Constructor_FormSectionSetSettingsTShirtDescription",
[StoryType.PowerOfTwo] = "Constructor_FormSectionSetSettingsPowerOfTwoDescription"
[StoryType.Fibonacci] = new("Constructor_FormSectionSetSettingsFibonacciDescription"),
[StoryType.TShirt] = new("Constructor_FormSectionSetSettingsTShirtDescription"),
[StoryType.PowerOfTwo] = new("Constructor_FormSectionSetSettingsPowerOfTwoDescription")
};

public string FeatureName => "Appraiser";
Expand All @@ -19,12 +20,12 @@ public IReadOnlyCollection<SettingSection> GetSections()
return
[
new SettingSection(
"Constructor_FormSectionSetSettingsAppraiserHeader",
"Constructor_FormSectionSetSettingsAppraiserHelp",
new("Constructor_FormSectionSetSettingsAppraiserHeader"),
new("Constructor_FormSectionSetSettingsAppraiserHelp"),
[
new(
AppraiserProperties.StoryTypeKey,
"Constructor_FormSectionSetSettingsStoryTypeFieldLabel",
new("Constructor_FormSectionSetSettingsStoryTypeFieldLabel"),
GetValuesForStoryType().ToArray())
])
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Inc.TeamAssistant.Primitives.Languages;

namespace Inc.TeamAssistant.Primitives.FeatureProperties;

public sealed record SelectValue(string MessageId, string Value);
public sealed record SelectValue(MessageId MessageId, string Value);
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Inc.TeamAssistant.Primitives.Languages;

namespace Inc.TeamAssistant.Primitives.FeatureProperties;

public sealed record SettingItem(
string PropertyName,
string LabelMessageId,
MessageId LabelMessageId,
IReadOnlyCollection<SelectValue> Values);
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Inc.TeamAssistant.Primitives.Languages;

namespace Inc.TeamAssistant.Primitives.FeatureProperties;

public sealed record SettingSection(
string HeaderMessageId,
string HelpMessageId,
MessageId HeaderMessageId,
MessageId HelpMessageId,
IReadOnlyCollection<SettingItem> SettingItems);
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,34 @@ public IReadOnlyCollection<SettingSection> GetSections()
return
[
new SettingSection(
"Constructor_FormSectionSetSettingsRandomCoffeeHeader",
"Constructor_FormSectionSetSettingsRandomCoffeeHelp",
new("Constructor_FormSectionSetSettingsRandomCoffeeHeader"),
new("Constructor_FormSectionSetSettingsRandomCoffeeHelp"),
[
new(
RandomCoffeeProperties.RoundIntervalKey,
"Constructor_FormSectionSetSettingsRoundIntervalFieldLabel",
new("Constructor_FormSectionSetSettingsRoundIntervalFieldLabel"),
GetValuesForRoundInterval().ToArray()),
new(
RandomCoffeeProperties.VotingIntervalKey,
"Constructor_FormSectionSetSettingsVotingIntervalFieldLabel",
new("Constructor_FormSectionSetSettingsVotingIntervalFieldLabel"),
GetValuesForVotingInterval().ToArray())
])
];
}

private IEnumerable<SelectValue> GetValuesForRoundInterval()
{
yield return new SelectValue("Constructor_FormSectionSetSettingsRoundInterval1Description", "7.00:00:00");
yield return new SelectValue("Constructor_FormSectionSetSettingsRoundInterval2Description", "14.00:00:00");
yield return new SelectValue("Constructor_FormSectionSetSettingsRoundInterval3Description", "21.00:00:00");
yield return new SelectValue("Constructor_FormSectionSetSettingsRoundInterval4Description", "28.00:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsRoundInterval1Description"), "7.00:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsRoundInterval2Description"), "14.00:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsRoundInterval3Description"), "21.00:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsRoundInterval4Description"), "28.00:00:00");
}

private IEnumerable<SelectValue> GetValuesForVotingInterval()
{
yield return new SelectValue("Constructor_FormSectionSetSettingsVotingInterval1Description", "02:00:00");
yield return new SelectValue("Constructor_FormSectionSetSettingsVotingInterval2Description", "04:00:00");
yield return new SelectValue("Constructor_FormSectionSetSettingsVotingInterval3Description", "1.00:00:00");
yield return new SelectValue("Constructor_FormSectionSetSettingsVotingInterval4Description", "2.00:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsVotingInterval1Description"), "02:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsVotingInterval2Description"), "04:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsVotingInterval3Description"), "1.00:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsVotingInterval4Description"), "2.00:00:00");
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using Inc.TeamAssistant.Primitives.FeatureProperties;
using Inc.TeamAssistant.Primitives.Languages;
using Inc.TeamAssistant.Reviewer.Domain;

namespace Inc.TeamAssistant.Reviewer.Application.Services;

internal sealed class ReviewerSettingSectionProvider : ISettingSectionProvider
{
private readonly IReadOnlyDictionary<NextReviewerType, string> _storyType = new Dictionary<NextReviewerType, string>
private readonly IReadOnlyDictionary<NextReviewerType, MessageId> _storyType = new Dictionary<NextReviewerType, MessageId>
{
[NextReviewerType.RoundRobin] = "Constructor_FormSectionSetSettingsRoundRobinDescription",
[NextReviewerType.Random] = "Constructor_FormSectionSetSettingsRandomDescription"
[NextReviewerType.RoundRobin] = new("Constructor_FormSectionSetSettingsRoundRobinDescription"),
[NextReviewerType.Random] = new("Constructor_FormSectionSetSettingsRandomDescription")
};

public string FeatureName => "Reviewer";
Expand All @@ -18,20 +19,20 @@ public IReadOnlyCollection<SettingSection> GetSections()
return
[
new SettingSection(
"Constructor_FormSectionSetSettingsReviewerHeader",
"Constructor_FormSectionSetSettingsReviewerHelp",
new("Constructor_FormSectionSetSettingsReviewerHeader"),
new("Constructor_FormSectionSetSettingsReviewerHelp"),
[
new(
ReviewerProperties.NextReviewerTypeKey,
"Constructor_FormSectionSetSettingsNextReviewerStrategyFieldLabel",
new("Constructor_FormSectionSetSettingsNextReviewerStrategyFieldLabel"),
GetValuesForNextReviewerType().ToArray()),
new(
ReviewerProperties.WaitingNotificationIntervalKey,
"Constructor_FormSectionSetSettingsWaitingNotificationIntervalFieldLabel",
new("Constructor_FormSectionSetSettingsWaitingNotificationIntervalFieldLabel"),
GetValuesForNotificationInterval().ToArray()),
new(
ReviewerProperties.InProgressNotificationIntervalKey,
"Constructor_FormSectionSetSettingsInProgressNotificationIntervalFieldLabel",
new("Constructor_FormSectionSetSettingsInProgressNotificationIntervalFieldLabel"),
GetValuesForNotificationInterval().ToArray())
])
];
Expand All @@ -46,9 +47,9 @@ private IEnumerable<SelectValue> GetValuesForNextReviewerType()

private IEnumerable<SelectValue> GetValuesForNotificationInterval()
{
yield return new SelectValue("Constructor_FormSectionSetSettingsNotificationInterval1Description", "00:30:00");
yield return new SelectValue("Constructor_FormSectionSetSettingsNotificationInterval2Description", "01:00:00");
yield return new SelectValue("Constructor_FormSectionSetSettingsNotificationInterval3Description", "01:30:00");
yield return new SelectValue("Constructor_FormSectionSetSettingsNotificationInterval4Description", "02:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsNotificationInterval1Description"), "00:30:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsNotificationInterval2Description"), "01:00:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsNotificationInterval3Description"), "01:30:00");
yield return new SelectValue(new("Constructor_FormSectionSetSettingsNotificationInterval4Description"), "02:00:00");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
? "nav-stages__item_can-move"
: string.Empty;

private string GetStageTitle(Stage stage) => $"Constructor_Stage{stage}";
private MessageId GetStageTitle(Stage stage) => new($"Constructor_Stage{stage}");

private void MoveTo(Stage stage)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Inc.TeamAssistant.Primitives.Languages;
using Inc.TeamAssistant.WebUI.Services.ClientCore;

namespace Inc.TeamAssistant.WebUI.Features.Constructor.Stages.Stage2;
Expand All @@ -17,7 +18,7 @@ public FeaturesFactory(ResourcesManager resources)

private string Create(string featureName, string propertyName)
{
var key = $"Constructor_Feature{featureName}{propertyName}";
var key = new MessageId($"Constructor_Feature{featureName}{propertyName}");

return _resources[key];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
StateHasChanged();
}

private string GetDayOfWeekTitle(DayOfWeek dayOfWeek) => $"Constructor_DayOfWeek{dayOfWeek}";
private MessageId GetDayOfWeekTitle(DayOfWeek dayOfWeek) => new($"Constructor_DayOfWeek{dayOfWeek}");

public async Task SubmitForm()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@using Inc.TeamAssistant.Primitives.Languages

@inject IServiceProvider ServiceProvider
@inject ResourcesManager Resources

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@using Inc.TeamAssistant.Primitives.FeatureProperties
@using Inc.TeamAssistant.Primitives.Languages

@inject IBotService BotService
@inject IServiceProvider ServiceProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{
const bool external = true;

var links = new (string Key, FooterLink Value)[]
var links = new (MessageId Key, FooterLink Value)[]
{
(Messages.Footer_GroupNavigation, new FooterLink(
Resources[Messages.Footer_LinkMain],
Expand Down
2 changes: 1 addition & 1 deletion src/Inc.TeamAssistant.WebUI/Features/Meta/MetaData.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[Parameter, EditorRequired]
public WebsiteSection WebsiteSection { get; set; }

private (string Description, string Keywords, bool Indexed) _data = default!;
private (MessageId Description, MessageId Keywords, bool Indexed) _data = default!;

protected override void OnParametersSet() => Load();

Expand Down
2 changes: 1 addition & 1 deletion src/Inc.TeamAssistant.WebUI/Features/Meta/OpenGraph.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public WebsiteSection WebsiteSection { get; set; }

private string _languageId = string.Empty;
private (string Title, string Description, string Image, string ImageText) _data = default;
private (MessageId Title, MessageId Description, string Image, MessageId ImageText) _data = default;

protected override void OnParametersSet() => Load();

Expand Down
1 change: 1 addition & 0 deletions src/Inc.TeamAssistant.WebUI/Features/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@using Microsoft.AspNetCore.Components.QuickGrid
@using ApexCharts

@using Inc.TeamAssistant.Primitives.Languages
@using Inc.TeamAssistant.WebUI.Contracts
@using Inc.TeamAssistant.WebUI.Features.Layouts
@using Inc.TeamAssistant.WebUI.Features.Meta
Expand Down
Loading

0 comments on commit 9fb9701

Please sign in to comment.