mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
added a context menu item to push inheritance to child nodes
This commit is contained in:
@@ -16,7 +16,7 @@ using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Csv
|
||||
{
|
||||
public class CsvConnectionsDeserializerMremotengFormatTests
|
||||
public class CsvConnectionsDeserializerMremotengFormatTests
|
||||
{
|
||||
private CsvConnectionsDeserializerMremotengFormat _deserializer;
|
||||
private CsvConnectionsSerializerMremotengFormat _serializer;
|
||||
@@ -165,7 +165,8 @@ namespace mRemoteNGTests.Config.Serializers.ConnectionSerializers.Csv
|
||||
var ignoreProperties = new[]
|
||||
{
|
||||
nameof(ConnectionInfoInheritance.EverythingInherited),
|
||||
nameof(ConnectionInfoInheritance.Parent)
|
||||
nameof(ConnectionInfoInheritance.Parent),
|
||||
nameof(ConnectionInfoInheritance.EverythingInherited)
|
||||
};
|
||||
var properties = typeof(ConnectionInfoInheritance)
|
||||
.GetProperties()
|
||||
|
||||
@@ -93,16 +93,6 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(nameOfModifiedProperty, Is.EqualTo("OpenConnections"));
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(InheritancePropertyProvider), nameof(InheritancePropertyProvider.GetProperties))]
|
||||
public void MovingAConnectionUnderRootNodeDisablesInheritance(PropertyInfo property)
|
||||
{
|
||||
var rootNode = new RootNodeInfo(RootNodeType.Connection);
|
||||
_connectionInfo.Inheritance.EverythingInherited = true;
|
||||
_connectionInfo.SetParent(rootNode);
|
||||
var propertyValue = property.GetValue(_connectionInfo.Inheritance);
|
||||
Assert.That(propertyValue, Is.False);
|
||||
}
|
||||
|
||||
[TestCaseSource(typeof(InheritancePropertyProvider), nameof(InheritancePropertyProvider.GetProperties))]
|
||||
public void MovingAConnectionFromUnderRootNodeToUnderADifferentNodeEnablesInheritance(PropertyInfo property)
|
||||
{
|
||||
|
||||
@@ -4,15 +4,23 @@ using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Container
|
||||
{
|
||||
public class RootNodeInfoTests
|
||||
public class RootNodeInfoTests
|
||||
{
|
||||
[Test]
|
||||
public void InheritanceIsDisabledForNodesDirectlyUnderRootNode()
|
||||
{
|
||||
var rootNode = new RootNodeInfo(RootNodeType.Connection);
|
||||
var con1 = new ConnectionInfo { Inheritance = { Password = true } };
|
||||
var expected = "UnInheritedValue";
|
||||
var rootNode = new RootNodeInfo(RootNodeType.Connection)
|
||||
{
|
||||
Description = "thisCameFromTheRootNode"
|
||||
};
|
||||
var con1 = new ConnectionInfo
|
||||
{
|
||||
Description = expected,
|
||||
Inheritance = { Description = true }
|
||||
};
|
||||
rootNode.AddChild(con1);
|
||||
Assert.That(con1.Inheritance.Password, Is.False);
|
||||
Assert.That(con1.Description, Is.EqualTo(expected));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ namespace mRemoteNG.Connection
|
||||
/// settings for individual properties.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool InheritanceActive { get; set; }
|
||||
public bool InheritanceActive { get; set; } = true;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace mRemoteNG.UI.Controls
|
||||
private ToolStripMenuItem _cMenTreeImportFile;
|
||||
private ToolStripMenuItem _cMenTreeImportActiveDirectory;
|
||||
private ToolStripMenuItem _cMenTreeImportPortScan;
|
||||
private ToolStripMenuItem _cMenTreeApplyInheritanceToChildren;
|
||||
private readonly ConnectionTree _connectionTree;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
|
||||
@@ -98,6 +99,7 @@ namespace mRemoteNG.UI.Controls
|
||||
_cMenTreeImportFile = new ToolStripMenuItem();
|
||||
_cMenTreeImportActiveDirectory = new ToolStripMenuItem();
|
||||
_cMenTreeImportPortScan = new ToolStripMenuItem();
|
||||
_cMenTreeApplyInheritanceToChildren = new ToolStripMenuItem();
|
||||
_cMenTreeExportFile = new ToolStripMenuItem();
|
||||
_cMenTreeSep4 = new ToolStripSeparator();
|
||||
_cMenTreeAddConnection = new ToolStripMenuItem();
|
||||
@@ -134,6 +136,7 @@ namespace mRemoteNG.UI.Controls
|
||||
_cMenTreeSep4,
|
||||
_cMenTreeAddConnection,
|
||||
_cMenTreeAddFolder,
|
||||
_cMenTreeApplyInheritanceToChildren,
|
||||
_toolStripSeparator1,
|
||||
_cMenTreeToolsSort,
|
||||
_cMenTreeMoveUp,
|
||||
@@ -396,8 +399,17 @@ namespace mRemoteNG.UI.Controls
|
||||
_cMenTreeMoveDown.Size = new System.Drawing.Size(199, 22);
|
||||
_cMenTreeMoveDown.Text = "Move down";
|
||||
_cMenTreeMoveDown.Click += OnMoveDownClicked;
|
||||
//
|
||||
// _cMenTreeApplyInheritanceToChildren
|
||||
//
|
||||
_cMenTreeApplyInheritanceToChildren.Name = "_cMenTreeApplyInheritanceToChildren";
|
||||
_cMenTreeApplyInheritanceToChildren.Size = new System.Drawing.Size(199, 22);
|
||||
_cMenTreeApplyInheritanceToChildren.Text = "Apply inheritance to children";
|
||||
_cMenTreeApplyInheritanceToChildren.Click += OnApplyInheritanceToChildrenClicked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void ApplyLanguage()
|
||||
{
|
||||
_cMenTreeConnect.Text = Language.strConnect;
|
||||
@@ -874,6 +886,14 @@ namespace mRemoteNG.UI.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void OnApplyInheritanceToChildrenClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!(_connectionTree.SelectedNode is ContainerInfo container))
|
||||
return;
|
||||
|
||||
container.ApplyInheritancePropertiesToChildren();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user