Skip to content

Commit

Permalink
Merge pull request #1071 from ILMTitan/include_last_2.0.0_commits
Browse files Browse the repository at this point in the history
Include last 2.0.0 commits
  • Loading branch information
Jim Przybylinski authored Dec 4, 2018
2 parents 32a030d + 708d0f0 commit 6d5eaac
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
x:Class="GoogleCloudExtension.CloudExplorer.CloudExplorerToolWindowControl"
xmlns:ext="clr-namespace:GoogleCloudExtension"
xmlns:consoleLinks="clr-namespace:GoogleCloudExtension.CloudExplorerSources.CloudConsoleLinks"
xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging"
xmlns:catalog="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.ImageCatalog"
Background="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"
Foreground="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}"
mc:Ignorable="d"
Expand Down Expand Up @@ -90,8 +92,17 @@
<Hyperlink Focusable="False"
Command="{Binding NavigateCommand}"
Style="{DynamicResource {x:Static vsshell:VsResourceKeys.ThemedDialogHyperlinkStyleKey}}">
<TextBlock Focusable="False" Text="{Binding Caption}" />
<Run Focusable="False" Text="{Binding Caption}" />
</Hyperlink>

<TextBlock Focusable="False"
Visibility="{Binding InfoLinkInfo, Converter={utils:NullEmptyInvisibleConverter}}">
<Hyperlink Command="{Binding NavigateInfoCommand}" TextDecorations="None">
<imaging:CrispImage Moniker="{x:Static catalog:KnownMonikers.StatusInformation}"
Width="12"
ToolTip="{Binding InfoLinkInfo.Caption}"/>
</Hyperlink>
</TextBlock>
</TextBlock>
</DataTemplate>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
// limitations under the License.

using GoogleCloudExtension.CloudExplorer;
using GoogleCloudExtension.Services;
using GoogleCloudExtension.Utils;
using System;
using System.Diagnostics;

namespace GoogleCloudExtension.CloudExplorerSources.CloudConsoleLinks
{
Expand All @@ -26,46 +26,59 @@ public class ConsoleLink : TreeLeaf
{
private readonly LinkInfo _linkFormatInfo;
private readonly ICloudSourceContext _context;
private readonly Func<string, Process> _startProcess;
private readonly Lazy<IBrowserService> _browserService =
GoogleCloudExtensionPackage.Instance.GetMefServiceLazy<IBrowserService>();

/// <summary>
/// The command to execute when the link is pressed.
/// </summary>
public ProtectedCommand NavigateCommand { get; }

/// <summary>
/// The link info for the help link, if any.
/// </summary>
public LinkInfo InfoLinkInfo { get; }

/// <summary>
/// The command to navigate to the info link.
/// </summary>
public ProtectedCommand NavigateInfoCommand { get; }

private IBrowserService BrowserService => _browserService.Value;

/// <summary>
/// Creates a new Console Link tree leaf node.
/// </summary>
/// <param name="context">The <see cref="ICloudSourceContext"/>.</param>
/// <param name="linkFormatInfo">
/// The link info with the caption and the <see cref="string.Format(string,object[])"/> ready url format.
/// </param>
/// <param name="context">The <see cref="ICloudSourceContext"/>.</param>
public ConsoleLink(LinkInfo linkFormatInfo, ICloudSourceContext context) : this(
linkFormatInfo, context, Process.Start)
{ }
/// <param name="infoLinkInfo">The link info for the help section of the console link.</param>
public ConsoleLink(ICloudSourceContext context, LinkInfo linkFormatInfo, LinkInfo infoLinkInfo) : this(context, linkFormatInfo)
{
InfoLinkInfo = infoLinkInfo;
NavigateInfoCommand.CanExecuteCommand = true;
}

/// <summary>
/// Internal constructor for testing.
/// Creates a new Console Link tree leaf node.
/// </summary>
/// <param name="context">The <see cref="ICloudSourceContext"/>.</param>
/// <param name="linkFormatInfo">
/// The link info with the caption and the <see cref="string.Format(string,object[])"/> ready url format.
/// </param>
/// <param name="context">The <see cref="ICloudSourceContext"/>.</param>
/// <param name="startProcess">
/// Dependency injecion of the static function <see cref="Process.Start(string)"/>.
/// </param>
internal ConsoleLink(LinkInfo linkFormatInfo, ICloudSourceContext context, Func<string, Process> startProcess)
public ConsoleLink(ICloudSourceContext context, LinkInfo linkFormatInfo)
{
_startProcess = startProcess;
_context = context;
_linkFormatInfo = linkFormatInfo;
Caption = _linkFormatInfo.Caption;
NavigateCommand = new ProtectedCommand(OnNavigateCommand);
NavigateInfoCommand = new ProtectedCommand(OnNavigateHelpCommand, false);
}

private void OnNavigateCommand()
{
_startProcess(string.Format(_linkFormatInfo.NavigateUrl, _context.CurrentProject?.ProjectId));
}
private void OnNavigateCommand() => BrowserService.OpenBrowser(
string.Format(_linkFormatInfo.NavigateUrl, _context.CurrentProject?.ProjectId));

private void OnNavigateHelpCommand() => BrowserService.OpenBrowser(InfoLinkInfo.NavigateUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace GoogleCloudExtension.CloudExplorerSources.CloudConsoleLinks
public class ConsoleLinkGroup : TreeHierarchy
{
public ConsoleLinkGroup(string caption, ICloudSourceContext context, IEnumerable<LinkInfo> groupLinks) : base(
groupLinks.Select(l => new ConsoleLink(l, context)))
groupLinks.Select(l => new ConsoleLink(context, l)))
{
Caption = caption;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ public class ConsoleLinksRoot : TreeHierarchy, ISourceRootViewModelBase
private const string PubSubPath = "cloudpubsub";
private const string MachineLearningEnginePath = "mlengine";

private const string KubernetesCodelabLink =
"https://codelabs.developers.google.com/codelabs/cloud-kubernetes-aspnetcore/";

internal static readonly LinkInfo s_consoleHomeFormatInfo = new LinkInfo(
HomeUrl, Resources.CloudExplorerConsoleLinkCaption);

private static readonly IReadOnlyList<(string, string)> s_primaryConsoleLinkPaths = new[]
private static readonly IReadOnlyList<(string path, string caption)> s_primaryConsoleLinkPaths = new[]
{
(AppEnginePath, Resources.CloudLinkAppEngineCaption),
(ComputeEnginePath, Resources.CloudLinkComputeEngineCaption),
Expand Down Expand Up @@ -129,6 +132,11 @@ public class ConsoleLinksRoot : TreeHierarchy, ISourceRootViewModelBase
})
};

private static readonly IReadOnlyDictionary<string, LinkInfo> s_helpLinks = new Dictionary<string, LinkInfo>
{
[KubernetesEnginePath] = new LinkInfo(KubernetesCodelabLink, Resources.ConsoleLinksKubernetesInfoTooltip)
};

private readonly Func<string, Process> _startProcess;

private readonly ICloudSourceContext _context;
Expand Down Expand Up @@ -163,9 +171,14 @@ internal ConsoleLinksRoot(ICloudSourceContext context, Func<string, Process> sta
Caption = s_consoleHomeFormatInfo.Caption;
NavigateCommand = new ProtectedCommand(OnNavigateCommand);

foreach (LinkInfo formatLinkInfo in PrimaryConsoleLinkFormats)
foreach ((string path, string caption) tuple in s_primaryConsoleLinkPaths)
{
Children.Add(new ConsoleLink(formatLinkInfo, _context));
LinkInfo linkInfo = PathTupleToLinkInfo(tuple);
ConsoleLink consoleLink = s_helpLinks.ContainsKey(tuple.path) ?
new ConsoleLink(_context, linkInfo, s_helpLinks[tuple.path]) :
new ConsoleLink(_context, linkInfo);

Children.Add(consoleLink);
}

foreach ((string groupCaption, IEnumerable<LinkInfo> linkInfos) in GroupedConsoleLinkFormats)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

// This version number matches the version in the .vsixmanifest. Please update both versions at the
// same time.
[assembly: AssemblyVersion("2.0.1.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyVersion("2.0.2.0")]
[assembly: AssemblyFileVersion("2.0.2.0")]

[assembly: InternalsVisibleTo(
"GoogleCloudExtensionUnitTests," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
d:DesignHeight="247"
d:DesignWidth="476"
d:DataContext="{d:DesignInstance local:CoreGceWarningStepViewModel}">
<DockPanel VerticalAlignment="Stretch" Margin="36,0,36,0">
<DockPanel VerticalAlignment="Stretch" Margin="24,0,24,0">
<CheckBox DockPanel.Dock="Bottom"
IsChecked="{Binding Options.DoNotShowAspNetCoreGceWarning}"
HorizontalAlignment="Right"
Expand All @@ -45,18 +45,30 @@

<TextBlock TextWrapping="Wrap" VerticalAlignment="Center">
<Run Text="{x:Static ext:Resources.PublishGceWarningStepLine1}" />

<LineBreak/>
<LineBreak/>
<LineBreak />
<LineBreak />

<wpf:WhitespaceDiscardingSpan>
<Run Text="{x:Static ext:Resources.PublishGceWarningStepLine2BeforeLink}" />

<Hyperlink Command="{Binding BrowseAspNetMarketplaceImage}">
<Run Text="{x:Static ext:Resources.PublishGceWarningStepLine2MarketplaceLink}" />
</Hyperlink>

<Run Text="{x:Static ext:Resources.PublishGceWarningStepLine2AfterLink}" />
</wpf:WhitespaceDiscardingSpan>

<LineBreak />
<LineBreak />

<wpf:WhitespaceDiscardingSpan>
<Run Text="{x:Static ext:Resources.PublishGceWarningStepLine3BeforeLink}" />

<Hyperlink Command="{Binding BrowseAspNetCoreIisDocs}">
<Run Text="{x:Static ext:Resources.PublishGceWarningStepLine2HyperLink}" />
<Run Text="{x:Static ext:Resources.PublishGceWarningStepLine3DocsLink}" />
</Hyperlink>

<Run Text="{x:Static ext:Resources.PublishGceWarningStepLine2AfterLink}"/>
<Run Text="{x:Static ext:Resources.PublishGceWarningStepLine3AfterLink}" />
</wpf:WhitespaceDiscardingSpan>
</TextBlock>
</DockPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class CoreGceWarningStepViewModel : ValidatingViewModelBase, IPublishDial
{
public const string AspNetCoreIisDocsLink = "https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/";

public const string AspNetMarketplaceImageLink =
"https://console.cloud.google.com/marketplace/details/click-to-deploy-images/aspnet";

private readonly IPublishDialog _publishDialog;
private readonly GceStepContent _nextStepContent;
private readonly Lazy<IBrowserService> _browserService;
Expand Down Expand Up @@ -57,16 +60,22 @@ public class CoreGceWarningStepViewModel : ValidatingViewModelBase, IPublishDial
public ProtectedCommand BrowseAspNetCoreIisDocs { get; }
private IBrowserService BrowserService => _browserService.Value;

public ProtectedCommand BrowseAspNetMarketplaceImage { get; }

public CoreGceWarningStepViewModel(IPublishDialog publishDialog)
{
_publishDialog = publishDialog;
BrowseAspNetCoreIisDocs = new ProtectedCommand(OnBrowseAspNetCoreIisDocs);
BrowseAspNetMarketplaceImage = new ProtectedCommand(OnBrowseAspNeMarketplaceImage);
Title = string.Format(Resources.GcePublishStepTitle, publishDialog.Project.Name);
ActionCommand = new ProtectedCommand(OnNextCommand);
_nextStepContent = new GceStepContent(_publishDialog);
_browserService = GoogleCloudExtensionPackage.Instance.GetMefServiceLazy<IBrowserService>();
}

private void OnBrowseAspNeMarketplaceImage() =>
BrowserService.OpenBrowser(AspNetMarketplaceImageLink);

private void OnBrowseAspNetCoreIisDocs() =>
BrowserService.OpenBrowser(AspNetCoreIisDocsLink);

Expand Down
42 changes: 39 additions & 3 deletions GoogleCloudExtension/GoogleCloudExtension/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions GoogleCloudExtension/GoogleCloudExtension/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2489,14 +2489,26 @@ Delete corrupted file?</value>
<comment>The first line of the ASP.NET Core on GCE warning dialog.</comment>
</data>
<data name="PublishGceWarningStepLine2BeforeLink" xml:space="preserve">
<value>Hosting ASP.NET Core applications on Compute Engine requires </value>
<value>Hosting ASP.NET Core applications on Compute Engine should use the </value>
<comment>The first part of the second line of the ASP.NET Core on GCE warning dialog.</comment>
</data>
<data name="PublishGceWarningStepLine2HyperLink" xml:space="preserve">
<data name="PublishGceWarningStepLine2MarketplaceLink" xml:space="preserve">
<value>ASP.NET Framework Marketplace Image</value>
<comment>The text of the link to the ASP.NET Framework Marketplace </comment>
</data>
<data name="PublishGceWarningStepLine2AfterLink" xml:space="preserve">
<value>.</value>
<comment>The text after the link of the second line of the ASP.NET Core on GCE warning dialog.</comment>
</data>
<data name="PublishGceWarningStepLine3BeforeLink" xml:space="preserve">
<value>The default windows image will require </value>
<comment>The part between the links of the second line of the ASP.NET Core on GCE warning dialog.</comment>
</data>
<data name="PublishGceWarningStepLine3DocsLink" xml:space="preserve">
<value>manual configuration of IIS</value>
<comment>The text of the hyperlink on the ASP.NET Core on GCE Warning dialog.</comment>
</data>
<data name="PublishGceWarningStepLine2AfterLink" xml:space="preserve">
<data name="PublishGceWarningStepLine3AfterLink" xml:space="preserve">
<value>.</value>
<comment>The end part of the second line of the ASP.NET Core on GCE warning dialog.</comment>
</data>
Expand All @@ -2507,4 +2519,8 @@ Delete corrupted file?</value>
<data name="UiDontShowWarningAgain" xml:space="preserve">
<value>Don't show this warning again</value>
</data>
<data name="ConsoleLinksKubernetesInfoTooltip" xml:space="preserve">
<value>Kubernetes Engine Code Lab</value>
<comment>The tooltip of the info link of the kubernetes console link.</comment>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The Version attribute of the Identity element *must* match the version number in Properties\AssemblyInfo.cs, to ensure
accurate metrics.
-->
<Identity Id="GoogleAppEngine.Google.d3d3eeb8-3710-4bd9-97ba-1401bf2acd22" Version="2.0.1.0" Language="en-US" Publisher="Google Inc." />
<Identity Id="GoogleAppEngine.Google.d3d3eeb8-3710-4bd9-97ba-1401bf2acd22" Version="2.0.2.0" Language="en-US" Publisher="Google Inc." />
<DisplayName>Google Cloud Tools for Visual Studio</DisplayName>
<Description xml:space="preserve">Tools to develop applications for Google Cloud Platform.</Description>
<MoreInfo>https://cloud.google.com/visual-studio/</MoreInfo>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace GoogleCloudExtensionUnitTests.CloudExplorerSources.CloudConsoleLinks
{
[TestClass]
public class CloudConsoleLinksSourceTests
public class CloudConsoleLinksSourceTests : ExtensionTestBase
{
[TestMethod]
public void TestConstructor_SetsRoot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace GoogleCloudExtensionUnitTests.CloudExplorerSources.CloudConsoleLinks
{
[TestClass]
public class ConsoleLinkGroupTests
public class ConsoleLinkGroupTests : ExtensionTestBase
{
private static readonly ICloudSourceContext s_mockedContext = Mock.Of<ICloudSourceContext>();
private const string DefaultCaption = "DefaultCaption";
Expand Down
Loading

0 comments on commit 6d5eaac

Please sign in to comment.