Example #1
0
        public PullRequestDetailViewModelDesigner()
        {
            var repoPath = @"C:\Repo";

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

            SourceBranchDisplayName = "shana/error-handling-a-ridiculously-long-branch-name-because-why-not";
            TargetBranchDisplayName = "master-is-always-stable";
            Body = @"Adds a way to surface errors from the view model to the view so that view hosts can get to them.

ViewModels are responsible for handling the UI on the view they control, but they shouldn't be handling UI for things outside of the view. In this case, we're showing errors in VS outside the view, and that should be handled by the section that is hosting the view.

This requires that errors be propagated from the viewmodel to the view and from there to the host via the IView interface, since hosts don't usually know what they're hosting.

![An image](https://cloud.githubusercontent.com/assets/1174461/18882991/5dd35648-8496-11e6-8735-82c3a182e8b4.png)";

            var gitHubDir       = new PullRequestDirectoryNode("GitHub");
            var modelsDir       = new PullRequestDirectoryNode("Models");
            var repositoriesDir = new PullRequestDirectoryNode("Repositories");
            var itrackingBranch = new PullRequestFileNode(repoPath, @"GitHub\Models\ITrackingBranch.cs", "abc", PullRequestFileStatus.Modified, null);
            var oldBranchModel  = new PullRequestFileNode(repoPath, @"GitHub\Models\OldBranchModel.cs", "abc", PullRequestFileStatus.Removed, null);
            var concurrentRepositoryConnection = new PullRequestFileNode(repoPath, @"GitHub\Repositories\ConcurrentRepositoryConnection.cs", "abc", PullRequestFileStatus.Added, "add");

            repositoriesDir.Files.Add(concurrentRepositoryConnection);
            modelsDir.Directories.Add(repositoriesDir);
            modelsDir.Files.Add(itrackingBranch);
            modelsDir.Files.Add(oldBranchModel);
            gitHubDir.Directories.Add(modelsDir);

            ChangedFilesTree = new ReactiveList <IPullRequestChangeNode>();
            ChangedFilesTree.Add(gitHubDir);

            ChangedFilesList = new ReactiveList <IPullRequestFileNode>();
            ChangedFilesList.Add(concurrentRepositoryConnection);
            ChangedFilesList.Add(itrackingBranch);
            ChangedFilesList.Add(oldBranchModel);
        }
        public PullRequestDetailViewModelDesigner()
        {
            var repoPath = @"C:\Repo";

            Model = new PullRequestDetailModel
            {
                Number = 419,
                Title  = "Error handling/bubbling from viewmodels to views to viewhosts",
                Author = new ActorModel {
                    Login = "******"
                },
                UpdatedAt = DateTimeOffset.Now.Subtract(TimeSpan.FromDays(3)),
            };

            SourceBranchDisplayName = "shana/error-handling";
            TargetBranchDisplayName = "master";
            Body = @"Adds a way to surface errors from the view model to the view so that view hosts can get to them.

ViewModels are responsible for handling the UI on the view they control, but they shouldn't be handling UI for things outside of the view. In this case, we're showing errors in VS outside the view, and that should be handled by the section that is hosting the view.

This requires that errors be propagated from the viewmodel to the view and from there to the host via the IView interface, since hosts don't usually know what they're hosting.

![An image](https://cloud.githubusercontent.com/assets/1174461/18882991/5dd35648-8496-11e6-8735-82c3a182e8b4.png)";

            var gitHubDir       = new PullRequestDirectoryNode("GitHub");
            var modelsDir       = new PullRequestDirectoryNode("Models");
            var repositoriesDir = new PullRequestDirectoryNode("Repositories");
            var itrackingBranch = new PullRequestFileNode(repoPath, @"GitHub\Models\ITrackingBranch.cs", "abc", PullRequestFileStatus.Modified, null);
            var oldBranchModel  = new PullRequestFileNode(repoPath, @"GitHub\Models\OldBranchModel.cs", "abc", PullRequestFileStatus.Removed, null);
            var concurrentRepositoryConnection = new PullRequestFileNode(repoPath, @"GitHub\Repositories\ConcurrentRepositoryConnection.cs", "abc", PullRequestFileStatus.Added, null);

            repositoriesDir.Files.Add(concurrentRepositoryConnection);
            modelsDir.Directories.Add(repositoriesDir);
            modelsDir.Files.Add(itrackingBranch);
            modelsDir.Files.Add(oldBranchModel);
            gitHubDir.Directories.Add(modelsDir);

            Reviews = new[]
            {
                new PullRequestReviewSummaryViewModel
                {
                    Id   = "id1",
                    User = new ActorViewModel {
                        Login = "******"
                    },
                    State            = PullRequestReviewState.Pending,
                    FileCommentCount = 0,
                },
                new PullRequestReviewSummaryViewModel
                {
                    Id   = "id",
                    User = new ActorViewModel {
                        Login = "******"
                    },
                    State            = PullRequestReviewState.Approved,
                    FileCommentCount = 5,
                },
                new PullRequestReviewSummaryViewModel
                {
                    Id   = "id3",
                    User = new ActorViewModel {
                        Login = "******"
                    },
                    State            = PullRequestReviewState.ChangesRequested,
                    FileCommentCount = 5,
                },
                new PullRequestReviewSummaryViewModel
                {
                },
            };

            Files = new PullRequestFilesViewModelDesigner();

            Checks = Array.Empty <PullRequestCheckViewModelDesigner>();
        }