diff --git a/src/GitHub.Exports/Settings/generated/IPackageSettings.cs b/src/GitHub.Exports/Settings/generated/IPackageSettings.cs index 258896c409..81e7309778 100644 --- a/src/GitHub.Exports/Settings/generated/IPackageSettings.cs +++ b/src/GitHub.Exports/Settings/generated/IPackageSettings.cs @@ -7,11 +7,6 @@ "type": "bool", "default": 'true' }, - { - "name": "EditorComments", - "type": "bool", - "default": "false" - }, { "name": "UIState", "type": "object", @@ -40,7 +35,6 @@ public interface IPackageSettings : INotifyPropertyChanged { void Save(); bool CollectMetrics { get; set; } - bool EditorComments { get; set; } UIState UIState { get; set; } bool HideTeamExplorerWelcomeMessage { get; set; } bool EnableTraceLogging { get; set; } diff --git a/src/GitHub.InlineReviews/GitHub.InlineReviews.csproj b/src/GitHub.InlineReviews/GitHub.InlineReviews.csproj index 314d26ae3d..12ca598f0e 100644 --- a/src/GitHub.InlineReviews/GitHub.InlineReviews.csproj +++ b/src/GitHub.InlineReviews/GitHub.InlineReviews.csproj @@ -61,8 +61,6 @@ - - @@ -97,12 +95,8 @@ ShowInlineCommentAnnotationGlyph.xaml - - - PullRequestFileMarginView.xaml - GlyphMarginGrid.xaml @@ -251,10 +245,6 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - Designer MSBuild:Compile diff --git a/src/GitHub.InlineReviews/Margins/PullRequestFileMargin.cs b/src/GitHub.InlineReviews/Margins/PullRequestFileMargin.cs deleted file mode 100644 index c46311bc0a..0000000000 --- a/src/GitHub.InlineReviews/Margins/PullRequestFileMargin.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using System.IO; -using System.Windows; -using System.Threading.Tasks; -using System.Reactive.Linq; -using GitHub.Models; -using GitHub.Commands; -using GitHub.Services; -using GitHub.Extensions; -using GitHub.InlineReviews.Views; -using GitHub.InlineReviews.ViewModels; -using Microsoft.VisualStudio.Text.Editor; -using ReactiveUI; -using Task = System.Threading.Tasks.Task; - -namespace GitHub.InlineReviews.Margins -{ - /// - /// This margin appears on solution files that have a corresponding PR file (file with changes in current PR). - /// - internal class PullRequestFileMargin : IWpfTextViewMargin - { - public const string MarginName = "PullRequestFileMargin"; - - readonly IWpfTextView textView; - readonly PullRequestFileMarginViewModel viewModel; - readonly PullRequestFileMarginView visualElement; - readonly IPullRequestSessionManager sessionManager; - - bool isDisposed; - - IDisposable currentSessionSubscription; - IDisposable optionChangedSubscription; - IDisposable visibilitySubscription; - - public PullRequestFileMargin( - IWpfTextView textView, - IToggleInlineCommentMarginCommand toggleInlineCommentMarginCommand, - IGoToSolutionOrPullRequestFileCommand goToSolutionOrPullRequestFileCommand, - IPullRequestSessionManager sessionManager, - Lazy 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 void Dispose() - { - if (!isDisposed) - { - GC.SuppressFinalize(this); - isDisposed = true; - - currentSessionSubscription.Dispose(); - optionChangedSubscription.Dispose(); - visibilitySubscription.Dispose(); - } - } - - async Task RefreshCurrentSession() - { - var sessionFile = await FindSessionFile(); - if (sessionFile != null) - { - viewModel.FileName = Path.GetFileName(sessionFile.RelativePath); - viewModel.CommentsInFile = sessionFile.InlineCommentThreads?.Count ?? -1; - viewModel.Enabled = sessionFile.Diff.Count > 0; - } - else - { - viewModel.CommentsInFile = 0; - viewModel.Enabled = false; - } - } - - async Task FindSessionFile() - { - await sessionManager.EnsureInitialized(); - - var session = sessionManager.CurrentSession; - if (session == null) - { - return null; - } - - var relativePath = sessionManager.GetRelativePath(textView.TextBuffer); - if (relativePath == null) - { - return null; - } - - return await session.GetFile(relativePath); - } - - public FrameworkElement VisualElement => visualElement; - - public double MarginSize => visualElement.ActualHeight; - - public bool Enabled => viewModel.Enabled; - - public ITextViewMargin GetTextViewMargin(string marginName) - { - return string.Equals(marginName, MarginName, StringComparison.OrdinalIgnoreCase) ? this : null; - } - } -} diff --git a/src/GitHub.InlineReviews/Margins/PullRequestFileMarginProvider.cs b/src/GitHub.InlineReviews/Margins/PullRequestFileMarginProvider.cs deleted file mode 100644 index 65ddccfe3c..0000000000 --- a/src/GitHub.InlineReviews/Margins/PullRequestFileMarginProvider.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.ComponentModel.Composition; -using GitHub.Commands; -using GitHub.Services; -using GitHub.Settings; -using GitHub.VisualStudio; -using Microsoft.VisualStudio.Shell; -using Microsoft.VisualStudio.Utilities; -using Microsoft.VisualStudio.Text.Editor; - -namespace GitHub.InlineReviews.Margins -{ - /// - /// Export a , which returns an instance of the margin for the editor to use. - /// - [Export(typeof(IWpfTextViewMarginProvider))] - [Name(PullRequestFileMargin.MarginName)] - [Order(After = PredefinedMarginNames.ZoomControl)] - [MarginContainer(PredefinedMarginNames.BottomControl)] // Set the container to the bottom of the editor window - [ContentType("text")] // Show this margin for all text-based types - [TextViewRole(PredefinedTextViewRoles.Editable)] - internal sealed class PullRequestFileMarginProvider : IWpfTextViewMarginProvider - { - readonly Lazy sessionManager; - readonly Lazy enableInlineCommentsCommand; - readonly Lazy goToSolutionOrPullRequestFileCommand; - readonly Lazy packageSettings; - readonly Lazy usageTracker; - readonly UIContext uiContext; - - [ImportingConstructor] - public PullRequestFileMarginProvider( - Lazy enableInlineCommentsCommand, - Lazy goToSolutionOrPullRequestFileCommand, - Lazy sessionManager, - Lazy packageSettings, - Lazy usageTracker) - { - this.enableInlineCommentsCommand = enableInlineCommentsCommand; - this.goToSolutionOrPullRequestFileCommand = goToSolutionOrPullRequestFileCommand; - this.sessionManager = sessionManager; - this.packageSettings = packageSettings; - this.usageTracker = usageTracker; - - uiContext = UIContext.FromUIContextGuid(new Guid(Guids.GitContextPkgString)); - } - - /// - /// Creates an for the given . - /// - /// The for which to create the . - /// The margin that will contain the newly-created margin. - /// The . - /// The value may be null if this does not participate for this context. - /// - public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) - { - if (!uiContext.IsActive) - { - // Only create margin when in the context of a Git repository - return null; - } - - // Comments in the editor feature flag - if (!packageSettings.Value.EditorComments) - { - return null; - } - - // Never show on diff views - if (IsDiffView(wpfTextViewHost.TextView)) - { - return null; - } - - return new PullRequestFileMargin( - wpfTextViewHost.TextView, - enableInlineCommentsCommand.Value, - goToSolutionOrPullRequestFileCommand.Value, - sessionManager.Value, - usageTracker); - } - - static bool IsDiffView(ITextView textView) => textView.Roles.Contains("DIFF"); - } -} diff --git a/src/GitHub.InlineReviews/ViewModels/PullRequestFileMarginViewModel.cs b/src/GitHub.InlineReviews/ViewModels/PullRequestFileMarginViewModel.cs deleted file mode 100644 index 84968d9d85..0000000000 --- a/src/GitHub.InlineReviews/ViewModels/PullRequestFileMarginViewModel.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Windows.Input; -using GitHub.Commands; -using GitHub.Services; -using ReactiveUI; - -namespace GitHub.InlineReviews.ViewModels -{ - public class PullRequestFileMarginViewModel : ReactiveObject - { - bool enabled; - string fileName; - int commentsInFile; - bool marginEnabled; - - public PullRequestFileMarginViewModel(ICommand toggleInlineCommentMarginCommand, ICommand viewChangesCommand, - Lazy usageTracker) - { - ToggleInlineCommentMarginCommand = toggleInlineCommentMarginCommand = new UsageTrackingCommand( - usageTracker, x => x.NumberOfPullRequestFileMarginToggleInlineCommentMargin, toggleInlineCommentMarginCommand); - ViewChangesCommand = viewChangesCommand = new UsageTrackingCommand( - usageTracker, x => x.NumberOfPullRequestFileMarginViewChanges, viewChangesCommand); - } - - public bool Enabled - { - get { return enabled; } - set { this.RaiseAndSetIfChanged(ref enabled, value); } - } - - public string FileName - { - get { return fileName; } - set { this.RaiseAndSetIfChanged(ref fileName, value); } - } - - public int CommentsInFile - { - get { return commentsInFile; } - set { this.RaiseAndSetIfChanged(ref commentsInFile, value); } - } - - public bool MarginEnabled - { - get { return marginEnabled; } - set { this.RaiseAndSetIfChanged(ref marginEnabled, value); } - } - - public ICommand ToggleInlineCommentMarginCommand { get; } - - public ICommand ViewChangesCommand { get; } - } -} diff --git a/src/GitHub.InlineReviews/Views/PullRequestFileMarginView.xaml b/src/GitHub.InlineReviews/Views/PullRequestFileMarginView.xaml deleted file mode 100644 index c6a0543ea9..0000000000 --- a/src/GitHub.InlineReviews/Views/PullRequestFileMarginView.xaml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/GitHub.InlineReviews/Views/PullRequestFileMarginView.xaml.cs b/src/GitHub.InlineReviews/Views/PullRequestFileMarginView.xaml.cs deleted file mode 100644 index 9dda80ff8b..0000000000 --- a/src/GitHub.InlineReviews/Views/PullRequestFileMarginView.xaml.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Windows.Controls; - -namespace GitHub.InlineReviews.Views -{ - public partial class PullRequestFileMarginView : UserControl - { - public PullRequestFileMarginView() - { - InitializeComponent(); - } - } -} diff --git a/src/GitHub.VisualStudio/Settings/OptionsPage.cs b/src/GitHub.VisualStudio/Settings/OptionsPage.cs index 7d94d1856e..f86e3431af 100644 --- a/src/GitHub.VisualStudio/Settings/OptionsPage.cs +++ b/src/GitHub.VisualStudio/Settings/OptionsPage.cs @@ -51,14 +51,12 @@ protected override void OnActivate(CancelEventArgs e) void LoadSettings() { child.CollectMetrics = packageSettings.CollectMetrics; - child.EditorComments = packageSettings.EditorComments; child.EnableTraceLogging = packageSettings.EnableTraceLogging; } void SaveSettings() { packageSettings.CollectMetrics = child.CollectMetrics; - packageSettings.EditorComments = child.EditorComments; packageSettings.EnableTraceLogging = child.EnableTraceLogging; packageSettings.Save(); } diff --git a/src/GitHub.VisualStudio/Settings/generated/PackageSettingsGen.cs b/src/GitHub.VisualStudio/Settings/generated/PackageSettingsGen.cs index 6969198bb2..e9ccc3dd62 100644 --- a/src/GitHub.VisualStudio/Settings/generated/PackageSettingsGen.cs +++ b/src/GitHub.VisualStudio/Settings/generated/PackageSettingsGen.cs @@ -7,11 +7,6 @@ "type": "bool", "default": 'true' }, - { - "name": "EditorComments", - "type": "bool", - "default": "false" - }, { "name": "UIState", "type": "object", @@ -48,13 +43,6 @@ public bool CollectMetrics set { collectMetrics = value; this.RaisePropertyChange(); } } - bool editorComments; - public bool EditorComments - { - get { return editorComments; } - set { editorComments = value; this.RaisePropertyChange(); } - } - bool forkButton; public bool ForkButton { @@ -87,7 +75,6 @@ public bool EnableTraceLogging void LoadSettings() { CollectMetrics = (bool)settingsStore.Read("CollectMetrics", true); - EditorComments = (bool)settingsStore.Read("EditorComments", false); UIState = SimpleJson.DeserializeObject((string)settingsStore.Read("UIState", "{}")); HideTeamExplorerWelcomeMessage = (bool)settingsStore.Read("HideTeamExplorerWelcomeMessage", false); EnableTraceLogging = (bool)settingsStore.Read("EnableTraceLogging", false); @@ -96,7 +83,6 @@ void LoadSettings() void SaveSettings() { settingsStore.Write("CollectMetrics", CollectMetrics); - settingsStore.Write("EditorComments", EditorComments); settingsStore.Write("UIState", SimpleJson.SerializeObject(UIState)); settingsStore.Write("HideTeamExplorerWelcomeMessage", HideTeamExplorerWelcomeMessage); settingsStore.Write("EnableTraceLogging", EnableTraceLogging); diff --git a/src/GitHub.VisualStudio/UI/Settings/OptionsControl.xaml b/src/GitHub.VisualStudio/UI/Settings/OptionsControl.xaml index 222df83aa3..901305575e 100644 --- a/src/GitHub.VisualStudio/UI/Settings/OptionsControl.xaml +++ b/src/GitHub.VisualStudio/UI/Settings/OptionsControl.xaml @@ -95,27 +95,5 @@ - - - - - - - - - - - - - - - - diff --git a/src/GitHub.VisualStudio/UI/Settings/OptionsControl.xaml.cs b/src/GitHub.VisualStudio/UI/Settings/OptionsControl.xaml.cs index 48e8313c08..4dadaaa391 100644 --- a/src/GitHub.VisualStudio/UI/Settings/OptionsControl.xaml.cs +++ b/src/GitHub.VisualStudio/UI/Settings/OptionsControl.xaml.cs @@ -25,12 +25,6 @@ public bool EnableTraceLogging set { chkEnableTraceLogging.IsChecked = value; } } - public bool EditorComments - { - get { return chkEditorComments.IsChecked ?? false; } - set { chkEditorComments.IsChecked = value; } - } - private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) { var browser = VisualStudio.Services.DefaultExportProvider.GetExportedValue(); diff --git a/src/common/settings.json b/src/common/settings.json index d0ca9a282a..8996829a04 100644 --- a/src/common/settings.json +++ b/src/common/settings.json @@ -5,11 +5,6 @@ "type": "bool", "default": 'true' }, - { - "name": "EditorComments", - "type": "bool", - "default": "false" - }, { "name": "UIState", "type": "object",