Skip to content

Commit d6ea380

Browse files
Merge pull request #659 from Sitecore/feature/657-Hide_Sitecore_9_instances_that_do_not_exist_in_Environments.json
#657 Hide Sitecore 9 and later instances that do not exist in Environments.json
2 parents c22c29b + da3154c commit d6ea380

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/SIM.Instances/InstanceManager.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,19 @@ public void Initialize([CanBeNull] string defaultRootFolder = null)
130130

131131
List<Instance> instances = new List<Instance>();
132132

133-
if(ApplicationManager.IsIisRunning) {instances.AddRange(GetIISInstances());}
133+
if(ApplicationManager.IsIisRunning)
134+
{
135+
List<Instance> iisInstances = GetIISInstances().ToList();
136+
if (!InstanceSettings.CoreInstancesShowWithoutEnviorenmentMembers.Value)
137+
{
138+
List<Instance> instancesWithoutMembers = iisInstances.Where(instance => instance.Type != Instance.InstanceType.Sitecore8AndEarlier && instance.SitecoreEnvironment.Members == null).ToList();
139+
instances.AddRange(iisInstances.Except(instancesWithoutMembers));
140+
}
141+
else
142+
{
143+
instances.AddRange(iisInstances);
144+
}
145+
}
134146

135147
if(ApplicationManager.IsDockerRunning) {instances.AddRange(GetContainerizedInstances());}
136148

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace SIM.Instances
2+
{
3+
public static class InstanceSettings
4+
{
5+
public static readonly AdvancedProperty<bool> CoreInstancesShowWithoutEnviorenmentMembers = AdvancedSettings.Create("Core/Instances/ShowWithoutEnviorenmentMembers", false);
6+
}
7+
}

src/SIM.Instances/SIM.Instances.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<ItemGroup>
8282
<Compile Include="ContainerizedInstance.cs" />
8383
<Compile Include="InstanceHelper.cs" />
84+
<Compile Include="InstanceSettings.cs" />
8485
<Compile Include="InstanceState.cs" />
8586
<Compile Include="PartiallyCachedInstance.cs" />
8687
<Compile Include="Instance.cs" />

src/SIM.Tool.Windows/Dialogs/AdvancedSettingsDialog.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public AdvancedSettingsDialog()
2525
// workaround for #179
2626
var types = new[]
2727
{
28-
typeof(SIM.Core.CoreAppSettings),
28+
typeof(SIM.Core.CoreAppSettings),
29+
typeof(SIM.Instances.InstanceSettings),
2930
typeof(SIM.Tool.Base.WinAppSettings),
3031
typeof(SIM.Tool.Windows.Properties.Settings),
3132
typeof(SIM.Tool.Windows.WindowsSettings),

0 commit comments

Comments
 (0)