Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2e04cf3
Functionality to add Publish to GitHub Essentials
StanleyGoldman May 22, 2019
f152a8a
Merge branch 'master' into essentials-publish
StanleyGoldman May 22, 2019
fb7b443
Merge branch 'master' into essentials-publish
StanleyGoldman May 23, 2019
3bf04a5
Hiding the publish section to favor the main package
StanleyGoldman May 23, 2019
d0a1cd8
Make publish view consistent with Azure DevOps
jcansdale May 23, 2019
1507ada
Starting to display the RepositoryPublishView
StanleyGoldman May 30, 2019
07bbffc
Loading more of the Publish functionality
StanleyGoldman May 30, 2019
d4603a2
Adding missing references
StanleyGoldman May 30, 2019
d86fad5
Use local not global ServiceProvider
jcansdale May 31, 2019
88109fb
Factor out GetExportProvider
jcansdale May 31, 2019
e4e574d
Clean up when view is unloaded
jcansdale May 31, 2019
fe9b3f2
Remove redundant ShowNotification
jcansdale May 31, 2019
b4e809d
Locate the DefaultExportProvider using MEF
jcansdale May 31, 2019
9544e81
Expose singleton GitHub ExportProvider via MEF
jcansdale May 31, 2019
e4355cd
Factor knowledge of full extension into FullExtensionUtilities
jcansdale May 31, 2019
46c2174
Avoid putting GitHub.Resources.dll on BindingPath
jcansdale Jun 3, 2019
25878e0
Making sure the `EnsureLoad` method is not optimized away
StanleyGoldman Jun 3, 2019
2aa0881
Authenticating the user before showing the publish section view
StanleyGoldman Jun 3, 2019
b4a400b
Merge branch 'master' into essentials-publish
StanleyGoldman Jun 4, 2019
e550bad
Add option to add/change accounts from publish view
jcansdale Jun 5, 2019
c5ce8f4
Fix style of Add/Change Accounts button
jcansdale Jun 5, 2019
9137b48
Remove deleted files from .csproj
jcansdale Jun 5, 2019
edf7220
Fixing unit test
StanleyGoldman Jun 5, 2019
e845cbe
Merge remote-tracking branch 'remotes/origin/essentials-publish' into…
StanleyGoldman Jun 5, 2019
d24aab8
Theme the publish view with Team Explorer colors
jcansdale Jun 25, 2019
b08edb5
Automatically change the host drop-down
jcansdale Jun 25, 2019
6e798c6
Use GitHub.Resources for publish BlurbText
jcansdale Jun 25, 2019
ac41d5b
Don't load the publish view until is becomes visible
jcansdale Jun 26, 2019
18bd027
Localize the publish section title
jcansdale Jun 26, 2019
543bf7b
Move to GitHub.VisualStudio namespace
jcansdale Jun 26, 2019
8b197bc
Remove unused ParentSection and View properties
jcansdale Jun 26, 2019
e640b8a
Localize the publish button text
jcansdale Jun 27, 2019
b99cda3
Stop CompositionServices from loading GitHub.Exports
jcansdale Jun 27, 2019
5690b6f
Use RelayCommand from TeamFoundation assembly
jcansdale Jun 27, 2019
9e4d1e2
Simplify the IsSectionVisible code
jcansdale Jun 27, 2019
c0a676f
Merge branch 'master' into essentials-publish
jcansdale Sep 13, 2019
f8ef812
Merge branch 'master' into essentials-publish
jcansdale Sep 27, 2019
c8be700
Merge branch 'master' into essentials-publish
jcansdale Sep 27, 2019
aacbaa7
Merge branch 'master' into essentials-publish
jcansdale Sep 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/GitHub.App/SampleData/SampleViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ public ReactiveCommand<Unit, ProgressState> PublishRepository
private set;
}

public ReactiveCommand<Unit, Unit> LoginAsDifferentUser
{
get;
private set;
}

public IReadOnlyObservableCollection<IConnection> Connections
{
get;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using GitHub.App;
using System.Threading.Tasks;
using GitHub.Extensions;
using GitHub.Extensions.Reactive;
using GitHub.Factories;
Expand All @@ -29,6 +29,7 @@ public class RepositoryPublishViewModel : RepositoryFormViewModel, IRepositoryPu
readonly IRepositoryPublishService repositoryPublishService;
readonly INotificationService notificationService;
readonly IModelServiceFactory modelServiceFactory;
readonly IDialogService dialogService;
readonly ObservableAsPropertyHelper<IReadOnlyList<IAccount>> accounts;
readonly ObservableAsPropertyHelper<bool> isHostComboBoxVisible;
readonly IUsageTracker usageTracker;
Expand All @@ -39,17 +40,20 @@ public RepositoryPublishViewModel(
INotificationService notificationService,
IConnectionManager connectionManager,
IModelServiceFactory modelServiceFactory,
IDialogService dialogService,
IUsageTracker usageTracker)
{
Guard.ArgumentNotNull(repositoryPublishService, nameof(repositoryPublishService));
Guard.ArgumentNotNull(notificationService, nameof(notificationService));
Guard.ArgumentNotNull(connectionManager, nameof(connectionManager));
Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));
Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
Guard.ArgumentNotNull(dialogService, nameof(dialogService));

this.notificationService = notificationService;
this.usageTracker = usageTracker;
this.modelServiceFactory = modelServiceFactory;
this.dialogService = dialogService;

Connections = connectionManager.Connections;
this.repositoryPublishService = repositoryPublishService;
Expand Down Expand Up @@ -83,6 +87,8 @@ public RepositoryPublishViewModel(
PublishRepository = InitializePublishRepositoryCommand();
PublishRepository.IsExecuting.Subscribe(x => IsBusy = x);

LoginAsDifferentUser = ReactiveCommand.CreateFromTask(LoginAsDifferentUserAsync);

var defaultRepositoryName = repositoryPublishService.LocalRepositoryName;
if (!string.IsNullOrEmpty(defaultRepositoryName))
RepositoryName = defaultRepositoryName;
Expand All @@ -101,6 +107,9 @@ public RepositoryPublishViewModel(
}

public ReactiveCommand<Unit, ProgressState> PublishRepository { get; private set; }

public ReactiveCommand<Unit, Unit> LoginAsDifferentUser { get; private set; }

public IReadOnlyObservableCollection<IConnection> Connections { get; private set; }

bool isBusy;
Expand All @@ -127,6 +136,14 @@ public bool IsHostComboBoxVisible
get { return isHostComboBoxVisible.Value; }
}

async Task LoginAsDifferentUserAsync()
{
if (await dialogService.ShowLoginDialog() is IConnection connection)
{
SelectedConnection = connection;
}
}

ReactiveCommand<Unit, ProgressState> InitializePublishRepositoryCommand()
{
var canCreate = this.WhenAny(x => x.RepositoryNameValidator.ValidationResult.IsValid, x => x.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public interface IRepositoryPublishViewModel : IViewModel, IRepositoryForm
/// </summary>
ReactiveCommand<Unit, ProgressState> PublishRepository { get; }

/// <summary>
/// Command that shows login dialog.
/// </summary>
ReactiveCommand<Unit, Unit> LoginAsDifferentUser { get; }

/// <summary>
/// Determines whether the host combo box is visible. Only true if the user is logged into more than one host.
/// </summary>
Expand Down
173 changes: 173 additions & 0 deletions src/GitHub.VisualStudio.16/Base/TeamExplorerBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved. This code released
* under the terms of the Microsoft Limited Public License (MS-LPL).
*/
using System;
using System.ComponentModel;
using System.Diagnostics;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Controls;

namespace GitHub.VisualStudio
{
/// <summary>
/// Team Explorer plugin common base class.
/// </summary>
public class TeamExplorerBase : IDisposable, INotifyPropertyChanged
{
#region Members

private bool m_contextSubscribed = false;

#endregion

/// <summary>
/// Get/set the service provider.
/// </summary>
public IServiceProvider ServiceProvider
{
get { return m_serviceProvider; }
set
{
// Unsubscribe from Team Foundation context changes
if (m_serviceProvider != null)
{
UnsubscribeContextChanges();
}

m_serviceProvider = value;

// Subscribe to Team Foundation context changes
if (m_serviceProvider != null)
{
SubscribeContextChanges();
}
}
}
private IServiceProvider m_serviceProvider = null;

/// <summary>
/// Get the requested service from the service provider.
/// </summary>
public T GetService<T>()
{
Debug.Assert(this.ServiceProvider != null, "GetService<T> called before service provider is set");
if (this.ServiceProvider != null)
{
return (T)this.ServiceProvider.GetService(typeof(T));
}

return default(T);
}

/// <summary>
/// Show a notification in the Team Explorer window.
/// </summary>
protected Guid ShowNotification(string message, NotificationType type)
{
ITeamExplorer teamExplorer = GetService<ITeamExplorer>();
if (teamExplorer != null)
{
Guid guid = Guid.NewGuid();
teamExplorer.ShowNotification(message, type, NotificationFlags.None, null, guid);
return guid;
}

return Guid.Empty;
}

#region IDisposable

/// <summary>
/// Dispose.
/// </summary>
public virtual void Dispose()
{
UnsubscribeContextChanges();
}

#endregion

#region INotifyPropertyChanged

public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

/// <summary>
/// Raise the PropertyChanged event for the specified property.
/// </summary>
/// <param name="propertyName">Property name</param>
protected void RaisePropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}

#endregion

#region Team Foundation Context

/// <summary>
/// Subscribe to context changes.
/// </summary>
protected void SubscribeContextChanges()
{
Debug.Assert(this.ServiceProvider != null, "ServiceProvider must be set before subscribing to context changes");
if (this.ServiceProvider == null || m_contextSubscribed)
{
return;
}

ITeamFoundationContextManager tfContextManager = GetService<ITeamFoundationContextManager>();
if (tfContextManager != null)
{
tfContextManager.ContextChanged += ContextChanged;
m_contextSubscribed = true;
}
}

/// <summary>
/// Unsubscribe from context changes.
/// </summary>
protected void UnsubscribeContextChanges()
{
if (this.ServiceProvider == null || !m_contextSubscribed)
{
return;
}

ITeamFoundationContextManager tfContextManager = GetService<ITeamFoundationContextManager>();
if (tfContextManager != null)
{
tfContextManager.ContextChanged -= ContextChanged;
}
}

/// <summary>
/// ContextChanged event handler.
/// </summary>
protected virtual void ContextChanged(object sender, ContextChangedEventArgs e)
{
}

/// <summary>
/// Get the current Team Foundation context.
/// </summary>
protected ITeamFoundationContext CurrentContext
{
get
{
ITeamFoundationContextManager tfContextManager = GetService<ITeamFoundationContextManager>();
if (tfContextManager != null)
{
return tfContextManager.CurrentContext;
}

return null;
}
}

#endregion
}
}
73 changes: 73 additions & 0 deletions src/GitHub.VisualStudio.16/Base/TeamExplorerBaseNavigationItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved. This code released
* under the terms of the Microsoft Limited Public License (MS-LPL).
*/
using System;
using System.ComponentModel.Composition;
using Microsoft.TeamFoundation.Controls;
using Microsoft.VisualStudio.Shell;

namespace GitHub.VisualStudio
{
/// <summary>
/// Team Explorer base navigation item class.
/// </summary>
public class TeamExplorerBaseNavigationItem : TeamExplorerBase, ITeamExplorerNavigationItem
{
/// <summary>
/// Constructor.
/// </summary>
public TeamExplorerBaseNavigationItem(IServiceProvider serviceProvider)
{
this.ServiceProvider = serviceProvider;
}

#region ITeamExplorerNavigationItem

/// <summary>
/// Get/set the item text.
/// </summary>
public string Text
{
get { return m_text; }
set { m_text = value; RaisePropertyChanged("Text"); }
}
private string m_text;

/// <summary>
/// Get/set the item image.
/// </summary>
public System.Drawing.Image Image
{
get { return m_image; }
set { m_image = value; RaisePropertyChanged("Image"); }
}
private System.Drawing.Image m_image;

/// <summary>
/// Get/set the IsVisible flag.
/// </summary>
public bool IsVisible
{
get { return m_isVisible; }
set { m_isVisible = value; RaisePropertyChanged("IsVisible"); }
}
private bool m_isVisible = true;

/// <summary>
/// Invalidate the item state.
/// </summary>
public virtual void Invalidate()
{
}

/// <summary>
/// Execute the item action.
/// </summary>
public virtual void Execute()
{
}

#endregion
}
}
Loading