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

Commit 2888313

Browse files
committed
Add command for creating Enterprise Gists
The command is called `GitHub.CreateGistEnterprise` and appears on the `GitHub` context menu as `Create an Enterprise Gist`.
1 parent 3ff3afc commit 2888313

File tree

6 files changed

+60
-8
lines changed

6 files changed

+60
-8
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace GitHub.Commands
4+
{
5+
/// <summary>
6+
/// Creates a GitHub Enterprise gist from the currently selected text.
7+
/// </summary>
8+
public interface ICreateGistEnterpriseCommand : IVsCommand
9+
{
10+
}
11+
}

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
<ItemGroup>
150150
<Compile Include="Commands\ICopyLinkCommand.cs" />
151151
<Compile Include="Commands\IBlameLinkCommand.cs" />
152+
<Compile Include="Commands\ICreateGistEnterpriseCommand.cs" />
152153
<Compile Include="Commands\IOpenFromClipboardCommand.cs" />
153154
<Compile Include="Commands\IOpenFromUrlCommand.cs" />
154155
<Compile Include="Commands\IToggleInlineCommentMarginCommand.cs" />

src/GitHub.Exports/Settings/PkgCmdID.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static class PkgCmdIDList
1919
public const int refreshCommand = 0x302;
2020
public const int pullRequestCommand = 0x310;
2121
public const int createGistCommand = 0x400;
22+
public const int createGistEnterpriseCommand = 0x401;
2223
public const int openLinkCommand = 0x100;
2324
public const int copyLinkCommand = 0x101;
2425
public const int goToSolutionOrPullRequestFileCommand = 0x102;

src/GitHub.VisualStudio/Commands/CreateGistCommand.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ namespace GitHub.VisualStudio.Commands
1414
/// Creates a GitHub Gist from the currently selected text.
1515
/// </summary>
1616
[Export(typeof(ICreateGistCommand))]
17-
public class CreateGistCommand : CreateGistCommandBase
17+
public class CreateGistCommand : CreateGistCommandBase, ICreateGistCommand
1818
{
19-
readonly Lazy<IDialogService> dialogService;
20-
readonly Lazy<ISelectedTextProvider> selectedTextProvider;
21-
readonly Lazy<IConnectionManager> connectionManager;
22-
2319
[ImportingConstructor]
2420
protected CreateGistCommand(
2521
Lazy<IDialogService> dialogService,
@@ -40,11 +36,36 @@ protected CreateGistCommand(
4036
public const int CommandId = PkgCmdIDList.createGistCommand;
4137
}
4238

39+
/// <summary>
40+
/// Creates a GitHub Enterprise Gist from the currently selected text.
41+
/// </summary>
42+
[Export(typeof(ICreateGistEnterpriseCommand))]
43+
public class CreateGistEnterpriseCommand : CreateGistCommandBase, ICreateGistEnterpriseCommand
44+
{
45+
[ImportingConstructor]
46+
protected CreateGistEnterpriseCommand(
47+
Lazy<IDialogService> dialogService,
48+
Lazy<ISelectedTextProvider> selectedTextProvider,
49+
Lazy<IConnectionManager> connectionManager)
50+
: base(CommandSet, CommandId, dialogService, selectedTextProvider, connectionManager, false)
51+
{
52+
}
53+
54+
/// <summary>
55+
/// Gets the GUID of the group the command belongs to.
56+
/// </summary>
57+
public static readonly Guid CommandSet = Guids.guidContextMenuSet;
58+
59+
/// <summary>
60+
/// Gets the numeric identifier of the command.
61+
/// </summary>
62+
public const int CommandId = PkgCmdIDList.createGistEnterpriseCommand;
63+
}
64+
4365
/// <summary>
4466
/// Creates a GitHub or GitHub Enterprise Gist from the currently selected text.
4567
/// </summary>
46-
[Export(typeof(ICreateGistCommand))]
47-
public abstract class CreateGistCommandBase : VsCommand, ICreateGistCommand
68+
public abstract class CreateGistCommandBase : VsCommand
4869
{
4970
readonly bool isGitHubDotCom;
5071
readonly Lazy<IDialogService> dialogService;

src/GitHub.VisualStudio/GitHub.VisualStudio.vsct

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,18 @@
214214
</Strings>
215215
</Button>
216216

217+
<Button guid="guidContextMenuSet" id="idCreateGistEnterpriseCommand" priority="0x0101" type="Button">
218+
<Icon guid="guidImages" id="logo" />
219+
<CommandFlag>IconIsMoniker</CommandFlag>
220+
<CommandFlag>DefaultInvisible</CommandFlag>
221+
<CommandFlag>DynamicVisibility</CommandFlag>
222+
<Strings>
223+
<ButtonText>Create an Enterprise Gist</ButtonText>
224+
<CanonicalName>.GitHub.CreateGistEnterprise</CanonicalName>
225+
<LocCanonicalName>.GitHub.CreateGistEnterprise</LocCanonicalName>
226+
</Strings>
227+
</Button>
228+
217229
<Button guid="guidContextMenuSet" id="openLinkCommand" type="Button">
218230
<Icon guid="guidImages" id="link_external" />
219231
<CommandFlag>IconIsMoniker</CommandFlag>
@@ -303,7 +315,11 @@
303315
<Parent guid="guidContextMenuSet" id="idGitHubContextSubMenuGroup"/>
304316
</CommandPlacement>
305317

306-
<CommandPlacement guid="guidContextMenuSet" id="idBlameCommand" priority="0x104">
318+
<CommandPlacement guid="guidContextMenuSet" id="idCreateGistEnterpriseCommand" priority="0x104">
319+
<Parent guid="guidContextMenuSet" id="idGitHubContextSubMenuGroup"/>
320+
</CommandPlacement>
321+
322+
<CommandPlacement guid="guidContextMenuSet" id="idBlameCommand" priority="0x105">
307323
<Parent guid="guidContextMenuSet" id="idGitHubContextSubMenuGroup"/>
308324
</CommandPlacement>
309325

@@ -410,6 +426,7 @@
410426
<IDSymbol name="copyLinkCommand" value="0x101"/>
411427
<IDSymbol name="goToSolutionOrPullRequestFileCommand" value="0x0102" />
412428
<IDSymbol name="idCreateGistCommand" value="0x0400" />
429+
<IDSymbol name="idCreateGistEnterpriseCommand" value="0x0401" />
413430
<IDSymbol name="idBlameCommand" value="0x0500" />
414431
</GuidSymbol>
415432

src/GitHub.VisualStudio/GitHubPackage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ async Task InitializeMenus()
8585
exports.GetExportedValue<IBlameLinkCommand>(),
8686
exports.GetExportedValue<ICopyLinkCommand>(),
8787
exports.GetExportedValue<ICreateGistCommand>(),
88+
exports.GetExportedValue<ICreateGistEnterpriseCommand>(),
8889
exports.GetExportedValue<IOpenLinkCommand>(),
8990
exports.GetExportedValue<IOpenPullRequestsCommand>(),
9091
exports.GetExportedValue<IShowCurrentPullRequestCommand>(),

0 commit comments

Comments
 (0)