Skip to content

Commit 317bb89

Browse files
authored
Simplify and clarify Platform Install experience on SCMU - v2 (#5837)
* SCMU add instance UI changes * add some tests * some code cleanup * remove unused name * remove more of unused code * cleaner code * Update UI * cleanup * add test for setup mode * supress warning * fix test
1 parent b79dc91 commit 317bb89

14 files changed

Lines changed: 541 additions & 260 deletions

‎src/ServiceControl.Config.Tests/ServiceControlAddScreenLoadedTests.cs‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using System;
44
using System.ComponentModel;
5+
using System.Linq;
56
using NUnit.Framework;
67
using ServiceControlInstaller.Engine.Configuration.ServiceControl;
78
using UI.InstanceAdd;
@@ -277,5 +278,86 @@ public void Full_text_search_on_bodies_is_enabled()
277278
Assert.That(viewModel.AuditEnableFullTextSearchOnBodies.Value, Is.EqualTo(true));
278279
}
279280
}
281+
282+
[Test]
283+
public void Instance_sections_are_expanded_by_default()
284+
{
285+
var viewModel = new ServiceControlAddViewModel();
286+
287+
using (Assert.EnterMultipleScope())
288+
{
289+
Assert.That(viewModel.IsServiceControlExpanded, Is.True);
290+
Assert.That(viewModel.IsServiceControlAuditExpanded, Is.True);
291+
}
292+
}
293+
294+
[Test]
295+
public void Integrated_ServicePulse_is_enabled_by_default()
296+
{
297+
var viewModel = new ServiceControlAddViewModel();
298+
299+
using (Assert.EnterMultipleScope())
300+
{
301+
Assert.That(viewModel.ErrorEnableIntegratedServicePulseOptions, Is.Not.Empty);
302+
Assert.That(viewModel.ErrorEnableIntegratedServicePulse.Value, Is.True);
303+
}
304+
}
305+
306+
[Test]
307+
public void Integrated_ServicePulse_can_be_disabled()
308+
{
309+
var viewModel = new ServiceControlAddViewModel();
310+
311+
var offOption = viewModel.ErrorEnableIntegratedServicePulseOptions.First(o => !o.Value);
312+
viewModel.ServiceControl.EnableIntegratedServicePulse = offOption;
313+
314+
Assert.That(viewModel.ErrorEnableIntegratedServicePulse.Value, Is.False);
315+
}
316+
317+
[Test]
318+
public void Audit_only_configuration_has_no_validation_errors_for_error_fields()
319+
{
320+
var viewModel = new ServiceControlAddViewModel(() => [])
321+
{
322+
InstallErrorInstance = false,
323+
InstallAuditInstance = true,
324+
SubmitAttempted = true
325+
};
326+
327+
var notifyErrorInfo = (INotifyDataErrorInfo)viewModel;
328+
329+
using (Assert.EnterMultipleScope())
330+
{
331+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorInstanceName)), Is.Empty);
332+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorHostName)), Is.Empty);
333+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorPortNumber)), Is.Empty);
334+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorDestinationPath)), Is.Empty);
335+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorLogPath)), Is.Empty);
336+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorDatabasePath)), Is.Empty);
337+
}
338+
}
339+
340+
[Test]
341+
public void Error_only_configuration_has_no_validation_errors_for_audit_fields()
342+
{
343+
var viewModel = new ServiceControlAddViewModel(() => [])
344+
{
345+
InstallErrorInstance = true,
346+
InstallAuditInstance = false,
347+
SubmitAttempted = true
348+
};
349+
350+
var notifyErrorInfo = (INotifyDataErrorInfo)viewModel;
351+
352+
using (Assert.EnterMultipleScope())
353+
{
354+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditInstanceName)), Is.Empty);
355+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditHostName)), Is.Empty);
356+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditPortNumber)), Is.Empty);
357+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditDestinationPath)), Is.Empty);
358+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditLogPath)), Is.Empty);
359+
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditDatabasePath)), Is.Empty);
360+
}
361+
}
280362
}
281363
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
namespace ServiceControl.Config.Tests
2+
{
3+
using NUnit.Framework;
4+
using UI.Shell;
5+
6+
[TestFixture]
7+
class SetupModeTests
8+
{
9+
[TestCase(SetupMode.ErrorHandling, true, false, false)]
10+
[TestCase(SetupMode.ErrorAndAudit, true, true, false)]
11+
[TestCase(SetupMode.AuditOnly, false, true, false)]
12+
[TestCase(SetupMode.MonitoringOnly, false, false, true)]
13+
public void Scenario_selects_the_instances_to_install(SetupMode mode, bool serviceControl, bool audit, bool monitoring)
14+
{
15+
using (Assert.EnterMultipleScope())
16+
{
17+
Assert.That(mode.InstallsServiceControl(), Is.EqualTo(serviceControl));
18+
Assert.That(mode.InstallsAudit(), Is.EqualTo(audit));
19+
Assert.That(mode.InstallsMonitoring(), Is.EqualTo(monitoring));
20+
}
21+
}
22+
23+
[TestCase(SetupMode.ErrorHandling)]
24+
[TestCase(SetupMode.ErrorAndAudit)]
25+
[TestCase(SetupMode.AuditOnly)]
26+
[TestCase(SetupMode.MonitoringOnly)]
27+
public void Every_scenario_installs_at_least_one_instance(SetupMode mode)
28+
{
29+
// The Next button is always enabled, so no scenario may resolve to nothing.
30+
Assert.That(mode.InstallsServiceControl() || mode.InstallsAudit() || mode.InstallsMonitoring(), Is.True);
31+
}
32+
33+
[TestCase(SetupMode.ErrorHandling)]
34+
[TestCase(SetupMode.ErrorAndAudit)]
35+
public void Integrated_ServicePulse_follows_the_choice_when_an_error_instance_is_installed(SetupMode mode)
36+
{
37+
using (Assert.EnterMultipleScope())
38+
{
39+
Assert.That(mode.InstallsServicePulse(wanted: true), Is.True);
40+
Assert.That(mode.InstallsServicePulse(wanted: false), Is.False);
41+
}
42+
}
43+
44+
[TestCase(SetupMode.AuditOnly)]
45+
[TestCase(SetupMode.MonitoringOnly)]
46+
public void Integrated_ServicePulse_is_never_installed_without_an_error_instance(SetupMode mode)
47+
{
48+
Assert.That(mode.InstallsServicePulse(wanted: true), Is.False);
49+
}
50+
}
51+
}

‎src/ServiceControl.Config/Commands/AddServiceControlInstanceCommand.cs‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
namespace ServiceControl.Config.Commands
1+
namespace ServiceControl.Config.Commands
22
{
33
using System;
4+
using System.Linq;
5+
using System.Threading;
46
using System.Threading.Tasks;
57
using Framework;
68
using Framework.Commands;
@@ -18,17 +20,32 @@ public AddServiceControlInstanceCommand(IServiceControlWindowManager windowManag
1820

1921
public override async Task ExecuteAsync(object obj)
2022
{
21-
if (!await commandChecks.CanAddInstance(true))
23+
await ExecuteWithOptions(installError: true, installAudit: true, installServicePulse: true);
24+
}
25+
26+
public async Task ExecuteWithOptions(bool installError, bool installAudit, bool installServicePulse, CancellationToken cancellationToken = default)
27+
{
28+
if (!await commandChecks.CanAddInstance(true, cancellationToken))
2229
{
2330
return;
2431
}
2532

2633
var instanceViewModel = addInstance();
27-
await windowManager.ShowInnerDialog(instanceViewModel);
34+
instanceViewModel.InstallErrorInstance = installError;
35+
instanceViewModel.InstallAuditInstance = installAudit;
36+
37+
if (installError)
38+
{
39+
// The options list always carries both an On and an Off entry.
40+
instanceViewModel.ServiceControl.EnableIntegratedServicePulse = instanceViewModel.ServiceControl
41+
.EnableIntegratedServicePulseOptions.First(o => o.Value == installServicePulse);
42+
}
43+
44+
await windowManager.ShowInnerDialog(instanceViewModel, cancellationToken: cancellationToken);
2845
}
2946

3047
readonly Func<ServiceControlAddViewModel> addInstance;
3148
readonly IServiceControlWindowManager windowManager;
3249
readonly ScmuCommandChecks commandChecks;
3350
}
34-
}
51+
}

‎src/ServiceControl.Config/UI/AdvancedOptions/ServiceControlAdvancedView.xaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@
4646
Visibility="{Binding InMaintenanceMode, Converter={StaticResource boolToVisInverted}}"
4747
Margin="0,0,0,20"
4848
>
49-
Enter database maintenance mode to access to RavenDB Management Studio. While in this mode all message processing is disabled and the REST API is unavailable. This will prevent ServicePulse and ServiceInsight connecting to this instance.
49+
Enter database maintenance mode to access to RavenDB Management Studio. While in this mode all message processing is disabled and the REST API is unavailable. This will prevent ServicePulse connecting to this instance.
5050
</TextBlock>
5151

5252
<TextBlock FontSize="12px"
5353
TextWrapping="Wrap"
5454
Visibility="{Binding InMaintenanceMode, Converter={StaticResource boolToVis}}"
5555
Margin="0,0,0,20"
5656
>
57-
This instance is in database maintenance mode. All message processing is disabled and the REST API is unavailable.<LineBreak />ServicePulse and ServiceInsight cannot connect to this instance while it is in maintenance mode.<LineBreak />Launch <Hyperlink Command="{Binding OpenUrl}" CommandParameter="{Binding RavenDbStudioUrl}">
57+
This instance is in database maintenance mode. All message processing is disabled and the REST API is unavailable.<LineBreak />ServicePulse cannot connect to this instance while it is in maintenance mode.<LineBreak />Launch <Hyperlink Command="{Binding OpenUrl}" CommandParameter="{Binding RavenDbStudioUrl}">
5858
RavenDB Management Studio
5959
<Hyperlink.ContextMenu>
6060
<ContextMenu>

‎src/ServiceControl.Config/UI/InstanceAdd/ServiceControlAddView.xaml‎

Lines changed: 18 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,14 @@
7373
Converter={StaticResource boolToVis}}" />
7474
</StackPanel>
7575

76-
<TextBlock Padding="0, 0, 0, 10" Visibility="{Binding OneInstanceTypeSelected, Converter={StaticResource boolToVisInverted}}"
77-
FontSize="13px"
78-
Foreground="{StaticResource ErrorBrush}"
79-
Text="Must select either an audit or an error instance." />
80-
81-
<StackPanel>
82-
<!-- Horizontal layout: CheckBox + Expander side by side -->
83-
<Grid>
84-
<Grid.ColumnDefinitions>
85-
<ColumnDefinition Width="Auto"/>
86-
<ColumnDefinition Width="*"/>
87-
</Grid.ColumnDefinitions>
88-
89-
<CheckBox Grid.Column="0"
90-
Padding="0, 0, 0, 0"
91-
IsChecked="{Binding InstallErrorInstance}"
92-
VerticalAlignment="Top"
93-
Margin="0,8,8,5"/>
94-
95-
<Expander Grid.Column="1"
96-
Header="ServiceControl"
97-
IsExpanded="{Binding IsServiceControlExpanded}"
98-
IsEnabled="{Binding InstallErrorInstance}"
99-
Margin="0,5,0,5"
100-
MouseDown="Button_MouseDown"
101-
PreviewMouseDown="Button_MouseDown"
102-
PreviewMouseLeftButtonDown="Button_MouseDown">
103-
<StackPanel Margin="60,0,60,0" Visibility="{Binding InstallErrorInstance, Converter={StaticResource boolToVis}}">
76+
<StackPanel Visibility="{Binding InstallErrorInstance, Converter={StaticResource boolToVis}}">
77+
<Expander Header="ServiceControl"
78+
IsExpanded="{Binding IsServiceControlExpanded}"
79+
Margin="0,5,0,5"
80+
MouseDown="Button_MouseDown"
81+
PreviewMouseDown="Button_MouseDown"
82+
PreviewMouseLeftButtonDown="Button_MouseDown">
83+
<StackPanel Margin="60,0,60,0">
10484
<Border Margin="0,40,0,20"
10585
BorderBrush="{StaticResource Gray70Brush}"
10686
BorderThickness="0,0,0,1">
@@ -261,34 +241,17 @@
261241
ItemsSource="{Binding ErrorEnableIntegratedServicePulseOptions}"
262242
SelectedValue="{Binding ErrorEnableIntegratedServicePulse}" />
263243
</StackPanel>
264-
</Expander>
265-
</Grid>
244+
</Expander>
266245
</StackPanel>
267246

268-
<StackPanel>
269-
<!-- Horizontal layout: CheckBox + Expander side by side -->
270-
<Grid>
271-
<Grid.ColumnDefinitions>
272-
<ColumnDefinition Width="Auto"/>
273-
<ColumnDefinition Width="*"/>
274-
</Grid.ColumnDefinitions>
275-
276-
<CheckBox Grid.Column="0"
277-
Padding="0, 0, 0, 0"
278-
IsChecked="{Binding InstallAuditInstance}"
279-
IsThreeState="False"
280-
VerticalAlignment="Top"
281-
Margin="0,8,8,5"/>
282-
283-
<Expander Grid.Column="1"
284-
Header="ServiceControl Audit"
285-
IsExpanded="{Binding IsServiceControlAuditExpanded}"
286-
IsEnabled="{Binding InstallAuditInstance}"
287-
Margin="0,5,0,5"
288-
MouseDown="Button_MouseDown"
289-
PreviewMouseDown="Button_MouseDown"
290-
PreviewMouseLeftButtonDown="Button_MouseDown">
291-
<StackPanel Margin="60,0,60,0" Visibility="{Binding InstallAuditInstance, Converter={StaticResource boolToVis}}">
247+
<StackPanel Visibility="{Binding InstallAuditInstance, Converter={StaticResource boolToVis}}">
248+
<Expander Header="ServiceControl Audit"
249+
IsExpanded="{Binding IsServiceControlAuditExpanded}"
250+
Margin="0,5,0,5"
251+
MouseDown="Button_MouseDown"
252+
PreviewMouseDown="Button_MouseDown"
253+
PreviewMouseLeftButtonDown="Button_MouseDown">
254+
<StackPanel Margin="60,0,60,0">
292255
<Border Margin="0,40,0,20"
293256
BorderBrush="{StaticResource Gray70Brush}"
294257
BorderThickness="0,0,0,1">
@@ -458,8 +421,7 @@
458421
ItemsSource="{Binding AuditEnableFullTextSearchOnBodiesOptions}"
459422
SelectedValue="{Binding AuditEnableFullTextSearchOnBodies}" />
460423
</StackPanel>
461-
</Expander>
462-
</Grid>
424+
</Expander>
463425
</StackPanel>
464426
</StackPanel>
465427
</sie:SharedServiceControlEditorView.SharedContent>

‎src/ServiceControl.Config/UI/InstanceAdd/ServiceControlAddViewModel.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ public string AuditDatabasePath
396396

397397
public TimeSpanUnits AuditRetentionUnits => ServiceControlAudit.AuditRetentionUnits;
398398

399-
public bool IsServiceControlExpanded { get; set; }
399+
public bool IsServiceControlExpanded { get; set; } = true;
400400

401-
public bool IsServiceControlAuditExpanded { get; set; }
401+
public bool IsServiceControlAuditExpanded { get; set; } = true;
402402

403403
public double AuditRetention
404404
{

‎src/ServiceControl.Config/UI/InstanceAdd/ServiceControlEditorViewModel.cs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public virtual void OnSelectedTransportChanged()
3636
// Needs to exist in base class for Fody to call it so it can be executed in superclass
3737
}
3838

39-
public bool OneInstanceTypeSelected => InstallErrorInstance || InstallAuditInstance;
40-
4139
public string TransportWarning => SelectedTransport?.Help;
4240

4341
public string ConnectionString { get; set; }
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<UserControl x:Class="ServiceControl.Config.UI.NoInstances.NoInstancesView"
1+
<UserControl x:Class="ServiceControl.Config.UI.NoInstances.NoInstancesView"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -7,26 +7,11 @@
77
d:DesignWidth="600"
88
mc:Ignorable="d">
99
<Grid>
10-
<Grid.RowDefinitions>
11-
<RowDefinition Height="*" />
12-
<RowDefinition Height="*" />
13-
</Grid.RowDefinitions>
14-
1510
<TextBlock Margin="10"
1611
HorizontalAlignment="Center"
17-
VerticalAlignment="Bottom"
12+
VerticalAlignment="Center"
1813
FontSize="20"
1914
Foreground="{StaticResource Gray60Brush}"
2015
Text="No service instances installed" />
21-
22-
<Button Grid.Row="1"
23-
Margin="10"
24-
HorizontalAlignment="Center"
25-
VerticalAlignment="Top"
26-
Command="{Binding AddInstance}"
27-
Content="Add new instance"
28-
Style="{StaticResource HiliteButton}"
29-
Visibility="{Binding ShowMonitoringInstances,
30-
Converter={StaticResource boolToVisInverted}}" />
3116
</Grid>
32-
</UserControl>
17+
</UserControl>
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
namespace ServiceControl.Config.UI.NoInstances
1+
namespace ServiceControl.Config.UI.NoInstances
22
{
3-
using System.Windows.Input;
4-
using Commands;
53
using Framework.Rx;
64

75
class NoInstancesViewModel : RxScreen
86
{
9-
public NoInstancesViewModel(AddServiceControlInstanceCommand addInstance)
7+
public NoInstancesViewModel()
108
{
119
DisplayName = "DEPLOYED INSTANCES";
12-
13-
AddInstance = addInstance;
1410
}
15-
16-
public ICommand AddInstance { get; }
17-
18-
[FeatureToggle(Feature.MonitoringInstances)]
19-
public bool ShowMonitoringInstances { get; set; }
2011
}
21-
}
12+
}

0 commit comments

Comments
 (0)