public PullRequestDetailViewModel( IPullRequestService pullRequestsService, IPullRequestSessionManager sessionManager, IModelServiceFactory modelServiceFactory, IUsageTracker usageTracker, ITeamExplorerContext teamExplorerContext, IPullRequestFilesViewModel files, ISyncSubmodulesCommand syncSubmodulesCommand, IViewViewModelFactory viewViewModelFactory) { Guard.ArgumentNotNull(pullRequestsService, nameof(pullRequestsService)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory)); Guard.ArgumentNotNull(usageTracker, nameof(usageTracker)); Guard.ArgumentNotNull(teamExplorerContext, nameof(teamExplorerContext)); Guard.ArgumentNotNull(syncSubmodulesCommand, nameof(syncSubmodulesCommand)); Guard.ArgumentNotNull(viewViewModelFactory, nameof(viewViewModelFactory)); this.pullRequestsService = pullRequestsService; this.sessionManager = sessionManager; this.modelServiceFactory = modelServiceFactory; this.usageTracker = usageTracker; this.teamExplorerContext = teamExplorerContext; this.syncSubmodulesCommand = syncSubmodulesCommand; this.viewViewModelFactory = viewViewModelFactory; Files = files; Checkout = ReactiveCommand.CreateAsyncObservable( this.WhenAnyValue(x => x.CheckoutState) .Cast <CheckoutCommandState>() .Select(x => x != null && x.IsEnabled), DoCheckout); Checkout.IsExecuting.Subscribe(x => isInCheckout = x); SubscribeOperationError(Checkout); Pull = ReactiveCommand.CreateAsyncObservable( this.WhenAnyValue(x => x.UpdateState) .Cast <UpdateCommandState>() .Select(x => x != null && x.PullEnabled), DoPull); SubscribeOperationError(Pull); Push = ReactiveCommand.CreateAsyncObservable( this.WhenAnyValue(x => x.UpdateState) .Cast <UpdateCommandState>() .Select(x => x != null && x.PushEnabled), DoPush); SubscribeOperationError(Push); SyncSubmodules = ReactiveCommand.CreateAsyncTask( this.WhenAnyValue(x => x.UpdateState) .Cast <UpdateCommandState>() .Select(x => x != null && x.SyncSubmodulesEnabled), DoSyncSubmodules); SyncSubmodules.Subscribe(_ => Refresh().ToObservable()); SubscribeOperationError(SyncSubmodules); OpenOnGitHub = ReactiveCommand.Create(); ShowReview = ReactiveCommand.Create().OnExecuteCompleted(DoShowReview); }
static PullRequestReviewAuthoringViewModel CreateTarget( IPullRequestService pullRequestService = null, IPullRequestEditorService editorService = null, IPullRequestSessionManager sessionManager = null, IMessageDraftStore draftStore = null, IPullRequestFilesViewModel files = null, IScheduler timerScheduler = null, IAutoCompleteAdvisor autoCompleteAdvisor = null ) { editorService = editorService ?? Substitute.For <IPullRequestEditorService>(); sessionManager = sessionManager ?? CreateSessionManager(); draftStore = draftStore ?? Substitute.For <IMessageDraftStore>(); files = files ?? Substitute.For <IPullRequestFilesViewModel>(); autoCompleteAdvisor = autoCompleteAdvisor ?? Substitute.For <IAutoCompleteAdvisor>(); timerScheduler = timerScheduler ?? DefaultScheduler.Instance; return(new PullRequestReviewAuthoringViewModel( pullRequestService, editorService, sessionManager, draftStore, files, autoCompleteAdvisor, timerScheduler)); }
public PullRequestReviewAuthoringViewModel( IPullRequestService pullRequestService, IPullRequestEditorService editorService, IPullRequestSessionManager sessionManager, IMessageDraftStore draftStore, IPullRequestFilesViewModel files) : this(pullRequestService, editorService, sessionManager, draftStore, files, DefaultScheduler.Instance) { }
static PullRequestReviewAuthoringViewModel CreateTarget( IPullRequestEditorService editorService = null, IPullRequestSessionManager sessionManager = null, IPullRequestFilesViewModel files = null) { editorService = editorService ?? Substitute.For <IPullRequestEditorService>(); sessionManager = sessionManager ?? CreateSessionManager(); files = files ?? Substitute.For <IPullRequestFilesViewModel>(); return(new PullRequestReviewAuthoringViewModel( editorService, sessionManager, files)); }
public PullRequestReviewAuthoringViewModel( IPullRequestService pullRequestService, IPullRequestEditorService editorService, IPullRequestSessionManager sessionManager, IMessageDraftStore draftStore, IPullRequestFilesViewModel files, IAutoCompleteAdvisor autoCompleteAdvisor, IScheduler timerScheduler) { Guard.ArgumentNotNull(editorService, nameof(editorService)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); Guard.ArgumentNotNull(draftStore, nameof(draftStore)); Guard.ArgumentNotNull(files, nameof(files)); Guard.ArgumentNotNull(autoCompleteAdvisor, nameof(autoCompleteAdvisor)); Guard.ArgumentNotNull(timerScheduler, nameof(timerScheduler)); this.pullRequestService = pullRequestService; this.editorService = editorService; this.sessionManager = sessionManager; this.draftStore = draftStore; this.timerScheduler = timerScheduler; canApproveRequestChanges = this.WhenAnyValue( x => x.Model, x => x.PullRequestModel, (review, pr) => review != null && pr != null && review.Author.Login != pr.Author.Login) .ToProperty(this, x => x.CanApproveRequestChanges); Files = files; AutoCompleteAdvisor = autoCompleteAdvisor; var hasBodyOrComments = this.WhenAnyValue( x => x.Body, x => x.FileComments.Count, (body, comments) => !string.IsNullOrWhiteSpace(body) || comments > 0); Approve = ReactiveCommand.CreateFromTask(() => DoSubmit(Octokit.PullRequestReviewEvent.Approve)); Comment = ReactiveCommand.CreateFromTask( () => DoSubmit(Octokit.PullRequestReviewEvent.Comment), hasBodyOrComments); RequestChanges = ReactiveCommand.CreateFromTask( () => DoSubmit(Octokit.PullRequestReviewEvent.RequestChanges), hasBodyOrComments); Cancel = ReactiveCommand.CreateFromTask(DoCancel); NavigateToPullRequest = ReactiveCommand.Create(() => NavigateTo(Invariant($"{RemoteRepositoryOwner}/{LocalRepository.Name}/pull/{PullRequestModel.Number}"))); }
public PullRequestReviewAuthoringViewModel( IPullRequestEditorService editorService, IPullRequestSessionManager sessionManager, IModelServiceFactory modelServiceFactory, IPullRequestFilesViewModel files) { Guard.ArgumentNotNull(editorService, nameof(editorService)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory)); Guard.ArgumentNotNull(files, nameof(files)); this.editorService = editorService; this.sessionManager = sessionManager; this.modelServiceFactory = modelServiceFactory; canApproveRequestChanges = this.WhenAnyValue( x => x.Model, x => x.PullRequestModel, (review, pr) => review != null && pr != null && review.User.Login != pr.Author.Login) .ToProperty(this, x => x.CanApproveRequestChanges); Files = files; var hasBodyOrComments = this.WhenAnyValue( x => x.Body, x => x.FileComments.Count, (body, comments) => !string.IsNullOrWhiteSpace(body) || comments > 0); Approve = ReactiveCommand.CreateAsyncTask(_ => DoSubmit(Octokit.PullRequestReviewEvent.Approve)); Comment = ReactiveCommand.CreateAsyncTask( hasBodyOrComments, _ => DoSubmit(Octokit.PullRequestReviewEvent.Comment)); RequestChanges = ReactiveCommand.CreateAsyncTask( hasBodyOrComments, _ => DoSubmit(Octokit.PullRequestReviewEvent.RequestChanges)); Cancel = ReactiveCommand.CreateAsyncTask(DoCancel); NavigateToPullRequest = ReactiveCommand.Create().OnExecuteCompleted(_ => NavigateTo(Invariant($"{LocalRepository.Owner}/{LocalRepository.Name}/pull/{PullRequestModel.Number}"))); }
public PullRequestDetailViewModel( IPullRequestService pullRequestsService, IPullRequestSessionManager sessionManager, IModelServiceFactory modelServiceFactory, IUsageTracker usageTracker, ITeamExplorerContext teamExplorerContext, IPullRequestFilesViewModel files, ISyncSubmodulesCommand syncSubmodulesCommand, IViewViewModelFactory viewViewModelFactory, IGitService gitService, IOpenIssueishDocumentCommand openDocumentCommand, [Import(AllowDefault = true)] JoinableTaskContext joinableTaskContext) { Guard.ArgumentNotNull(pullRequestsService, nameof(pullRequestsService)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory)); Guard.ArgumentNotNull(usageTracker, nameof(usageTracker)); Guard.ArgumentNotNull(teamExplorerContext, nameof(teamExplorerContext)); Guard.ArgumentNotNull(syncSubmodulesCommand, nameof(syncSubmodulesCommand)); Guard.ArgumentNotNull(viewViewModelFactory, nameof(viewViewModelFactory)); Guard.ArgumentNotNull(gitService, nameof(gitService)); Guard.ArgumentNotNull(openDocumentCommand, nameof(openDocumentCommand)); this.pullRequestsService = pullRequestsService; this.sessionManager = sessionManager; this.modelServiceFactory = modelServiceFactory; this.usageTracker = usageTracker; this.teamExplorerContext = teamExplorerContext; this.syncSubmodulesCommand = syncSubmodulesCommand; this.viewViewModelFactory = viewViewModelFactory; this.gitService = gitService; this.openDocumentCommand = openDocumentCommand; JoinableTaskContext = joinableTaskContext ?? ThreadHelper.JoinableTaskContext; Files = files; Checkout = ReactiveCommand.CreateFromObservable( DoCheckout, this.WhenAnyValue(x => x.CheckoutState) .Cast <CheckoutCommandState>() .Select(x => x != null && x.IsEnabled)); Checkout.IsExecuting.Subscribe(x => isInCheckout = x); SubscribeOperationError(Checkout); Pull = ReactiveCommand.CreateFromObservable( DoPull, this.WhenAnyValue(x => x.UpdateState) .Cast <UpdateCommandState>() .Select(x => x != null && x.PullEnabled)); SubscribeOperationError(Pull); Push = ReactiveCommand.CreateFromObservable( DoPush, this.WhenAnyValue(x => x.UpdateState) .Cast <UpdateCommandState>() .Select(x => x != null && x.PushEnabled)); SubscribeOperationError(Push); SyncSubmodules = ReactiveCommand.CreateFromTask( DoSyncSubmodules, this.WhenAnyValue(x => x.UpdateState) .Cast <UpdateCommandState>() .Select(x => x != null && x.SyncSubmodulesEnabled)); SyncSubmodules.Subscribe(_ => Refresh().ToObservable()); SubscribeOperationError(SyncSubmodules); OpenConversation = ReactiveCommand.Create(DoOpenConversation); OpenOnGitHub = ReactiveCommand.Create(DoOpenDetailsUrl); ShowReview = ReactiveCommand.Create <IPullRequestReviewSummaryViewModel>(DoShowReview); ShowAnnotations = ReactiveCommand.Create <IPullRequestCheckViewModel>(DoShowAnnotations); }