Skip to content

Commit 001f747

Browse files
authored
Merge pull request #1114 from OctopusDeploy/wlthomson/label-disabled-tenants-in-setup-dropdown
2 parents 680247f + 2d6dc77 commit 001f747

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

source/Octopus.Manager.Tentacle/TentacleConfiguration/SetupWizard/SetupTentacleWizardModel.cs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class SetupTentacleWizardModel : ShellViewModel, IScriptableViewModel, IH
5656
string[] potentialRoles;
5757
string[] potentialMachinePolicies;
5858
string[] potentialTenantTags;
59-
string[] potentialTenants;
59+
TenantDisplayItem[] potentialTenants;
6060
string[] potentialWorkerPools;
6161
string[] potentialSpaces;
6262
string machineName;
@@ -321,17 +321,23 @@ public string[] PotentialTenantTags
321321
}
322322
}
323323

324-
public string[] PotentialTenants
324+
public TenantDisplayItem[] PotentialTenants
325325
{
326326
get => potentialTenants;
327327
set
328328
{
329329
if (Equals(value, potentialTenants)) return;
330330
potentialTenants = value;
331331
OnPropertyChanged();
332+
OnPropertyChanged(nameof(PotentialTenantNames));
332333
}
333334
}
334335

336+
public string[] PotentialTenantNames
337+
{
338+
get => potentialTenants?.Select(t => t.GetDisplayName()).ToArray() ?? Array.Empty<string>();
339+
}
340+
335341
public string[] PotentialWorkerPools
336342
{
337343
get => potentialWorkerPools;
@@ -777,8 +783,8 @@ void UpdateTenants()
777783
AreTenantsSupported = spaceSpecificData.AreTenantsSupported;
778784
PotentialTenantTags = spaceSpecificData.TenantTags.SelectMany(tt => tt.Tags.Select(t => t.CanonicalTagName)).ToArray();
779785
UpdateSelection(SelectedTenantTags, PotentialTenantTags);
780-
PotentialTenants = spaceSpecificData.Tenants.Select(tt => tt.Name).ToArray();
781-
UpdateSelection(SelectedTenants, PotentialTenants);
786+
PotentialTenants = spaceSpecificData.Tenants.Select(tt => new TenantDisplayItem(tt.Name, tt.IsDisabled)).ToArray();
787+
UpdateSelection(SelectedTenants, PotentialTenants.Select(t => t.GetDisplayName()));
782788
AreTenantsAvailable = PotentialTenants.Any();
783789
}
784790

@@ -929,7 +935,10 @@ public IEnumerable<CommandLineInvocation> GenerateScript()
929935
register.Argument("tenanttag", tag);
930936

931937
foreach (var tenant in SelectedTenants)
932-
register.Argument("tenant", tenant);
938+
{
939+
var tenantItem = PotentialTenants.FirstOrDefault(t => t.GetDisplayName() == tenant);
940+
register.Argument("tenant", tenantItem?.Name ?? tenant);
941+
}
933942
}
934943

935944
foreach (var role in SelectedRoles)
@@ -1086,4 +1095,21 @@ async Task<List<TenantResource>> LoadTenants()
10861095
MachinePolicies = machinePolicies;
10871096
}
10881097
}
1098+
1099+
public class TenantDisplayItem
1100+
{
1101+
public string Name { get; }
1102+
public bool IsDisabled { get; }
1103+
1104+
public TenantDisplayItem(string name, bool isDisabled)
1105+
{
1106+
Name = name;
1107+
IsDisabled = isDisabled;
1108+
}
1109+
1110+
public string GetDisplayName()
1111+
{
1112+
return IsDisabled ? $"{Name} (disabled)" : Name;
1113+
}
1114+
}
10891115
}

source/Octopus.Manager.Tentacle/TentacleConfiguration/SetupWizard/Views/TentacleActiveDetailsTab.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<TextBlock TextWrapping="Wrap" Foreground="Gray" Text="Choose at least one role that this deployment target will provide." FontSize="10" HorizontalAlignment="Stretch" />
6161
<Expander Padding="0" Header="Tenants" Style="{StaticResource CustomMaterialDesignExpander}" IsExpanded="{Binding AreTenantsAvailable}" Visibility="{Binding Path=AreTenantsSupported, Converter={StaticResource Converter.BooleanToVisibilityConverter}}" Background="White" Margin="0,20,0,0">
6262
<StackPanel Background="White">
63-
<controls:AutoCompleteTagControl SuggestedTags="{Binding Path=PotentialTenants}" SelectedTags="{Binding SelectedTenants}" TagName="tenants" CanCreateNewTags="False"/>
63+
<controls:AutoCompleteTagControl SuggestedTags="{Binding Path=PotentialTenantNames}" SelectedTags="{Binding SelectedTenants}" TagName="tenants" CanCreateNewTags="False"/>
6464
<controls:ErrorMessage ErrorPath="SelectedTenants" />
6565
<TextBlock TextWrapping="Wrap" Foreground="Gray" Text="Choose tenants this deployment target should be associated with." FontSize="10"/>
6666

source/Octopus.Tentacle/Octopus.Tentacle.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</ItemGroup>
5454
<ItemGroup>
5555
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.1" />
56-
<PackageReference Include="Octopus.Client" Version="14.3.1508" />
56+
<PackageReference Include="Octopus.Client" Version="15.2.2240" />
5757
</ItemGroup>
5858
<ItemGroup>
5959
<PackageReference Include="Autofac" Version="4.6.2" />

0 commit comments

Comments
 (0)