Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 2ed22d5

Browse files
committed
GitHub Pane view and viewmodel
Add a view and viewmodel for the GitHubPane. They'll handle hosting the views for specific features (pull request list, pull request creation, detail, etc), as well as loading and navigating between them, using a long-lived instance of UIController. Toolbar commands are controlled by the view model. The view model gets informed of contextual repository changes in the same way that sections and navigation items do - by hooking up to TeamExplorerServiceHolder (via the constructor) and getting notifications. These notifications are now also sent via property events, as well as `RepoChanged()` calls.
1 parent 9dc02fe commit 2ed22d5

14 files changed

+312
-42
lines changed

src/GitHub.Exports/Exports/ExportMetadata.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ public enum UIViewType {
1717
Clone,
1818
Publish,
1919
End = 100,
20-
Finished
21-
}
20+
Finished,
21+
GitHubPane,
22+
}
2223

2324
[MetadataAttribute]
2425
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false)]

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
<ItemGroup>
126126
<Compile Include="Authentication\AuthenticationResultExtensions.cs" />
127127
<Compile Include="Extensions\VSExtensions.cs" />
128+
<Compile Include="ViewModels\IServiceProviderAware.cs" />
128129
<Compile Include="UI\IView.cs" />
129130
<Compile Include="UI\Octicon.cs" />
130131
<Compile Include="ViewModels\IGitHubConnectSection.cs" />
@@ -145,6 +146,7 @@
145146
<Compile Include="Services\IUIProvider.cs" />
146147
<Compile Include="Services\IWikiProbe.cs" />
147148
<Compile Include="Services\WikiProbe.cs" />
149+
<Compile Include="ViewModels\IGitHubPaneViewModel.cs" />
148150
<Compile Include="ViewModels\ILoginViewModel.cs" />
149151
<Compile Include="Primitives\HostAddress.cs" />
150152
<Compile Include="UI\IUIController.cs" />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Windows.Input;
2+
3+
namespace GitHub.ViewModels
4+
{
5+
public interface IGitHubPaneViewModel : IViewModel
6+
{
7+
string ActiveRepoName { get; }
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
namespace GitHub.ViewModels
4+
{
5+
public interface IServiceProviderAware
6+
{
7+
void Initialize(IServiceProvider serviceProvider);
8+
}
9+
}

src/GitHub.VisualStudio/Base/TeamExplorerGitRepoInfo.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using GitHub.Models;
22
using GitHub.Primitives;
33
using GitHub.Services;
4+
using GitHub.VisualStudio.Helpers;
45
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
56
using NullGuard;
67

@@ -10,7 +11,9 @@ public class TeamExplorerGitRepoInfo : TeamExplorerBase, IGitAwareItem
1011
{
1112
public TeamExplorerGitRepoInfo()
1213
{
13-
ActiveRepo = null;
14+
activeRepo = null;
15+
activeRepoUri = null;
16+
activeRepoName = string.Empty;
1417
}
1518

1619
ISimpleRepositoryModel activeRepo;
@@ -24,14 +27,26 @@ public ISimpleRepositoryModel ActiveRepo
2427
ActiveRepoName = string.Empty;
2528
ActiveRepoUri = null;
2629
activeRepo = value;
30+
this.RaisePropertyChange();
2731
}
2832
}
2933

34+
UriString activeRepoUri;
3035
/// <summary>
3136
/// Represents the web URL of the repository on GitHub.com, even if the origin is an SSH address.
3237
/// </summary>
3338
[AllowNull]
34-
public UriString ActiveRepoUri { [return: AllowNull] get; set; }
35-
public string ActiveRepoName { get; set; }
39+
public UriString ActiveRepoUri
40+
{
41+
[return: AllowNull] get { return activeRepoUri; }
42+
set { activeRepoUri = value; this.RaisePropertyChange(); }
43+
}
44+
45+
string activeRepoName;
46+
public string ActiveRepoName
47+
{
48+
get { return activeRepoName; }
49+
set { activeRepoName = value; this.RaisePropertyChange(); }
50+
}
3651
}
3752
}

src/GitHub.VisualStudio/Base/TeamExplorerItemBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public ISimpleApiClient SimpleApiClient
3131

3232
protected ISimpleApiClientFactory ApiFactory => apiFactory;
3333

34+
public TeamExplorerItemBase(ITeamExplorerServiceHolder holder)
35+
{
36+
this.holder = holder;
37+
}
38+
3439
public TeamExplorerItemBase(ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder)
3540
{
3641
this.apiFactory = apiFactory;

src/GitHub.VisualStudio/Base/TeamExplorerSectionBase.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
using NullGuard;
55
using GitHub.Services;
66
using System.Diagnostics;
7-
using System.Threading;
8-
using GitHub.Extensions;
9-
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
107
using GitHub.Api;
118
using GitHub.Models;
9+
using GitHub.ViewModels;
1210

1311
namespace GitHub.VisualStudio.Base
1412
{
15-
public class TeamExplorerSectionBase : TeamExplorerItemBase, ITeamExplorerSection
13+
public class TeamExplorerSectionBase : TeamExplorerItemBase, ITeamExplorerSection, IServiceProviderAware
1614
{
1715
protected IConnectionManager connectionManager;
1816

@@ -52,6 +50,14 @@ public virtual object GetExtensibilityService(Type serviceType)
5250
return null;
5351
}
5452

53+
public TeamExplorerSectionBase(ITeamExplorerServiceHolder holder)
54+
: base(holder)
55+
{
56+
IsVisible = false;
57+
IsEnabled = true;
58+
IsExpanded = true;
59+
}
60+
5561
public TeamExplorerSectionBase(ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder)
5662
: base(apiFactory, holder)
5763
{
@@ -60,29 +66,39 @@ public TeamExplorerSectionBase(ISimpleApiClientFactory apiFactory, ITeamExplorer
6066
IsExpanded = true;
6167
}
6268

69+
public TeamExplorerSectionBase(ITeamExplorerServiceHolder holder, IConnectionManager cm) : this(holder)
70+
{
71+
connectionManager = cm;
72+
}
73+
6374
public TeamExplorerSectionBase(ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder,
6475
IConnectionManager cm) : this(apiFactory, holder)
6576
{
6677
connectionManager = cm;
6778
}
6879

69-
public virtual void Cancel()
80+
void ITeamExplorerSection.Cancel()
81+
{
82+
}
83+
84+
void ITeamExplorerSection.Initialize(object sender, SectionInitializeEventArgs e)
7085
{
86+
Initialize(e.ServiceProvider);
7187
}
7288

73-
public virtual void Initialize(object sender, SectionInitializeEventArgs e)
89+
public virtual void Initialize(IServiceProvider serviceProvider)
7490
{
7591
#if DEBUG
76-
// VsOutputLogger.WriteLine("{0:HHmmssff}\t{1} Initialize", DateTime.Now, GetType());
92+
//VsOutputLogger.WriteLine("{0:HHmmssff}\t{1} Initialize", DateTime.Now, GetType());
7793
#endif
78-
ServiceProvider = e.ServiceProvider;
94+
ServiceProvider = serviceProvider;
7995
Debug.Assert(holder != null, "Could not get an instance of TeamExplorerServiceHolder");
8096
if (holder == null)
8197
return;
82-
holder.ServiceProvider = e.ServiceProvider;
98+
holder.ServiceProvider = ServiceProvider;
8399
SubscribeToRepoChanges();
84100
#if DEBUG
85-
// VsOutputLogger.WriteLine("{0:HHmmssff}\t{1} Initialize DONE", DateTime.Now, GetType());
101+
//VsOutputLogger.WriteLine("{0:HHmmssff}\t{1} Initialize DONE", DateTime.Now, GetType());
86102
#endif
87103
}
88104

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@
274274
<Compile Include="UI\Views\Controls\TwoFactorControl.xaml.cs">
275275
<DependentUpon>TwoFactorControl.xaml</DependentUpon>
276276
</Compile>
277+
<Compile Include="UI\Views\GitHubPaneView.xaml.cs">
278+
<DependentUpon>GitHubPaneView.xaml</DependentUpon>
279+
</Compile>
277280
<Compile Include="UI\WindowController.xaml.cs">
278281
<DependentUpon>WindowController.xaml</DependentUpon>
279282
</Compile>
@@ -391,6 +394,10 @@
391394
<SubType>
392395
</SubType>
393396
</Page>
397+
<Page Include="UI\Views\GitHubPaneView.xaml">
398+
<SubType>Designer</SubType>
399+
<Generator>MSBuild:Compile</Generator>
400+
</Page>
394401
<Page Include="UI\WindowController.xaml">
395402
<Generator>MSBuild:Compile</Generator>
396403
</Page>
Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,60 @@
1-
<ResourceDictionary
2-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
5-
>
1+
<ResourceDictionary
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">
65

76
<ResourceDictionary.MergedDictionaries>
87
<ResourceDictionary Source="pack://application:,,,/GitHub.VisualStudio;component/UI/Views/Controls/ActionLinkButton.xaml" />
98
</ResourceDictionary.MergedDictionaries>
109

11-
<Style x:Key="VSStyledButton" TargetType="{x:Type Button}" BasedOn="{StaticResource VsButtonStyleKey}">
12-
</Style>
10+
<Style x:Key="VSStyledButton" BasedOn="{StaticResource VsButtonStyleKey}" TargetType="{x:Type Button}" />
1311
<Style x:Key="VSStyledCheckBox" BasedOn="{StaticResource VsCheckBoxStyleKey}" TargetType="{x:Type CheckBox}">
1412
<Setter Property="Foreground" Value="{DynamicResource VsBrush.ToolWindowText}" />
1513
<Setter Property="Background" Value="{DynamicResource VsBrush.ToolWindowBackground}" />
1614
<Style.Triggers>
1715
<Trigger Property="UIElement.IsMouseOver" Value="true">
18-
<Setter Property="Background" Value="{DynamicResource VsBrush.ToolWindowBackground}"/>
16+
<Setter Property="Background" Value="{DynamicResource VsBrush.ToolWindowBackground}" />
1917
</Trigger>
2018
</Style.Triggers>
2119
</Style>
22-
<Style x:Key="VSStyledComboBox" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource VsComboBoxStyleKey}">
23-
</Style>
24-
20+
<Style x:Key="VSStyledComboBox" BasedOn="{StaticResource VsComboBoxStyleKey}" TargetType="{x:Type ComboBox}" />
21+
2522
<DrawingBrush x:Key="ConnectArrowBrush">
2623
<DrawingBrush.Drawing>
2724
<DrawingGroup>
2825
<DrawingGroup.Children>
29-
<GeometryDrawing Brush="{DynamicResource VsBrush.ControlLinkText}"
30-
Geometry="F1 M 9,11 L 7,11 9,9 4,9 4,7 9,7 7,5 9,5 12,8 Z"/>
31-
<GeometryDrawing Brush="{DynamicResource VsBrush.ControlLinkText}"
32-
Geometry="F1 M 7.9741,1.0698 C 4.1461,1.0698 1.0441,4.1728 1.0441,7.9998 1.0441,11.8268 4.1461,14.9298 7.9741,14.9298 11.8011,14.9298 14.9041,11.8268 14.9041,7.9998 14.9041,4.1728 11.8011,1.0698 7.9741,1.0698 M 7.9741,2.0598 C 11.2501,2.0598 13.9151,4.7248 13.9151,7.9998 13.9151,11.2758 11.2501,13.9408 7.9741,13.9408 4.6991,13.9408 2.0341,11.2758 2.0341,7.9998 2.0341,4.7248 4.6991,2.0598 7.9741,2.0598 "/>
26+
<GeometryDrawing Brush="{DynamicResource VsBrush.ControlLinkText}" Geometry="F1 M 9,11 L 7,11 9,9 4,9 4,7 9,7 7,5 9,5 12,8 Z" />
27+
<GeometryDrawing Brush="{DynamicResource VsBrush.ControlLinkText}" Geometry="F1 M 7.9741,1.0698 C 4.1461,1.0698 1.0441,4.1728 1.0441,7.9998 1.0441,11.8268 4.1461,14.9298 7.9741,14.9298 11.8011,14.9298 14.9041,11.8268 14.9041,7.9998 14.9041,4.1728 11.8011,1.0698 7.9741,1.0698 M 7.9741,2.0598 C 11.2501,2.0598 13.9151,4.7248 13.9151,7.9998 13.9151,11.2758 11.2501,13.9408 7.9741,13.9408 4.6991,13.9408 2.0341,11.2758 2.0341,7.9998 2.0341,4.7248 4.6991,2.0598 7.9741,2.0598 " />
3328
</DrawingGroup.Children>
3429
</DrawingGroup>
3530
</DrawingBrush.Drawing>
3631
</DrawingBrush>
3732

38-
<Style x:Key="VerticalSeparator" TargetType="{x:Type Separator}">
39-
<Setter Property="Control.Background" Value="{DynamicResource VsBrush.GrayText}" />
40-
<Setter Property="FrameworkElement.Margin" Value="3,0,3,0" />
41-
<Setter Property="UIElement.Focusable" Value="False" />
42-
<Setter Property="Control.Template">
33+
<Style x:Key="TitleVerticalSeparator" TargetType="{x:Type Separator}">
34+
<Setter Property="Foreground" Value="#BBBBBB" />
35+
<Setter Property="Width" Value="2" />
36+
<Setter Property="Margin" Value="3,0,3,0" />
37+
<Setter Property="Template">
4338
<Setter.Value>
4439
<ControlTemplate TargetType="{x:Type Separator}">
45-
<Border SnapsToDevicePixels="True" Width="1" Background="{TemplateBinding Control.Background}"
46-
BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="{TemplateBinding Control.BorderThickness}" />
40+
<Border Width="{TemplateBinding Width}"
41+
Background="{TemplateBinding Foreground}"
42+
BorderBrush="{TemplateBinding Foreground}"
43+
BorderThickness="{TemplateBinding BorderThickness}"
44+
SnapsToDevicePixels="True" />
4745
</ControlTemplate>
4846
</Setter.Value>
4947
</Setter>
5048
</Style>
5149

50+
<Style x:Key="VerticalSeparator" TargetType="{x:Type Separator}">
51+
<Setter Property="Background" Value="Gray" />
52+
<Setter Property="Margin" Value="3,0,3,0" />
53+
<Setter Property="LayoutTransform">
54+
<Setter.Value>
55+
<RotateTransform Angle="90" />
56+
</Setter.Value>
57+
</Setter>
58+
</Style>
59+
5260
</ResourceDictionary>

src/GitHub.VisualStudio/TeamExplorer/Connect/GitHubConnectSection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ public override void Refresh()
159159
base.Refresh();
160160
}
161161

162-
public override void Initialize(object sender, SectionInitializeEventArgs e)
162+
public override void Initialize(IServiceProvider serviceProvider)
163163
{
164-
base.Initialize(sender, e);
164+
base.Initialize(serviceProvider);
165165
UpdateConnection();
166166

167167
// watch for new repos added to the local repo list

0 commit comments

Comments
 (0)