public InlineCommentMargin( IWpfTextViewHost wpfTextViewHost, IInlineCommentPeekService peekService, IEditorFormatMapService editorFormatMapService, IViewTagAggregatorFactoryService tagAggregatorFactory, Lazy <IPullRequestSessionManager> sessionManager) { textView = wpfTextViewHost.TextView; this.sessionManager = sessionManager.Value; // Default to not show comment margin textView.Options.SetOptionValue(InlineCommentTextViewOptions.MarginEnabledId, false); marginGrid = new GlyphMarginGrid { Width = 17.0 }; var glyphFactory = new InlineCommentGlyphFactory(peekService, textView); var editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView); glyphMargin = new GlyphMargin <InlineCommentTag>(textView, glyphFactory, marginGrid, tagAggregatorFactory, editorFormatMap, MarginPropertiesName); if (IsDiffView()) { TrackCommentGlyph(wpfTextViewHost, marginGrid); } currentSessionSubscription = this.sessionManager.WhenAnyValue(x => x.CurrentSession) .Subscribe(x => RefreshCurrentSession().Forget()); visibleSubscription = marginGrid.WhenAnyValue(x => x.IsVisible) .Subscribe(x => textView.Options.SetOptionValue(InlineCommentTextViewOptions.MarginVisibleId, x)); textView.Options.OptionChanged += (s, e) => RefreshMarginVisibility(); }
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 Tuple <PullRequestDetailViewModel, IPullRequestService> CreateTargetAndService( string currentBranch = "master", string existingPrBranch = null, bool prFromFork = false, bool dirty = false, int aheadBy = 0, int behindBy = 0, IPullRequestSessionManager sessionManager = null) { var repository = Substitute.For <ILocalRepositoryModel>(); var currentBranchModel = new BranchModel(currentBranch, repository); repository.CurrentBranch.Returns(currentBranchModel); repository.CloneUrl.Returns(new UriString(Uri.ToString())); repository.LocalPath.Returns(@"C:\projects\ThisRepo"); repository.Name.Returns("repo"); var pullRequestService = Substitute.For <IPullRequestService>(); if (existingPrBranch != null) { var existingBranchModel = new BranchModel(existingPrBranch, repository); pullRequestService.GetLocalBranches(repository, Arg.Any <IPullRequestModel>()) .Returns(Observable.Return(existingBranchModel)); } else { pullRequestService.GetLocalBranches(repository, Arg.Any <IPullRequestModel>()) .Returns(Observable.Empty <IBranch>()); } pullRequestService.Checkout(repository, Arg.Any <IPullRequestModel>(), Arg.Any <string>()).Returns(x => Throws("Checkout threw")); pullRequestService.GetDefaultLocalBranchName(repository, Arg.Any <int>(), Arg.Any <string>()).Returns(x => Observable.Return($"pr/{x[1]}")); pullRequestService.IsPullRequestFromRepository(repository, Arg.Any <IPullRequestModel>()).Returns(!prFromFork); pullRequestService.IsWorkingDirectoryClean(repository).Returns(Observable.Return(!dirty)); pullRequestService.Pull(repository).Returns(x => Throws("Pull threw")); pullRequestService.Push(repository).Returns(x => Throws("Push threw")); pullRequestService.SwitchToBranch(repository, Arg.Any <IPullRequestModel>()) .Returns( x => Throws("Switch threw"), _ => Observable.Return(Unit.Default)); var divergence = Substitute.For <BranchTrackingDetails>(); divergence.AheadBy.Returns(aheadBy); divergence.BehindBy.Returns(behindBy); pullRequestService.CalculateHistoryDivergence(repository, Arg.Any <int>()) .Returns(Observable.Return(divergence)); var vm = new PullRequestDetailViewModel( pullRequestService, sessionManager ?? Substitute.For <IPullRequestSessionManager>(), Substitute.For <IModelServiceFactory>(), Substitute.For <IUsageTracker>(), Substitute.For <IVSGitExt>()); vm.InitializeAsync(repository, Substitute.For <IConnection>(), "owner", "repo", 1).Wait(); return(Tuple.Create(vm, pullRequestService)); }
/// <summary> /// Initializes a new instance of the <see cref="InlineCommentPeekViewModel"/> class. /// </summary> public InlineCommentPeekViewModel( IInlineCommentPeekService peekService, IPeekSession peekSession, IPullRequestSessionManager sessionManager, INextInlineCommentCommand nextCommentCommand, IPreviousInlineCommentCommand previousCommentCommand) { Guard.ArgumentNotNull(peekService, nameof(peekService)); Guard.ArgumentNotNull(peekSession, nameof(peekSession)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); Guard.ArgumentNotNull(nextCommentCommand, nameof(nextCommentCommand)); Guard.ArgumentNotNull(previousCommentCommand, nameof(previousCommentCommand)); this.peekService = peekService; this.peekSession = peekSession; this.sessionManager = sessionManager; triggerPoint = peekSession.GetTriggerPoint(peekSession.TextView.TextBuffer); peekSession.Dismissed += (s, e) => Dispose(); NextComment = ReactiveCommand.CreateAsyncTask( Observable.Return(nextCommentCommand.Enabled), _ => nextCommentCommand.Execute(new InlineCommentNavigationParams { FromLine = peekService.GetLineNumber(peekSession, triggerPoint).Item1, })); PreviousComment = ReactiveCommand.CreateAsyncTask( Observable.Return(previousCommentCommand.Enabled), _ => previousCommentCommand.Execute(new InlineCommentNavigationParams { FromLine = peekService.GetLineNumber(peekSession, triggerPoint).Item1, })); }
public InlineCommentTaggerProvider( IPullRequestSessionManager sessionManager) { Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); this.sessionManager = sessionManager; }
public PullRequestPageViewModel( IViewViewModelFactory factory, IPullRequestService service, IPullRequestSessionManager sessionManager, ITeamExplorerServices teServices, IVisualStudioBrowser visualStudioBrowser, IUsageTracker usageTracker) { Guard.ArgumentNotNull(factory, nameof(factory)); Guard.ArgumentNotNull(service, nameof(service)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); Guard.ArgumentNotNull(visualStudioBrowser, nameof(visualStudioBrowser)); Guard.ArgumentNotNull(teServices, nameof(teServices)); this.factory = factory; this.service = service; this.sessionManager = sessionManager; this.teServices = teServices; this.visualStudioBrowser = visualStudioBrowser; this.usageTracker = usageTracker; timeline.ItemsRemoved.Subscribe(TimelineItemRemoved); ShowCommit = ReactiveCommand.CreateFromTask <string>(DoShowCommit); OpenOnGitHub = ReactiveCommand.Create(DoOpenOnGitHub); }
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 PullRequestFileMargin( IWpfTextView textView, IToggleInlineCommentMarginCommand toggleInlineCommentMarginCommand, IGoToSolutionOrPullRequestFileCommand goToSolutionOrPullRequestFileCommand, IPullRequestSessionManager sessionManager, Lazy <IUsageTracker> usageTracker) { this.textView = textView; this.sessionManager = sessionManager; viewModel = new PullRequestFileMarginViewModel(toggleInlineCommentMarginCommand, goToSolutionOrPullRequestFileCommand, usageTracker); visualElement = new PullRequestFileMarginView { DataContext = viewModel, ClipToBounds = true }; visibilitySubscription = viewModel.WhenAnyValue(x => x.Enabled).Subscribe(enabled => { visualElement.Visibility = enabled ? Visibility.Visible : Visibility.Collapsed; }); optionChangedSubscription = Observable.FromEventPattern(textView.Options, nameof(textView.Options.OptionChanged)).Subscribe(_ => { viewModel.MarginEnabled = textView.Options.GetOptionValue(InlineCommentTextViewOptions.MarginEnabledId); }); currentSessionSubscription = sessionManager.WhenAnyValue(x => x.CurrentSession) .Subscribe(x => RefreshCurrentSession().Forget()); }
public ShowPullRequestCommentsCommand( IApiClientFactory apiClientFactory, IPullRequestSessionManager sessionManager) : base(CommandSet, CommandId) { this.apiClientFactory = apiClientFactory; this.sessionManager = sessionManager; }
public PullRequestDetailViewModel( IPullRequestService pullRequestsService, IPullRequestSessionManager sessionManager, IModelServiceFactory modelServiceFactory, IUsageTracker usageTracker, ITeamExplorerContext teamExplorerContext, IStatusBarNotificationService statusBarNotificationService) { 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(statusBarNotificationService, nameof(statusBarNotificationService)); this.pullRequestsService = pullRequestsService; this.sessionManager = sessionManager; this.modelServiceFactory = modelServiceFactory; this.usageTracker = usageTracker; this.teamExplorerContext = teamExplorerContext; this.statusBarNotificationService = statusBarNotificationService; 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(); DiffFile = ReactiveCommand.Create(); DiffFileWithWorkingDirectory = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsCheckedOut)); OpenFileInWorkingDirectory = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsCheckedOut)); ViewFile = ReactiveCommand.Create(); }
public PullRequestAnnotationsViewModel(IPullRequestSessionManager sessionManager, IPullRequestEditorService pullRequestEditorService) { this.sessionManager = sessionManager; this.pullRequestEditorService = pullRequestEditorService; NavigateToPullRequest = ReactiveCommand.Create(() => { NavigateTo(FormattableString.Invariant( $"{LocalRepository.Owner}/{LocalRepository.Name}/pull/{PullRequestNumber}")); }); }
public PullRequestReviewAuthoringViewModel( IPullRequestService pullRequestService, IPullRequestEditorService editorService, IPullRequestSessionManager sessionManager, IMessageDraftStore draftStore, IPullRequestFilesViewModel files) : this(pullRequestService, editorService, sessionManager, draftStore, files, DefaultScheduler.Instance) { }
public IssueishPaneViewModel( IViewViewModelFactory factory, IPullRequestSessionManager sessionManager) { Guard.ArgumentNotNull(factory, nameof(factory)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); this.factory = factory; this.sessionManager = sessionManager; }
public InlineCommentPeekableItemSource( IInlineCommentPeekService peekService, IPullRequestSessionManager sessionManager, INextInlineCommentCommand nextCommentCommand, IPreviousInlineCommentCommand previousCommentCommand) { this.peekService = peekService; this.sessionManager = sessionManager; this.nextCommentCommand = nextCommentCommand; this.previousCommentCommand = previousCommentCommand; }
PullRequestUserReviewsViewModel CreateTarget( IPullRequestEditorService editorService = null, IPullRequestSessionManager sessionManager = null) { editorService = editorService ?? Substitute.For <IPullRequestEditorService>(); sessionManager = sessionManager ?? CreateSessionManager(); return(new PullRequestUserReviewsViewModel( editorService, sessionManager)); }
public InlineCommentMarginProvider( IEditorFormatMapService editorFormatMapService, IViewTagAggregatorFactoryService tagAggregatorFactory, IInlineCommentPeekService peekService, IPullRequestSessionManager sessionManager) { this.editorFormatMapService = editorFormatMapService; this.tagAggregatorFactory = tagAggregatorFactory; this.peekService = peekService; this.sessionManager = sessionManager; }
public InlineCommentTagger( ITextView view, ITextBuffer buffer, IPullRequestSessionManager sessionManager) { Guard.ArgumentNotNull(buffer, nameof(buffer)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); this.buffer = buffer; this.view = view; this.sessionManager = sessionManager; }
static async Task <PullRequestListViewModel> CreateTargetAndInitialize( IPullRequestSessionManager sessionManager = null, IRepositoryService repositoryService = null, IPullRequestService service = null, ILocalRepositoryModel repository = null, IConnection connection = null) { var result = CreateTarget(sessionManager, repositoryService, service); await result.InitializeAsync(repository, connection); return(result); }
PullRequestDetailViewModel( IConnectionRepositoryHostMap connectionRepositoryHostMap, ITeamExplorerServiceHolder teservice, IPullRequestService pullRequestsService, IPullRequestSessionManager sessionManager, IUsageTracker usageTracker) : this(teservice.ActiveRepo, connectionRepositoryHostMap.CurrentRepositoryHost.ModelService, pullRequestsService, sessionManager, usageTracker) { }
/// <summary> /// Start showing the PR for the active branch on the status bar. /// </summary> /// <remarks> /// This must be called from the Main thread. /// </remarks> public void StartShowingStatus() { try { pullRequestSessionManager = serviceProvider.GetService <IPullRequestSessionManager>(); pullRequestSessionManager.WhenAnyValue(x => x.CurrentSession) .Subscribe(x => RefreshCurrentSession()); } catch (Exception e) { log.Error(e, "Error initializing"); } }
public InlineCommentPeekableItemSourceProvider( IApiClientFactory apiClientFactory, IInlineCommentPeekService peekService, IPullRequestSessionManager sessionManager, INextInlineCommentCommand nextCommentCommand, IPreviousInlineCommentCommand previousCommentCommand) { this.apiClientFactory = apiClientFactory; this.peekService = peekService; this.sessionManager = sessionManager; this.nextCommentCommand = nextCommentCommand; this.previousCommentCommand = previousCommentCommand; }
public PullRequestUserReviewsViewModel( IPullRequestEditorService editorService, IPullRequestSessionManager sessionManager) { Guard.ArgumentNotNull(editorService, nameof(editorService)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); this.editorService = editorService; this.sessionManager = sessionManager; NavigateToPullRequest = ReactiveCommand.Create(() => NavigateTo(Invariant($"{LocalRepository.Owner}/{LocalRepository.Name}/pull/{PullRequestNumber}"))); }
public InlineCommentPeekableItemSourceProvider( IInlineCommentPeekService peekService, IPullRequestSessionManager sessionManager, INextInlineCommentCommand nextCommentCommand, IPreviousInlineCommentCommand previousCommentCommand, IViewViewModelFactory factory) { this.peekService = peekService; this.sessionManager = sessionManager; this.nextCommentCommand = nextCommentCommand; this.previousCommentCommand = previousCommentCommand; this.factory = factory; }
public PullRequestFileMarginProvider( IToggleInlineCommentMarginCommand enableInlineCommentsCommand, IGoToSolutionOrPullRequestFileCommand goToSolutionOrPullRequestFileCommand, IPullRequestSessionManager sessionManager, IPackageSettings packageSettings, Lazy <IUsageTracker> usageTracker) { this.enableInlineCommentsCommand = enableInlineCommentsCommand; this.goToSolutionOrPullRequestFileCommand = goToSolutionOrPullRequestFileCommand; this.sessionManager = sessionManager; this.packageSettings = packageSettings; this.usageTracker = usageTracker; }
static PullRequestListViewModel CreateTarget( IPullRequestSessionManager sessionManager = null, IRepositoryService repositoryService = null, IPullRequestService service = null) { sessionManager = sessionManager ?? CreateSessionManager(); repositoryService = repositoryService ?? CreateRepositoryService(); service = service ?? CreatePullRequestService(); return(new PullRequestListViewModel( sessionManager, repositoryService, service)); }
PullRequestDetailViewModel( IGlobalConnection connection, IModelServiceFactory modelServiceFactory, ITeamExplorerServiceHolder teservice, IPullRequestService pullRequestsService, IPullRequestSessionManager sessionManager, IUsageTracker usageTracker) : this(teservice.ActiveRepo, modelServiceFactory.CreateBlocking(connection.Get()), pullRequestsService, sessionManager, usageTracker) { }
PullRequestUserReviewsViewModel CreateTarget( IPullRequestEditorService editorService = null, IPullRequestSessionManager sessionManager = null, IModelServiceFactory modelServiceFactory = null) { editorService = editorService ?? Substitute.For <IPullRequestEditorService>(); sessionManager = sessionManager ?? Substitute.For <IPullRequestSessionManager>(); modelServiceFactory = modelServiceFactory ?? Substitute.For <IModelServiceFactory>(); return(new PullRequestUserReviewsViewModel( editorService, sessionManager, modelServiceFactory)); }
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 InlineCommentTaggerProvider( IGitService gitService, IGitClient gitClient, IDiffService diffService, IPullRequestSessionManager sessionManager) { Guard.ArgumentNotNull(gitService, nameof(gitService)); Guard.ArgumentNotNull(gitClient, nameof(gitClient)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); this.gitService = gitService; this.gitClient = gitClient; this.diffService = diffService; this.sessionManager = sessionManager; }
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}"))); }