Skip to content

Commit

Permalink
Fixed error message and added settings shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
timheuer committed Aug 19, 2023
1 parent c6e2660 commit db0b33f
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 6 deletions.
18 changes: 18 additions & 0 deletions src/Commands/OpenSettingsCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using GitHubActionsVS.ToolWindows;

namespace GitHubActionsVS;

[Command(PackageIds.OpenSettingsCommand)]
internal sealed class OpenSettingsCommand : BaseCommand<OpenSettingsCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
ToolWindowMessenger messenger = await Package.GetServiceAsync<ToolWindowMessenger, ToolWindowMessenger>();
messenger.Send(new(MessageCommand.OpenSettings));
}).FireAndForget();
}
}
4 changes: 1 addition & 3 deletions src/Converters/ConclusionColorConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Newtonsoft.Json.Linq;
using System.Globalization;
using System.Windows;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

Expand Down
2 changes: 2 additions & 0 deletions src/GitHubActionsVS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="Commands\GotoRepoCommand.cs" />
<Compile Include="Commands\OpenSettingsCommand.cs" />
<Compile Include="Commands\RefreshRepoCommand.cs" />
<Compile Include="Converters\ConclusionColorConverter.cs" />
<Compile Include="Converters\ConclusionIconConverter.cs" />
Expand Down Expand Up @@ -184,6 +185,7 @@
<EmbeddedResource Include="Resources\UIStrings.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>UIStrings.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/UIStrings.Designer.cs

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

2 changes: 1 addition & 1 deletion src/Resources/UIStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
<comment>Menu for editing a secret</comment>
</data>
<data name="GIT_NOT_GITHUB" xml:space="preserve">
<value>Repo found, but not a github.com</value>
<value>Repository found, but not identified as a GitHub repo. Please open a folder that contains a GitHub repository.</value>
<comment>For when the git repo is not github.com</comment>
</data>
<data name="HEADER_CURRENT_BRANCH" xml:space="preserve">
Expand Down
6 changes: 6 additions & 0 deletions src/ToolWindows/GHActionsToolWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ private void OnMessageReceived(object sender, MessagePayload payload)
{
MessageCommand.Refresh => GetRepoInfoAsync(),
MessageCommand.GotoRepo => GotoRepoAsync(),
MessageCommand.OpenSettings => OpenSettingsAsync(),
_ => Task.CompletedTask
});
}).FireAndForget();
}

private async Task OpenSettingsAsync()
{
await VS.Settings.OpenAsync(typeof(OptionsProvider.ExtensionOptionsOptions));
}

private Task GotoRepoAsync()
{
if (_repoInfo is { RepoUrl.Length: > 0 })
Expand Down
3 changes: 2 additions & 1 deletion src/ToolWindows/MessageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public enum MessageCommand
{
GotoRepo,
Refresh
Refresh,
OpenSettings
}
1 change: 1 addition & 0 deletions src/VSCommandTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ internal sealed partial class PackageIds
public const int TWindowToolbarGroup = 0x1050;
public const int RefreshRepoCommand = 0x0111;
public const int GotoRepoCommand = 0x0112;
public const int OpenSettingsCommand = 0x0113;
}
}
10 changes: 10 additions & 0 deletions src/VSCommandTable.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@
<LocCanonicalName>.View.GotoRepo</LocCanonicalName>
</Strings>
</Button>
<Button guid="GitHubActionsVS" id="OpenSettingsCommand" priority="0x0003" type="Button">
<Parent guid="GitHubActionsVS" id="TWindowToolbarGroup"/>
<Icon guid="ImageCatalogGuid" id="Settings"/>
<CommandFlag>IconIsMoniker</CommandFlag>
<Strings>
<ButtonText>Open Settings</ButtonText>
<LocCanonicalName>.View.OpenSettings</LocCanonicalName>
</Strings>
</Button>
</Buttons>
</Commands>

Expand All @@ -74,6 +83,7 @@
<IDSymbol name="TWindowToolbarGroup" value="0x1050" />
<IDSymbol name="RefreshRepoCommand" value="0x0111" />
<IDSymbol name="GotoRepoCommand" value="0x0112" />
<IDSymbol name="OpenSettingsCommand" value="0x0113" />
</GuidSymbol>
</Symbols>
</CommandTable>

0 comments on commit db0b33f

Please sign in to comment.