Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.ComponentModel;
using System.Linq;
using NUnit.Framework;
using ServiceControlInstaller.Engine.Configuration.ServiceControl;
using UI.InstanceAdd;
Expand Down Expand Up @@ -277,5 +278,86 @@ public void Full_text_search_on_bodies_is_enabled()
Assert.That(viewModel.AuditEnableFullTextSearchOnBodies.Value, Is.EqualTo(true));
}
}

[Test]
public void Instance_sections_are_expanded_by_default()
{
var viewModel = new ServiceControlAddViewModel();

using (Assert.EnterMultipleScope())
{
Assert.That(viewModel.IsServiceControlExpanded, Is.True);
Assert.That(viewModel.IsServiceControlAuditExpanded, Is.True);
}
}

[Test]
public void Integrated_ServicePulse_is_enabled_by_default()
{
var viewModel = new ServiceControlAddViewModel();

using (Assert.EnterMultipleScope())
{
Assert.That(viewModel.ErrorEnableIntegratedServicePulseOptions, Is.Not.Empty);
Assert.That(viewModel.ErrorEnableIntegratedServicePulse.Value, Is.True);
}
}

[Test]
public void Integrated_ServicePulse_can_be_disabled()
{
var viewModel = new ServiceControlAddViewModel();

var offOption = viewModel.ErrorEnableIntegratedServicePulseOptions.First(o => !o.Value);
viewModel.ServiceControl.EnableIntegratedServicePulse = offOption;

Assert.That(viewModel.ErrorEnableIntegratedServicePulse.Value, Is.False);
}

[Test]
public void Audit_only_configuration_has_no_validation_errors_for_error_fields()
{
var viewModel = new ServiceControlAddViewModel(() => [])
{
InstallErrorInstance = false,
InstallAuditInstance = true,
SubmitAttempted = true
};

var notifyErrorInfo = (INotifyDataErrorInfo)viewModel;

using (Assert.EnterMultipleScope())
{
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorInstanceName)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorHostName)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorPortNumber)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorDestinationPath)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorLogPath)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.ErrorDatabasePath)), Is.Empty);
}
}

[Test]
public void Error_only_configuration_has_no_validation_errors_for_audit_fields()
{
var viewModel = new ServiceControlAddViewModel(() => [])
{
InstallErrorInstance = true,
InstallAuditInstance = false,
SubmitAttempted = true
};

var notifyErrorInfo = (INotifyDataErrorInfo)viewModel;

using (Assert.EnterMultipleScope())
{
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditInstanceName)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditHostName)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditPortNumber)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditDestinationPath)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditLogPath)), Is.Empty);
Assert.That(notifyErrorInfo.GetErrors(nameof(viewModel.AuditDatabasePath)), Is.Empty);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace ServiceControl.Config.Commands
namespace ServiceControl.Config.Commands
{
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Framework;
using Framework.Commands;
Expand All @@ -18,17 +20,36 @@ public AddServiceControlInstanceCommand(IServiceControlWindowManager windowManag

public override async Task ExecuteAsync(object obj)
{
if (!await commandChecks.CanAddInstance(true))
await ExecuteWithOptions(installError: true, installAudit: true, installServicePulse: true);
}

public async Task ExecuteWithOptions(bool installError, bool installAudit, bool installServicePulse, CancellationToken cancellationToken = default)
{
if (!await commandChecks.CanAddInstance(true, cancellationToken))
{
return;
}

var instanceViewModel = addInstance();
await windowManager.ShowInnerDialog(instanceViewModel);
instanceViewModel.InstallErrorInstance = installError;
instanceViewModel.InstallAuditInstance = installAudit;

if (installError)
{
var spOption = instanceViewModel.ServiceControl.EnableIntegratedServicePulseOptions
.FirstOrDefault(o => o.Value == installServicePulse);

if (spOption != null)
{
instanceViewModel.ServiceControl.EnableIntegratedServicePulse = spOption;
}
}

await windowManager.ShowInnerDialog(instanceViewModel, cancellationToken: cancellationToken);
}

readonly Func<ServiceControlAddViewModel> addInstance;
readonly IServiceControlWindowManager windowManager;
readonly ScmuCommandChecks commandChecks;
}
}
}
74 changes: 18 additions & 56 deletions src/ServiceControl.Config/UI/InstanceAdd/ServiceControlAddView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,14 @@
Converter={StaticResource boolToVis}}" />
</StackPanel>

<TextBlock Padding="0, 0, 0, 10" Visibility="{Binding OneInstanceTypeSelected, Converter={StaticResource boolToVisInverted}}"
FontSize="13px"
Foreground="{StaticResource ErrorBrush}"
Text="Must select either an audit or an error instance." />

<StackPanel>
<!-- Horizontal layout: CheckBox + Expander side by side -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<CheckBox Grid.Column="0"
Padding="0, 0, 0, 0"
IsChecked="{Binding InstallErrorInstance}"
VerticalAlignment="Top"
Margin="0,8,8,5"/>

<Expander Grid.Column="1"
Header="ServiceControl"
IsExpanded="{Binding IsServiceControlExpanded}"
IsEnabled="{Binding InstallErrorInstance}"
Margin="0,5,0,5"
MouseDown="Button_MouseDown"
PreviewMouseDown="Button_MouseDown"
PreviewMouseLeftButtonDown="Button_MouseDown">
<StackPanel Margin="60,0,60,0" Visibility="{Binding InstallErrorInstance, Converter={StaticResource boolToVis}}">
<StackPanel Visibility="{Binding InstallErrorInstance, Converter={StaticResource boolToVis}}">
<Expander Header="ServiceControl"
IsExpanded="{Binding IsServiceControlExpanded}"
Margin="0,5,0,5"
MouseDown="Button_MouseDown"
PreviewMouseDown="Button_MouseDown"
PreviewMouseLeftButtonDown="Button_MouseDown">
<StackPanel Margin="60,0,60,0">
<Border Margin="0,40,0,20"
BorderBrush="{StaticResource Gray70Brush}"
BorderThickness="0,0,0,1">
Expand Down Expand Up @@ -261,34 +241,17 @@
ItemsSource="{Binding ErrorEnableIntegratedServicePulseOptions}"
SelectedValue="{Binding ErrorEnableIntegratedServicePulse}" />
</StackPanel>
</Expander>
</Grid>
</Expander>
</StackPanel>

<StackPanel>
<!-- Horizontal layout: CheckBox + Expander side by side -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<CheckBox Grid.Column="0"
Padding="0, 0, 0, 0"
IsChecked="{Binding InstallAuditInstance}"
IsThreeState="False"
VerticalAlignment="Top"
Margin="0,8,8,5"/>

<Expander Grid.Column="1"
Header="ServiceControl Audit"
IsExpanded="{Binding IsServiceControlAuditExpanded}"
IsEnabled="{Binding InstallAuditInstance}"
Margin="0,5,0,5"
MouseDown="Button_MouseDown"
PreviewMouseDown="Button_MouseDown"
PreviewMouseLeftButtonDown="Button_MouseDown">
<StackPanel Margin="60,0,60,0" Visibility="{Binding InstallAuditInstance, Converter={StaticResource boolToVis}}">
<StackPanel Visibility="{Binding InstallAuditInstance, Converter={StaticResource boolToVis}}">
<Expander Header="ServiceControl Audit"
IsExpanded="{Binding IsServiceControlAuditExpanded}"
Margin="0,5,0,5"
MouseDown="Button_MouseDown"
PreviewMouseDown="Button_MouseDown"
PreviewMouseLeftButtonDown="Button_MouseDown">
<StackPanel Margin="60,0,60,0">
<Border Margin="0,40,0,20"
BorderBrush="{StaticResource Gray70Brush}"
BorderThickness="0,0,0,1">
Expand Down Expand Up @@ -458,8 +421,7 @@
ItemsSource="{Binding AuditEnableFullTextSearchOnBodiesOptions}"
SelectedValue="{Binding AuditEnableFullTextSearchOnBodies}" />
</StackPanel>
</Expander>
</Grid>
</Expander>
</StackPanel>
</StackPanel>
</sie:SharedServiceControlEditorView.SharedContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ public string AuditDatabasePath

public TimeSpanUnits AuditRetentionUnits => ServiceControlAudit.AuditRetentionUnits;

public bool IsServiceControlExpanded { get; set; }
public bool IsServiceControlExpanded { get; set; } = true;

public bool IsServiceControlAuditExpanded { get; set; }
public bool IsServiceControlAuditExpanded { get; set; } = true;

public double AuditRetention
{
Expand Down
21 changes: 3 additions & 18 deletions src/ServiceControl.Config/UI/NoInstances/NoInstancesView.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="ServiceControl.Config.UI.NoInstances.NoInstancesView"
<UserControl x:Class="ServiceControl.Config.UI.NoInstances.NoInstancesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand All @@ -7,26 +7,11 @@
d:DesignWidth="600"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<TextBlock Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
VerticalAlignment="Center"
FontSize="20"
Foreground="{StaticResource Gray60Brush}"
Text="No service instances installed" />

<Button Grid.Row="1"
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Command="{Binding AddInstance}"
Content="Add new instance"
Style="{StaticResource HiliteButton}"
Visibility="{Binding ShowMonitoringInstances,
Converter={StaticResource boolToVisInverted}}" />
</Grid>
</UserControl>
</UserControl>
15 changes: 3 additions & 12 deletions src/ServiceControl.Config/UI/NoInstances/NoInstancesViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
namespace ServiceControl.Config.UI.NoInstances
namespace ServiceControl.Config.UI.NoInstances
{
using System.Windows.Input;
using Commands;
using Framework.Rx;

class NoInstancesViewModel : RxScreen
{
public NoInstancesViewModel(AddServiceControlInstanceCommand addInstance)
public NoInstancesViewModel()
{
DisplayName = "DEPLOYED INSTANCES";

AddInstance = addInstance;
}

public ICommand AddInstance { get; }

[FeatureToggle(Feature.MonitoringInstances)]
public bool ShowMonitoringInstances { get; set; }
}
}
}
Loading