Skip to content

Commit 79cea90

Browse files
authored
Merge pull request #5548 from retailcoder/weblink
Introduces a link to the website's inspection details page for the selected inspection result, at the bottom of the bottom panel in the inspection results toolwindow.
2 parents 60055fc + 97475d1 commit 79cea90

File tree

6 files changed

+53
-11
lines changed

6 files changed

+53
-11
lines changed

Rubberduck.Core/UI/About/AboutControlViewModel.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ namespace Rubberduck.UI.About
1313
public class AboutControlViewModel
1414
{
1515
private readonly IVersionCheck _version;
16+
private readonly IWebNavigator _web;
1617

17-
public AboutControlViewModel(IVersionCheck version)
18+
public AboutControlViewModel(IVersionCheck version, IWebNavigator web)
1819
{
1920
_version = version;
21+
_web = web;
2022

2123
UriCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteUri);
2224
ViewLogCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteViewLog);
@@ -42,10 +44,7 @@ public AboutControlViewModel(IVersionCheck version)
4244

4345
public CommandBase ViewLogCommand { get; }
4446

45-
private void ExecuteUri(object parameter)
46-
{
47-
Process.Start(new ProcessStartInfo(((Uri)parameter).AbsoluteUri));
48-
}
47+
private void ExecuteUri(object parameter) => _web.Navigate(((Uri)parameter));
4948

5049
private void ExecuteViewLog(object parameter)
5150
{

Rubberduck.Core/UI/About/AboutDialog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ namespace Rubberduck.UI.About
55
{
66
public partial class AboutDialog : Form
77
{
8-
public AboutDialog(IVersionCheck versionCheck) : this()
8+
public AboutDialog(IVersionCheck versionCheck, IWebNavigator web) : this()
99
{
10-
ViewModel = new AboutControlViewModel(versionCheck);
10+
ViewModel = new AboutControlViewModel(versionCheck, web);
1111
}
1212

1313
public AboutDialog()

Rubberduck.Core/UI/Command/AboutCommand.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ namespace Rubberduck.UI.Command
1010
[ComVisible(false)]
1111
public class AboutCommand : CommandBase
1212
{
13-
public AboutCommand(IVersionCheck versionService)
13+
public AboutCommand(IVersionCheck versionService, IWebNavigator web)
1414
{
1515
_versionService = versionService;
16+
_web = web;
1617
}
1718

1819
private readonly IVersionCheck _versionService;
20+
private readonly IWebNavigator _web;
1921

2022
protected override void OnExecute(object parameter)
2123
{
22-
using (var window = new AboutDialog(_versionService))
24+
using (var window = new AboutDialog(_versionService, _web))
2325
{
2426
window.ShowDialog();
2527
}

Rubberduck.Core/UI/Inspections/InspectionResultsControl.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@
278278
Visibility="{Binding CanDisableInspection, Converter={StaticResource BoolToVisibility}}"
279279
Command="{Binding DisableInspectionCommand}"
280280
Content="{Resx ResxName=Rubberduck.Resources.Inspections.InspectionsUI, Key=DisableThisInspection}" />
281+
282+
<controls:LinkButton Margin="4"
283+
Command="{Binding OpenInspectionDetailsPageCommand}"
284+
Content="{Binding InspectionDetailsUrl}" />
285+
281286
</StackPanel>
282287
</ScrollViewer>
283288
</Border>

Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public QuickFixCommandViewModel(
8989

9090
public sealed class InspectionResultsViewModel : ViewModelBase, INavigateSelection, IComparer<IInspectionResult>, IComparer, IDisposable
9191
{
92+
private readonly IWebNavigator _web;
9293
private readonly RubberduckParserState _state;
9394
private readonly IInspector _inspector;
9495
private readonly IQuickFixProvider _quickFixProvider;
@@ -106,10 +107,12 @@ public InspectionResultsViewModel(
106107
INavigateCommand navigateCommand,
107108
ReparseCommand reparseCommand,
108109
IClipboardWriter clipboard,
110+
IWebNavigator web,
109111
IConfigurationService<Configuration> configService,
110112
ISettingsFormFactory settingsFormFactory,
111113
IUiDispatcher uiDispatcher)
112114
{
115+
_web = web;
113116
_state = state;
114117
_inspector = inspector;
115118
_quickFixProvider = quickFixProvider;
@@ -144,6 +147,8 @@ public InspectionResultsViewModel(
144147
OpenInspectionSettings = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);
145148
CollapseAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseAll);
146149
ExpandAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAll);
150+
151+
OpenInspectionDetailsPageCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteOpenInspectionDetailsPageCommand);
147152

148153
QuickFixCommands = new List<(ICommand command, string key, Func<IQuickFix, bool> visibility)>
149154
{
@@ -195,6 +200,8 @@ public INavigateSource SelectedItem
195200
get => _selectedItem;
196201
set
197202
{
203+
SelectedInspection = null;
204+
CanQuickFix = false;
198205
if (value == _selectedItem)
199206
{
200207
return;
@@ -203,8 +210,6 @@ public INavigateSource SelectedItem
203210
_selectedItem = value;
204211
OnPropertyChanged();
205212
OnPropertyChanged(nameof(QuickFixes));
206-
SelectedInspection = null;
207-
CanQuickFix = false;
208213

209214
if (_selectedItem is IInspectionResult inspectionResult)
210215
{
@@ -225,6 +230,7 @@ public IInspection SelectedInspection
225230
{
226231
_selectedInspection = value;
227232
OnPropertyChanged();
233+
OnPropertyChanged(nameof(InspectionDetailsUrl));
228234
}
229235
}
230236

@@ -354,6 +360,7 @@ private bool InspectionFilter(IInspectionResult result)
354360
public CommandBase OpenInspectionSettings { get; }
355361
public CommandBase CollapseAllCommand { get; }
356362
public CommandBase ExpandAllCommand { get; }
363+
public CommandBase OpenInspectionDetailsPageCommand { get; }
357364

358365
private void ExecuteCollapseAll(object parameter)
359366
{
@@ -767,6 +774,14 @@ public bool CanDisableInspection
767774
}
768775
}
769776

777+
private static readonly Uri _inspectionsHomeUrl = new Uri("https://rubberduckvba.com/inspections");
778+
779+
public Uri InspectionDetailsUrl => _selectedInspection == null
780+
? _inspectionsHomeUrl
781+
: new Uri($"https://rubberduckvba.com/inspections/details/{_selectedInspection.AnnotationName}");
782+
783+
private void ExecuteOpenInspectionDetailsPageCommand(object parameter) => _web.Navigate(InspectionDetailsUrl);
784+
770785
private static readonly List<(string Name, hAlignment alignment)> ResultColumns = new List<(string Name, hAlignment alignment)>
771786
{
772787
(Resources.Inspections.InspectionsUI.ExportColumnHeader_Type, hAlignment.Left),

Rubberduck.Core/UI/WebNavigator.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Diagnostics;
3+
4+
namespace Rubberduck.UI
5+
{
6+
public interface IWebNavigator
7+
{
8+
/// <summary>
9+
/// Opens the specified URI in the default browser.
10+
/// </summary>
11+
void Navigate(Uri uri);
12+
}
13+
14+
public class WebNavigator : IWebNavigator
15+
{
16+
public void Navigate(Uri uri)
17+
{
18+
Process.Start(new ProcessStartInfo(uri.AbsoluteUri));
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)