Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit e48a595

Browse files
committed
Don't prevent free users from creating private repos.
1 parent 306bd6b commit e48a595

File tree

7 files changed

+2
-93
lines changed

7 files changed

+2
-93
lines changed

src/GitHub.App/ViewModels/Dialog/RepositoryCreationViewModel.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public class RepositoryCreationViewModel : RepositoryFormViewModel, IRepositoryC
3939
readonly IModelServiceFactory modelServiceFactory;
4040
readonly IRepositoryCreationService repositoryCreationService;
4141
readonly ObservableAsPropertyHelper<bool> isCreating;
42-
readonly ObservableAsPropertyHelper<bool> canKeepPrivate;
4342
readonly IOperatingSystem operatingSystem;
4443
readonly IUsageTracker usageTracker;
4544
ObservableAsPropertyHelper<IReadOnlyList<IAccount>> accounts;
@@ -96,10 +95,6 @@ public RepositoryCreationViewModel(
9695

9796
CreateRepository = InitializeCreateRepositoryCommand();
9897

99-
canKeepPrivate = CanKeepPrivateObservable.CombineLatest(CreateRepository.IsExecuting,
100-
(canKeep, publishing) => canKeep && !publishing)
101-
.ToProperty(this, x => x.CanKeepPrivate);
102-
10398
isCreating = CreateRepository.IsExecuting
10499
.ToProperty(this, x => x.IsCreating);
105100

@@ -128,11 +123,6 @@ public string BaseRepositoryPath
128123
/// </summary>
129124
public bool IsCreating { get { return isCreating.Value; } }
130125

131-
/// <summary>
132-
/// If the repo can be made private (depends on the user plan)
133-
/// </summary>
134-
public bool CanKeepPrivate { get { return canKeepPrivate.Value; } }
135-
136126
IReadOnlyList<GitIgnoreItem> gitIgnoreTemplates;
137127
public IReadOnlyList<GitIgnoreItem> GitIgnoreTemplates
138128
{

src/GitHub.App/ViewModels/RepositoryFormViewModel.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@ public abstract class RepositoryFormViewModel : ViewModelBase
1717

1818
protected RepositoryFormViewModel()
1919
{
20-
CanKeepPrivateObservable = this.WhenAny(
21-
x => x.SelectedAccount.IsEnterprise,
22-
x => x.SelectedAccount.IsOnFreePlan,
23-
x => x.SelectedAccount.HasMaximumPrivateRepositories,
24-
(isEnterprise, isOnFreePlan, hasMaxPrivateRepos) =>
25-
isEnterprise.Value || (!isOnFreePlan.Value && !hasMaxPrivateRepos.Value));
26-
27-
CanKeepPrivateObservable
28-
.Where(x => !x)
29-
.Subscribe(x => KeepPrivate = false);
30-
3120
safeRepositoryName = this.WhenAny(x => x.RepositoryName, x => x.Value)
3221
.Select(x => x != null ? GetSafeRepositoryName(x) : null)
3322
.ToProperty(this, x => x.SafeRepositoryName);
@@ -85,14 +74,6 @@ public IAccount SelectedAccount
8574
set { this.RaiseAndSetIfChanged(ref selectedAccount, value); }
8675
}
8776

88-
public bool ShowUpgradePlanWarning { get; private set; }
89-
90-
public bool ShowUpgradeToMicroPlanWarning { get; private set; }
91-
92-
public ICommand UpgradeAccountPlan { get; private set; }
93-
94-
protected IObservable<bool> CanKeepPrivateObservable { get; private set; }
95-
9677
// These are the characters which are permitted when creating a repository name on GitHub The Website
9778
static readonly Regex invalidRepositoryCharsRegex = new Regex(@"[^0-9A-Za-z_\.\-]", RegexOptions.ECMAScript);
9879

src/GitHub.App/ViewModels/TeamExplorer/RepositoryPublishViewModel.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class RepositoryPublishViewModel : RepositoryFormViewModel, IRepositoryPu
3131
readonly IModelServiceFactory modelServiceFactory;
3232
readonly ObservableAsPropertyHelper<IReadOnlyList<IAccount>> accounts;
3333
readonly ObservableAsPropertyHelper<bool> isHostComboBoxVisible;
34-
readonly ObservableAsPropertyHelper<bool> canKeepPrivate;
3534
readonly ObservableAsPropertyHelper<string> title;
3635
readonly IUsageTracker usageTracker;
3736

@@ -91,11 +90,6 @@ public RepositoryPublishViewModel(
9190
InitializeValidation();
9291

9392
PublishRepository = InitializePublishRepositoryCommand();
94-
95-
canKeepPrivate = CanKeepPrivateObservable.CombineLatest(PublishRepository.IsExecuting,
96-
(canKeep, publishing) => canKeep && !publishing)
97-
.ToProperty(this, x => x.CanKeepPrivate);
98-
9993
PublishRepository.IsExecuting.Subscribe(x => IsBusy = x);
10094

10195
var defaultRepositoryName = repositoryPublishService.LocalRepositoryName;
@@ -116,7 +110,6 @@ public RepositoryPublishViewModel(
116110
}
117111

118112
public string Title { get { return title.Value; } }
119-
public bool CanKeepPrivate { get { return canKeepPrivate.Value; } }
120113

121114
public ReactiveCommand<Unit, ProgressState> PublishRepository { get; private set; }
122115
public IReadOnlyObservableCollection<IConnection> Connections { get; private set; }

src/GitHub.Exports.Reactive/ViewModels/IRepositoryForm.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,5 @@ public interface IRepositoryForm : IViewModel
4141
/// Indicates whether the created repository should be private or not.
4242
/// </summary>
4343
bool KeepPrivate { get; set; }
44-
45-
/// <summary>
46-
/// Indicates whether the user can create a private repository. This is false if the user is not a paid
47-
/// account or if the user has run out of repositories for their current plan.
48-
/// </summary>
49-
bool CanKeepPrivate { get; }
50-
bool ShowUpgradeToMicroPlanWarning { get; }
51-
bool ShowUpgradePlanWarning { get; }
52-
53-
/// <summary>
54-
/// Command that opens a browser to a page for upgrading the user's plan.
55-
/// </summary>
56-
ICommand UpgradeAccountPlan { get; }
5744
}
5845
}

src/GitHub.VisualStudio.UI/Views/Dialog/RepositoryCreationView.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@
244244
Padding="8,0,0,0"
245245
Style="{DynamicResource BlueRoundedCheckBox}"
246246
IsChecked="{Binding KeepPrivate}"
247-
IsEnabled="{Binding CanKeepPrivate}"
248247
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.PrivateRepositoryCheckBox}" />
249248
</Grid>
250249

src/GitHub.VisualStudio.UI/Views/TeamExplorer/RepositoryPublishView.xaml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,9 @@
129129
<CheckBox x:Name="makePrivate"
130130
Margin="0,8,0,0"
131131
IsChecked="{Binding KeepPrivate}"
132-
IsEnabled="{Binding CanKeepPrivate}"
133132
Style="{StaticResource VSStyledCheckBox}"
134-
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.TeamExplorerPrivateRepositoryCheckBox}" >
135-
<TextBlock Background="{DynamicResource GitHubVsToolWindowBackground}"
136-
Foreground="{DynamicResource GitHubVsToolWindowText}"
137-
TextWrapping="Wrap">
138-
<TextBlock.Resources>
139-
<Style TargetType="{x:Type TextBlock}">
140-
<Style.Triggers>
141-
<Trigger Property="IsEnabled" Value="False">
142-
<Setter Property="Opacity" Value="0.5" />
143-
</Trigger>
144-
</Style.Triggers>
145-
</Style>
146-
</TextBlock.Resources>
147-
<TextBlock.Inlines>
148-
<Run Text="{x:Static ghfvs:Resources.makePrivateContent}" />
149-
</TextBlock.Inlines>
150-
</TextBlock>
151-
</CheckBox>
133+
Content="{x:Static ghfvs:Resources.makePrivateContent}"
134+
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.TeamExplorerPrivateRepositoryCheckBox}" />
152135

153136
<Button x:Name="publishRepositoryButton"
154137
Margin="0,8,0,0"

test/GitHub.App.UnitTests/ViewModels/Dialog/RepositoryCreationViewModelTests.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -603,28 +603,4 @@ public void CannotCreateWhenRepositoryNameOrBasePathIsInvalid(
603603
Assert.That(expected, Is.EqualTo(result));
604604
}
605605
}
606-
607-
public class TheCanKeepPrivateProperty : TestBaseClass
608-
{
609-
[TestCase(true, false, false, false)]
610-
[TestCase(true, false, true, false)]
611-
[TestCase(false, false, true, false)]
612-
[TestCase(true, true, true, true)]
613-
[TestCase(false, false, false, true)]
614-
public void IsOnlyTrueWhenUserIsEntepriseOrNotOnFreeAccountThatIsNotMaxedOut(
615-
bool isFreeAccount,
616-
bool isEnterprise,
617-
bool isMaxedOut,
618-
bool expected)
619-
{
620-
var selectedAccount = Substitute.For<IAccount>();
621-
selectedAccount.IsOnFreePlan.Returns(isFreeAccount);
622-
selectedAccount.IsEnterprise.Returns(isEnterprise);
623-
selectedAccount.HasMaximumPrivateRepositories.Returns(isMaxedOut);
624-
var vm = GetMeAViewModel();
625-
vm.SelectedAccount = selectedAccount;
626-
627-
Assert.That(expected, Is.EqualTo(vm.CanKeepPrivate));
628-
}
629-
}
630606
}

0 commit comments

Comments
 (0)