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

Commit

Permalink
Merge pull request #1712 from github/refactor/pr-models
Browse files Browse the repository at this point in the history
Refactoring Pull Request Models.
  • Loading branch information
grokys committed Jun 21, 2018
2 parents 9e03d68 + d1bc28c commit d5ddf0d
Show file tree
Hide file tree
Showing 100 changed files with 2,281 additions and 2,288 deletions.
Binary file removed lib/Octokit.GraphQL.0.0.2-alpha.nupkg
Binary file not shown.
Binary file added lib/Octokit.GraphQL.0.0.4-alpha.nupkg
Binary file not shown.
8 changes: 4 additions & 4 deletions src/GitHub.Api/GitHub.Api.csproj
Expand Up @@ -51,12 +51,12 @@
<HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Octokit.GraphQL, Version=0.0.2.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
<HintPath>..\..\packages\Octokit.GraphQL.0.0.2-alpha\lib\netstandard1.1\Octokit.GraphQL.dll</HintPath>
<Reference Include="Octokit.GraphQL, Version=0.0.4.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
<HintPath>..\..\packages\Octokit.GraphQL.0.0.4-alpha\lib\netstandard1.1\Octokit.GraphQL.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Octokit.GraphQL.Core, Version=0.0.2.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
<HintPath>..\..\packages\Octokit.GraphQL.0.0.2-alpha\lib\netstandard1.1\Octokit.GraphQL.Core.dll</HintPath>
<Reference Include="Octokit.GraphQL.Core, Version=0.0.4.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
<HintPath>..\..\packages\Octokit.GraphQL.0.0.4-alpha\lib\netstandard1.1\Octokit.GraphQL.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.Api/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
<package id="Octokit.GraphQL" version="0.0.2-alpha" targetFramework="net461" />
<package id="Octokit.GraphQL" version="0.0.4-alpha" targetFramework="net461" />
<package id="Serilog" version="2.5.0" targetFramework="net461" />
</packages>
4 changes: 0 additions & 4 deletions src/GitHub.App/Factories/ModelServiceFactory.cs
Expand Up @@ -16,7 +16,6 @@ namespace GitHub.Factories
public sealed class ModelServiceFactory : IModelServiceFactory, IDisposable
{
readonly IApiClientFactory apiClientFactory;
readonly IGraphQLClientFactory graphQLClientFactory;
readonly IHostCacheFactory hostCacheFactory;
readonly IAvatarProvider avatarProvider;
readonly Dictionary<IConnection, ModelService> cache = new Dictionary<IConnection, ModelService>();
Expand All @@ -25,12 +24,10 @@ public sealed class ModelServiceFactory : IModelServiceFactory, IDisposable
[ImportingConstructor]
public ModelServiceFactory(
IApiClientFactory apiClientFactory,
IGraphQLClientFactory graphQLClientFactory,
IHostCacheFactory hostCacheFactory,
IAvatarProvider avatarProvider)
{
this.apiClientFactory = apiClientFactory;
this.graphQLClientFactory = graphQLClientFactory;
this.hostCacheFactory = hostCacheFactory;
this.avatarProvider = avatarProvider;
}
Expand All @@ -47,7 +44,6 @@ public async Task<IModelService> CreateAsync(IConnection connection)
{
result = new ModelService(
await apiClientFactory.Create(connection.HostAddress),
await graphQLClientFactory.CreateConnection(connection.HostAddress),
await hostCacheFactory.Create(connection.HostAddress),
avatarProvider);
result.InsertUser(AccountCacheItem.Create(connection.User));
Expand Down
17 changes: 7 additions & 10 deletions src/GitHub.App/GitHub.App.csproj
Expand Up @@ -145,12 +145,12 @@
<HintPath>..\..\packages\Microsoft.VisualStudio.Utilities.14.3.25407\lib\net45\Microsoft.VisualStudio.Utilities.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Octokit.GraphQL, Version=0.0.2.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
<HintPath>..\..\packages\Octokit.GraphQL.0.0.2-alpha\lib\netstandard1.1\Octokit.GraphQL.dll</HintPath>
<Reference Include="Octokit.GraphQL, Version=0.0.4.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
<HintPath>..\..\packages\Octokit.GraphQL.0.0.4-alpha\lib\netstandard1.1\Octokit.GraphQL.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Octokit.GraphQL.Core, Version=0.0.2.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
<HintPath>..\..\packages\Octokit.GraphQL.0.0.2-alpha\lib\netstandard1.1\Octokit.GraphQL.Core.dll</HintPath>
<Reference Include="Octokit.GraphQL.Core, Version=0.0.4.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
<HintPath>..\..\packages\Octokit.GraphQL.0.0.4-alpha\lib\netstandard1.1\Octokit.GraphQL.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
Expand Down Expand Up @@ -209,12 +209,10 @@
<Compile Include="Commands\UsageTrackingCommand.cs" />
<Compile Include="Factories\ViewViewModelFactory.cs" />
<Compile Include="Factories\ModelServiceFactory.cs" />
<Compile Include="Models\IssueCommentModel.cs" />
<Compile Include="Models\PullRequestReviewCommentModel.cs" />
<Compile Include="Models\PullRequestDetailArgument.cs" />
<Compile Include="Models\PullRequestModel.cs" />
<Compile Include="SampleData\ForkRepositoryExecuteViewModelDesigner.cs" />
<Compile Include="SampleData\ForkRepositorySelectViewModelDesigner.cs" />
<Compile Include="Models\PullRequestReviewModel.cs" />
<Compile Include="SampleData\GitServiceDesigner.cs" />
<Compile Include="SampleData\ForkRepositorySwitchViewModelDesigner.cs" />
<Compile Include="SampleData\PullRequestFilesViewModelDesigner.cs" />
Expand All @@ -225,6 +223,7 @@
<Compile Include="Services\EnterpriseCapabilitiesService.cs" />
<Compile Include="Services\GlobalConnection.cs" />
<Compile Include="Services\RepositoryForkService.cs" />
<Compile Include="ViewModels\ActorViewModel.cs" />
<Compile Include="ViewModels\Dialog\ForkRepositoryExecuteViewModel.cs" />
<Compile Include="ViewModels\Dialog\ForkRepositorySwitchViewModel.cs" />
<Compile Include="ViewModels\Dialog\ForkRepositoryViewModel.cs" />
Expand Down Expand Up @@ -256,7 +255,7 @@
<Compile Include="ViewModels\GitHubPane\NotAGitHubRepositoryViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\NotAGitRepositoryViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestReviewAuthoringViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestReviewFileCommentViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestReviewCommentViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestReviewSummaryViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestReviewViewModel.cs" />
<Compile Include="ViewModels\GitHubPane\PullRequestUserReviewsViewModel.cs" />
Expand All @@ -268,8 +267,6 @@
<Compile Include="Extensions\AkavacheExtensions.cs" />
<Compile Include="Extensions\EnvironmentExtensions.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Models\PullRequestFileModel.cs" />
<Compile Include="Models\PullRequestModel.cs" />
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down
13 changes: 0 additions & 13 deletions src/GitHub.App/Models/IssueCommentModel.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/GitHub.App/Models/PullRequestFileModel.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/GitHub.App/Models/PullRequestModel.cs
Expand Up @@ -162,32 +162,6 @@ public string Body
public DateTimeOffset CreatedAt { get; set; }
public DateTimeOffset UpdatedAt { get; set; }
public IAccount Author { get; set; }
public IReadOnlyList<IPullRequestFileModel> ChangedFiles { get; set; } = new IPullRequestFileModel[0];
public IReadOnlyList<ICommentModel> Comments { get; set; } = new ICommentModel[0];

IReadOnlyList<IPullRequestReviewModel> reviews = new IPullRequestReviewModel[0];
public IReadOnlyList<IPullRequestReviewModel> Reviews
{
get { return reviews; }
set
{
Guard.ArgumentNotNull(value, nameof(value));
reviews = value;
this.RaisePropertyChange();
}
}

IReadOnlyList<IPullRequestReviewCommentModel> reviewComments = new IPullRequestReviewCommentModel[0];
public IReadOnlyList<IPullRequestReviewCommentModel> ReviewComments
{
get { return reviewComments; }
set
{
Guard.ArgumentNotNull(value, nameof(value));
reviewComments = value;
this.RaisePropertyChange();
}
}

IAccount assignee;
public IAccount Assignee
Expand Down
21 changes: 0 additions & 21 deletions src/GitHub.App/Models/PullRequestReviewCommentModel.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/GitHub.App/Models/PullRequestReviewModel.cs

This file was deleted.

26 changes: 13 additions & 13 deletions src/GitHub.App/SampleData/PullRequestDetailViewModelDesigner.cs
Expand Up @@ -35,13 +35,12 @@ public PullRequestDetailViewModelDesigner()
{
var repoPath = @"C:\Repo";

Model = new PullRequestModel(419,
"Error handling/bubbling from viewmodels to views to viewhosts",
new AccountDesigner { Login = "shana", IsUser = true },
DateTime.Now.Subtract(TimeSpan.FromDays(3)))
Model = new PullRequestDetailModel
{
State = PullRequestStateEnum.Open,
CommitCount = 9,
Number = 419,
Title = "Error handling/bubbling from viewmodels to views to viewhosts",
Author = new ActorModel { Login = "shana" },
UpdatedAt = DateTimeOffset.Now.Subtract(TimeSpan.FromDays(3)),
};

SourceBranchDisplayName = "shana/error-handling";
Expand Down Expand Up @@ -71,22 +70,22 @@ public PullRequestDetailViewModelDesigner()
{
new PullRequestReviewSummaryViewModel
{
Id = 2,
User = new AccountDesigner { Login = "grokys", IsUser = true },
Id = "id1",
User = new ActorViewModel { Login = "grokys" },
State = PullRequestReviewState.Pending,
FileCommentCount = 0,
},
new PullRequestReviewSummaryViewModel
{
Id = 1,
User = new AccountDesigner { Login = "jcansdale", IsUser = true },
Id = "id",
User = new ActorViewModel { Login = "jcansdale" },
State = PullRequestReviewState.Approved,
FileCommentCount = 5,
},
new PullRequestReviewSummaryViewModel
{
Id = 2,
User = new AccountDesigner { Login = "shana", IsUser = true },
Id = "id3",
User = new ActorViewModel { Login = "shana" },
State = PullRequestReviewState.ChangesRequested,
FileCommentCount = 5,
},
Expand All @@ -98,11 +97,12 @@ public PullRequestDetailViewModelDesigner()
Files = new PullRequestFilesViewModelDesigner();
}

public IPullRequestModel Model { get; }
public PullRequestDetailModel Model { get; }
public IPullRequestSession Session { get; }
public ILocalRepositoryModel LocalRepository { get; }
public string RemoteRepositoryOwner { get; }
public int Number { get; set; }
public IActorViewModel Author { get; set; }
public string SourceBranchDisplayName { get; set; }
public string TargetBranchDisplayName { get; set; }
public int CommentCount { get; set; }
Expand Down
Expand Up @@ -18,6 +18,7 @@ public class PullRequestListViewModelDesigner : PanePageViewModelBase, IPullRequ
public PullRequestListViewModelDesigner()
{
var prs = new TrackingCollection<IPullRequestModel>(Observable.Empty<IPullRequestModel>());

prs.Add(new PullRequestModel(399, "Let's try doing this differently",
new AccountDesigner { Login = "shana", IsUser = true },
DateTimeOffset.Now - TimeSpan.FromDays(1))
Expand Down Expand Up @@ -58,7 +59,7 @@ public PullRequestListViewModelDesigner()

public IReadOnlyList<IRemoteRepositoryModel> Repositories { get; }
public IRemoteRepositoryModel SelectedRepository { get; set; }
public IPullRequestModel CheckedOutPullRequest { get; set; }
public PullRequestDetailModel CheckedOutPullRequest { get; set; }
public ITrackingCollection<IPullRequestModel> PullRequests { get; set; }
public IPullRequestModel SelectedPullRequest { get; set; }

Expand Down
Expand Up @@ -12,11 +12,13 @@ public class PullRequestReviewAuthoringViewModelDesigner : PanePageViewModelBase
{
public PullRequestReviewAuthoringViewModelDesigner()
{
PullRequestModel = new PullRequestModel(
419,
"Fix a ton of potential crashers, odd code and redundant calls in ModelService",
new AccountDesigner { Login = "Haacked", IsUser = true },
DateTimeOffset.Now - TimeSpan.FromDays(2));
PullRequestModel = new PullRequestDetailModel
{
Number = 419,
Title = "Fix a ton of potential crashers, odd code and redundant calls in ModelService",
Author = new ActorModel { Login = "Haacked" },
UpdatedAt = DateTimeOffset.Now - TimeSpan.FromDays(2),
};

Files = new PullRequestFilesViewModelDesigner();

Expand All @@ -42,10 +44,10 @@ public PullRequestReviewAuthoringViewModelDesigner()
public IReadOnlyList<IPullRequestReviewFileCommentViewModel> FileComments { get; }
public IPullRequestFilesViewModel Files { get; }
public ILocalRepositoryModel LocalRepository { get; set; }
public IPullRequestReviewModel Model { get; set; }
public PullRequestReviewModel Model { get; set; }
public ReactiveCommand<object> NavigateToPullRequest { get; }
public string OperationError { get; set; }
public IPullRequestModel PullRequestModel { get; set; }
public PullRequestDetailModel PullRequestModel { get; set; }
public string RemoteRepositoryOwner { get; set; }
public ReactiveCommand<Unit> Approve { get; }
public ReactiveCommand<Unit> Comment { get; }
Expand Down
21 changes: 11 additions & 10 deletions src/GitHub.App/SampleData/PullRequestReviewViewModelDesigner.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using GitHub.Models;
using GitHub.ViewModels.GitHubPane;
using ReactiveUI;
Expand All @@ -13,17 +12,19 @@ public class PullRequestReviewViewModelDesigner : PanePageViewModelBase, IPullRe
{
public PullRequestReviewViewModelDesigner()
{
PullRequestModel = new PullRequestModel(
419,
"Fix a ton of potential crashers, odd code and redundant calls in ModelService",
new AccountDesigner { Login = "Haacked", IsUser = true },
DateTimeOffset.Now - TimeSpan.FromDays(2));
PullRequestModel = new PullRequestDetailModel
{
Number = 419,
Title = "Fix a ton of potential crashers, odd code and redundant calls in ModelService",
Author = new ActorModel { Login = "Haacked" },
UpdatedAt = DateTimeOffset.Now - TimeSpan.FromDays(2),
};

Model = new PullRequestReviewModel
{

SubmittedAt = DateTimeOffset.Now - TimeSpan.FromDays(1),
User = new AccountDesigner { Login = "Haacked", IsUser = true },
Author = new ActorModel { Login = "Haacked" },
};

Body = @"Just a few comments. I don't feel too strongly about them though.
Expand Down Expand Up @@ -63,10 +64,10 @@ public PullRequestReviewViewModelDesigner()
public bool IsExpanded { get; set; }
public bool HasDetails { get; set; }
public ILocalRepositoryModel LocalRepository { get; set; }
public IPullRequestReviewModel Model { get; set; }
public PullRequestReviewModel Model { get; set; }
public ReactiveCommand<object> NavigateToPullRequest { get; }
public IReadOnlyList<IPullRequestReviewFileCommentViewModel> OutdatedFileComments { get; set; }
public IPullRequestModel PullRequestModel { get; set; }
public PullRequestDetailModel PullRequestModel { get; set; }
public string RemoteRepositoryOwner { get; set; }
public string StateDisplay { get; set; }
}
Expand Down

0 comments on commit d5ddf0d

Please sign in to comment.