diff --git a/src/RepoM.App/MainWindow.xaml b/src/RepoM.App/MainWindow.xaml
index 475c9392..7a023b39 100644
--- a/src/RepoM.App/MainWindow.xaml
+++ b/src/RepoM.App/MainWindow.xaml
@@ -9,6 +9,7 @@
xmlns:converters="clr-namespace:RepoM.App.Converters"
xmlns:controls="clr-namespace:RepoM.App.Controls"
xmlns:app="clr-namespace:RepoM.App"
+ xmlns:viewModels="clr-namespace:RepoM.App.ViewModels"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="12"
@@ -22,7 +23,8 @@
fw:AcrylicWindow.TintColor="#101010"
fw:AcrylicWindow.FallbackColor="#303030"
fw:AcrylicWindow.TintOpacity="0.7"
- fw:AcrylicWindow.Enabled="True">
+ fw:AcrylicWindow.Enabled="True"
+ d:DataContext="{d:DesignInstance viewModels:MainWindowViewModel}">
@@ -385,14 +387,14 @@
-
-
-
+
+
+
diff --git a/src/RepoM.App/MainWindow.xaml.cs b/src/RepoM.App/MainWindow.xaml.cs
index ec4279d2..023b484f 100644
--- a/src/RepoM.App/MainWindow.xaml.cs
+++ b/src/RepoM.App/MainWindow.xaml.cs
@@ -88,7 +88,13 @@ public MainWindow(
var filterViewModel = new FiltersViewModel(_repositoryFilteringManager, threadDispatcher);
var pluginsViewModel = new PluginCollectionViewModel(moduleManager);
- DataContext = new MainWindowViewModel(appSettingsService, orderingsViewModel, queryParsersViewModel, filterViewModel, pluginsViewModel);
+ DataContext = new MainWindowViewModel(
+ appSettingsService,
+ orderingsViewModel,
+ queryParsersViewModel,
+ filterViewModel,
+ pluginsViewModel,
+ new HelpViewModel(_translationService));
SettingsMenu.DataContext = DataContext; // this is out of the visual tree
_monitor = repositoryMonitor as DefaultRepositoryMonitor;
@@ -108,10 +114,6 @@ public MainWindow(
repositoryFilteringManager.SelectedQueryParserChanged += (_, _) => view.Refresh();
repositoryFilteringManager.SelectedFilterChanged += (_, _) => view.Refresh();
- AssemblyName? appName = Assembly.GetEntryAssembly()?.GetName();
- txtHelpCaption.Text = appName?.Name + " " + appName?.Version?.ToString(2);
- txtHelp.Text = GetHelp();
-
PlaceFormByTaskBarLocation();
}
@@ -861,19 +863,5 @@ private void TxtFilter_Finish(object sender, EventArgs e)
item?.Focus();
}
- private string GetHelp()
- {
- return _translationService.Translate(
- "Help Detail",
- StatusCharacterMap.IDENTICAL_SIGN,
- StatusCharacterMap.STASH_SIGN,
- StatusCharacterMap.IDENTICAL_SIGN,
- StatusCharacterMap.ARROW_UP_SIGN,
- StatusCharacterMap.ARROW_DOWN_SIGN,
- StatusCharacterMap.NO_UPSTREAM_SIGN,
- StatusCharacterMap.STASH_SIGN
- );
- }
-
public bool IsShown => Visibility == Visibility.Visible && IsActive;
}
\ No newline at end of file
diff --git a/src/RepoM.App/ViewModels/HelpViewModel.cs b/src/RepoM.App/ViewModels/HelpViewModel.cs
new file mode 100644
index 00000000..ce82d0de
--- /dev/null
+++ b/src/RepoM.App/ViewModels/HelpViewModel.cs
@@ -0,0 +1,41 @@
+namespace RepoM.App.ViewModels;
+
+using System;
+using System.Reflection;
+using JetBrains.Annotations;
+using RepoM.Api.Common;
+using RepoM.Api.Git;
+
+public class HelpViewModel
+{
+ public HelpViewModel(ITranslationService translationService)
+ {
+ ArgumentNullException.ThrowIfNull(translationService);
+ Header = GetHeader();
+ Description = GetHelp(translationService);
+ }
+
+ public string Header { [UsedImplicitly] get; }
+
+ public string Description { [UsedImplicitly] get; }
+
+ private static string GetHeader()
+ {
+ AssemblyName? appName = Assembly.GetEntryAssembly()?.GetName();
+ return appName?.Name + ' ' + appName?.Version?.ToString(2).Trim();
+ }
+
+ private static string GetHelp(ITranslationService translationService)
+ {
+ return translationService.Translate(
+ "Help Detail",
+ StatusCharacterMap.IDENTICAL_SIGN,
+ StatusCharacterMap.STASH_SIGN,
+ StatusCharacterMap.IDENTICAL_SIGN,
+ StatusCharacterMap.ARROW_UP_SIGN,
+ StatusCharacterMap.ARROW_DOWN_SIGN,
+ StatusCharacterMap.NO_UPSTREAM_SIGN,
+ StatusCharacterMap.STASH_SIGN
+ );
+ }
+}
\ No newline at end of file
diff --git a/src/RepoM.App/ViewModels/MainWindowViewModel.cs b/src/RepoM.App/ViewModels/MainWindowViewModel.cs
index a370e03b..3810d06c 100644
--- a/src/RepoM.App/ViewModels/MainWindowViewModel.cs
+++ b/src/RepoM.App/ViewModels/MainWindowViewModel.cs
@@ -16,13 +16,15 @@ public MainWindowViewModel(
OrderingsViewModel orderingsViewModel,
QueryParsersViewModel queryParsersViewModel,
FiltersViewModel filtersViewModel,
- PluginCollectionViewModel pluginsViewModel)
+ PluginCollectionViewModel pluginsViewModel,
+ HelpViewModel helpViewModel)
{
_appSettingsService = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService));
Orderings = orderingsViewModel ?? throw new ArgumentNullException(nameof(orderingsViewModel));
QueryParsers = queryParsersViewModel ?? throw new ArgumentNullException(nameof(queryParsersViewModel));
Filters = filtersViewModel ?? throw new ArgumentNullException(nameof(filtersViewModel));
Plugins = pluginsViewModel ?? throw new ArgumentNullException(nameof(pluginsViewModel));
+ Help = helpViewModel ?? throw new ArgumentNullException(nameof(helpViewModel));
}
private AutoFetchMode AutoFetchMode
@@ -48,6 +50,8 @@ private AutoFetchMode AutoFetchMode
public PluginCollectionViewModel Plugins { [UsedImplicitly] get; }
+ public HelpViewModel Help { [UsedImplicitly] get; }
+
public bool AutoFetchOff
{
get => AutoFetchMode == AutoFetchMode.Off;
diff --git a/tests/RepoM.ActionMenu.Core.Tests/Plugin/PluginTests.cs b/tests/RepoM.ActionMenu.Core.Tests/Plugin/PluginTests.cs
index e8ddecec..69dbd23f 100644
--- a/tests/RepoM.ActionMenu.Core.Tests/Plugin/PluginTests.cs
+++ b/tests/RepoM.ActionMenu.Core.Tests/Plugin/PluginTests.cs
@@ -69,13 +69,13 @@ public PluginTests()
new()
{
Host = "h1",
- DatabaseNames = new [] {"x1", "x2", },
+ DatabaseNames = ["x1", "x2",],
Key = "k1",
},
new()
{
Host = "h2",
- DatabaseNames = new [] {"x21", "x22", },
+ DatabaseNames = ["x21", "x22",],
Key = "k2",
},
};
diff --git a/tests/RepoM.App.Tests/ViewModels/MainWindowViewModelTests.cs b/tests/RepoM.App.Tests/ViewModels/MainWindowViewModelTests.cs
index 344604ad..417e172a 100644
--- a/tests/RepoM.App.Tests/ViewModels/MainWindowViewModelTests.cs
+++ b/tests/RepoM.App.Tests/ViewModels/MainWindowViewModelTests.cs
@@ -17,6 +17,7 @@ public class MainWindowViewModelTests
private readonly QueryParsersViewModel _queryParsersViewModel;
private readonly FiltersViewModel _filtersViewModel;
private readonly PluginCollectionViewModel _pluginsViewModel;
+ private readonly HelpViewModel _helpViewModel;
public MainWindowViewModelTests()
{
@@ -30,6 +31,7 @@ public MainWindowViewModelTests()
_queryParsersViewModel = new QueryParsersViewModel(repositoryFilterManager, threadDispatcher);
_filtersViewModel = new FiltersViewModel(repositoryFilterManager, threadDispatcher);
_pluginsViewModel = new PluginCollectionViewModel(moduleManager);
+ _helpViewModel = new HelpViewModel(A.Fake());
}
[Fact]
@@ -38,11 +40,12 @@ public void Ctor_ShouldThrown_WhenArgumentIsNull()
// arrange
// act
- Action act1 = () => _ = new MainWindowViewModel(_appSettingsService, _orderingsViewModel, _queryParsersViewModel, _filtersViewModel, null!);
- Action act2 = () => _ = new MainWindowViewModel(_appSettingsService, _orderingsViewModel, _queryParsersViewModel, null!, _pluginsViewModel);
- Action act3 = () => _ = new MainWindowViewModel(_appSettingsService, _orderingsViewModel, null!, _filtersViewModel, _pluginsViewModel);
- Action act4 = () => _ = new MainWindowViewModel(_appSettingsService, null!, _queryParsersViewModel, _filtersViewModel, _pluginsViewModel);
- Action act5 = () => _ = new MainWindowViewModel(null!, _orderingsViewModel, _queryParsersViewModel, _filtersViewModel, _pluginsViewModel);
+ Action act1 = () => _ = new MainWindowViewModel(_appSettingsService, _orderingsViewModel, _queryParsersViewModel, _filtersViewModel, null!, _helpViewModel);
+ Action act2 = () => _ = new MainWindowViewModel(_appSettingsService, _orderingsViewModel, _queryParsersViewModel, null!, _pluginsViewModel, _helpViewModel);
+ Action act3 = () => _ = new MainWindowViewModel(_appSettingsService, _orderingsViewModel, null!, _filtersViewModel, _pluginsViewModel, _helpViewModel);
+ Action act4 = () => _ = new MainWindowViewModel(_appSettingsService, null!, _queryParsersViewModel, _filtersViewModel, _pluginsViewModel, _helpViewModel);
+ Action act5 = () => _ = new MainWindowViewModel(null!, _orderingsViewModel, _queryParsersViewModel, _filtersViewModel, _pluginsViewModel, _helpViewModel);
+ Action act6 = () => _ = new MainWindowViewModel(_appSettingsService, _orderingsViewModel, _queryParsersViewModel, _filtersViewModel, _pluginsViewModel, null!);
// assert
act1.Should().ThrowExactly();
@@ -50,6 +53,7 @@ public void Ctor_ShouldThrown_WhenArgumentIsNull()
act3.Should().ThrowExactly();
act4.Should().ThrowExactly();
act5.Should().ThrowExactly();
+ act6.Should().ThrowExactly();
}
[Fact]
@@ -58,7 +62,7 @@ public void Ctor_ShouldInitializeProperties()
// arrange
// act
- var sut = new MainWindowViewModel(_appSettingsService, _orderingsViewModel, _queryParsersViewModel, _filtersViewModel, _pluginsViewModel);
+ var sut = new MainWindowViewModel(_appSettingsService, _orderingsViewModel, _queryParsersViewModel, _filtersViewModel, _pluginsViewModel, _helpViewModel);
// assert
sut.QueryParsers.Should().BeSameAs(_queryParsersViewModel);