Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
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
25 changes: 0 additions & 25 deletions src/GitHub.App/SampleData/SampleViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public RepositoryCreationViewModelDesigner()
RepositoryName = "Hello-World";
Description = "A description";
KeepPrivate = true;
CanKeepPrivate = true;
Accounts = new ReactiveList<IAccount>
{
new AccountDesigner { Login = "shana" },
Expand Down Expand Up @@ -80,12 +79,6 @@ public ReactiveCommand<Unit, Unit> BrowseForDirectory
private set;
}

public bool CanKeepPrivate
{
get;
private set;
}

public ReactiveCommand<Unit, Unit> CreateRepository
{
get;
Expand Down Expand Up @@ -146,24 +139,6 @@ public IAccount SelectedAccount
set;
}

public bool ShowUpgradePlanWarning
{
get;
private set;
}

public bool ShowUpgradeToMicroPlanWarning
{
get;
private set;
}

public ICommand UpgradeAccountPlan
{
get;
private set;
}

public IReadOnlyList<GitIgnoreItem> GitIgnoreTemplates
{
get; private set;
Expand Down
10 changes: 0 additions & 10 deletions src/GitHub.App/ViewModels/Dialog/RepositoryCreationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class RepositoryCreationViewModel : RepositoryFormViewModel, IRepositoryC
readonly IModelServiceFactory modelServiceFactory;
readonly IRepositoryCreationService repositoryCreationService;
readonly ObservableAsPropertyHelper<bool> isCreating;
readonly ObservableAsPropertyHelper<bool> canKeepPrivate;
readonly IOperatingSystem operatingSystem;
readonly IUsageTracker usageTracker;
ObservableAsPropertyHelper<IReadOnlyList<IAccount>> accounts;
Expand Down Expand Up @@ -96,10 +95,6 @@ public RepositoryCreationViewModel(

CreateRepository = InitializeCreateRepositoryCommand();

canKeepPrivate = CanKeepPrivateObservable.CombineLatest(CreateRepository.IsExecuting,
(canKeep, publishing) => canKeep && !publishing)
.ToProperty(this, x => x.CanKeepPrivate);

isCreating = CreateRepository.IsExecuting
.ToProperty(this, x => x.IsCreating);

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

/// <summary>
/// If the repo can be made private (depends on the user plan)
/// </summary>
public bool CanKeepPrivate { get { return canKeepPrivate.Value; } }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yey, commenting now works! 😄


IReadOnlyList<GitIgnoreItem> gitIgnoreTemplates;
public IReadOnlyList<GitIgnoreItem> GitIgnoreTemplates
{
Expand Down
19 changes: 0 additions & 19 deletions src/GitHub.App/ViewModels/RepositoryFormViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ public abstract class RepositoryFormViewModel : ViewModelBase

protected RepositoryFormViewModel()
{
CanKeepPrivateObservable = this.WhenAny(
x => x.SelectedAccount.IsEnterprise,
x => x.SelectedAccount.IsOnFreePlan,
x => x.SelectedAccount.HasMaximumPrivateRepositories,
(isEnterprise, isOnFreePlan, hasMaxPrivateRepos) =>
isEnterprise.Value || (!isOnFreePlan.Value && !hasMaxPrivateRepos.Value));

CanKeepPrivateObservable
.Where(x => !x)
.Subscribe(x => KeepPrivate = false);

safeRepositoryName = this.WhenAny(x => x.RepositoryName, x => x.Value)
.Select(x => x != null ? GetSafeRepositoryName(x) : null)
.ToProperty(this, x => x.SafeRepositoryName);
Expand Down Expand Up @@ -85,14 +74,6 @@ public IAccount SelectedAccount
set { this.RaiseAndSetIfChanged(ref selectedAccount, value); }
}

public bool ShowUpgradePlanWarning { get; private set; }

public bool ShowUpgradeToMicroPlanWarning { get; private set; }

public ICommand UpgradeAccountPlan { get; private set; }

protected IObservable<bool> CanKeepPrivateObservable { get; private set; }

// These are the characters which are permitted when creating a repository name on GitHub The Website
static readonly Regex invalidRepositoryCharsRegex = new Regex(@"[^0-9A-Za-z_\.\-]", RegexOptions.ECMAScript);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class RepositoryPublishViewModel : RepositoryFormViewModel, IRepositoryPu
readonly IModelServiceFactory modelServiceFactory;
readonly ObservableAsPropertyHelper<IReadOnlyList<IAccount>> accounts;
readonly ObservableAsPropertyHelper<bool> isHostComboBoxVisible;
readonly ObservableAsPropertyHelper<bool> canKeepPrivate;
readonly ObservableAsPropertyHelper<string> title;
readonly IUsageTracker usageTracker;

Expand Down Expand Up @@ -91,11 +90,6 @@ public RepositoryPublishViewModel(
InitializeValidation();

PublishRepository = InitializePublishRepositoryCommand();

canKeepPrivate = CanKeepPrivateObservable.CombineLatest(PublishRepository.IsExecuting,
(canKeep, publishing) => canKeep && !publishing)
.ToProperty(this, x => x.CanKeepPrivate);

PublishRepository.IsExecuting.Subscribe(x => IsBusy = x);

var defaultRepositoryName = repositoryPublishService.LocalRepositoryName;
Expand All @@ -116,7 +110,6 @@ public RepositoryPublishViewModel(
}

public string Title { get { return title.Value; } }
public bool CanKeepPrivate { get { return canKeepPrivate.Value; } }

public ReactiveCommand<Unit, ProgressState> PublishRepository { get; private set; }
public IReadOnlyObservableCollection<IConnection> Connections { get; private set; }
Expand Down
13 changes: 0 additions & 13 deletions src/GitHub.Exports.Reactive/ViewModels/IRepositoryForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,5 @@ public interface IRepositoryForm : IViewModel
/// Indicates whether the created repository should be private or not.
/// </summary>
bool KeepPrivate { get; set; }

/// <summary>
/// Indicates whether the user can create a private repository. This is false if the user is not a paid
/// account or if the user has run out of repositories for their current plan.
/// </summary>
bool CanKeepPrivate { get; }
bool ShowUpgradeToMicroPlanWarning { get; }
bool ShowUpgradePlanWarning { get; }

/// <summary>
/// Command that opens a browser to a page for upgrading the user's plan.
/// </summary>
ICommand UpgradeAccountPlan { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@
Padding="8,0,0,0"
Style="{DynamicResource BlueRoundedCheckBox}"
IsChecked="{Binding KeepPrivate}"
IsEnabled="{Binding CanKeepPrivate}"
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.PrivateRepositoryCheckBox}" />
</Grid>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,9 @@
<CheckBox x:Name="makePrivate"
Margin="0,8,0,0"
IsChecked="{Binding KeepPrivate}"
IsEnabled="{Binding CanKeepPrivate}"
Style="{StaticResource VSStyledCheckBox}"
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.TeamExplorerPrivateRepositoryCheckBox}" >
<TextBlock Background="{DynamicResource GitHubVsToolWindowBackground}"
Foreground="{DynamicResource GitHubVsToolWindowText}"
TextWrapping="Wrap">
<TextBlock.Resources>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.5" />
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Resources>
<TextBlock.Inlines>
<Run Text="{x:Static ghfvs:Resources.makePrivateContent}" />
</TextBlock.Inlines>
</TextBlock>
</CheckBox>
Content="{x:Static ghfvs:Resources.makePrivateContent}"
AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.TeamExplorerPrivateRepositoryCheckBox}" />

<Button x:Name="publishRepositoryButton"
Margin="0,8,0,0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,28 +603,4 @@ public void CannotCreateWhenRepositoryNameOrBasePathIsInvalid(
Assert.That(expected, Is.EqualTo(result));
}
}

public class TheCanKeepPrivateProperty : TestBaseClass
{
[TestCase(true, false, false, false)]
[TestCase(true, false, true, false)]
[TestCase(false, false, true, false)]
[TestCase(true, true, true, true)]
[TestCase(false, false, false, true)]
public void IsOnlyTrueWhenUserIsEntepriseOrNotOnFreeAccountThatIsNotMaxedOut(
bool isFreeAccount,
bool isEnterprise,
bool isMaxedOut,
bool expected)
{
var selectedAccount = Substitute.For<IAccount>();
selectedAccount.IsOnFreePlan.Returns(isFreeAccount);
selectedAccount.IsEnterprise.Returns(isEnterprise);
selectedAccount.HasMaximumPrivateRepositories.Returns(isMaxedOut);
var vm = GetMeAViewModel();
vm.SelectedAccount = selectedAccount;

Assert.That(expected, Is.EqualTo(vm.CanKeepPrivate));
}
}
}