Skip to content

Commit e18bb28

Browse files
committed
Adding links to logs
- Added icons to menus - Added view log context menu
1 parent 6b40399 commit e18bb28

File tree

8 files changed

+66
-9
lines changed

8 files changed

+66
-9
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Globalization;
2+
using System.Windows;
3+
using System.Windows.Data;
4+
5+
namespace GitHubActionsVS.Converters;
6+
public class NullToVisibilityConverter : IValueConverter
7+
{
8+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9+
{
10+
return value == null ? Visibility.Hidden: Visibility.Visible;
11+
}
12+
13+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
14+
{
15+
throw new NotImplementedException();
16+
}
17+
}

src/GitHubActionsVS.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<Compile Include="Commands\RefreshRepoCommand.cs" />
5050
<Compile Include="Converters\ConclusionColorConverter.cs" />
5151
<Compile Include="Converters\ConclusionIconConverter.cs" />
52+
<Compile Include="Converters\NullToVisibilityConverter.cs" />
5253
<Compile Include="Helpers\CredentialManager.cs" />
5354
<Compile Include="Helpers\RepoInfo.cs" />
5455
<Compile Include="Models\BaseWorkflowType.cs" />
@@ -80,6 +81,7 @@
8081
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
8182
<IncludeInVSIX>true</IncludeInVSIX>
8283
</Content>
84+
<Resource Include="Resources\OpenWebSite.png" />
8385
<Resource Include="Resources\codicon.ttf" />
8486
<Content Include="LICENSE">
8587
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -93,10 +95,12 @@
9395
<IncludeInVSIX>true</IncludeInVSIX>
9496
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
9597
</Content>
96-
<Content Include="Resources\Icon.png">
98+
<Resource Include="Resources\AddItem.png" />
99+
<Resource Include="Resources\Delete.png" />
100+
<Resource Include="Resources\Edit.png" />
101+
<Resource Include="Resources\Icon.png">
97102
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
98-
<IncludeInVSIX>true</IncludeInVSIX>
99-
</Content>
103+
</Resource>
100104
</ItemGroup>
101105
<ItemGroup>
102106
<VSCTCompile Include="VSCommandTable.vsct">

src/Resources/AddItem.png

271 Bytes
Loading

src/Resources/Delete.png

291 Bytes
Loading

src/Resources/Edit.png

643 Bytes
Loading

src/Resources/OpenWebSite.png

1.36 KB
Loading

src/ToolWindows/GHActionsToolWindow.xaml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<FontFamily x:Key="CodiconFont">pack://application:,,,/GitHubActionsVS;component/Resources/#codicon</FontFamily>
2020
<ivc:ConclusionIconConverter x:Key="ConclusionIconConverter" />
2121
<ivc:ConclusionColorConverter x:Key="ConclusionColorConverter" />
22+
<ivc:NullToVisibilityConverter x:Key="NullVisibilityConverter" />
2223
<Style TargetType="{x:Type Expander}">
2324
<Setter Property="toolkit:Themes.UseVsTheme" Value="True" />
2425
</Style>
@@ -35,7 +36,11 @@
3536
<TextBlock Text="{Binding}">
3637
<TextBlock.ContextMenu>
3738
<ContextMenu>
38-
<MenuItem Header="Add Secret" Click="AddSecret_Click" />
39+
<MenuItem Header="Add Secret" Click="AddSecret_Click">
40+
<MenuItem.Icon>
41+
<Image Source="pack://application:,,,/GitHubActionsVS;component/Resources/AddItem.png" />
42+
</MenuItem.Icon>
43+
</MenuItem>
3944
</ContextMenu>
4045
</TextBlock.ContextMenu>
4146
</TextBlock>
@@ -45,7 +50,17 @@
4550
<TextBlock VerticalAlignment="Center" FontFamily="{StaticResource CodiconFont}"
4651
Foreground="{Binding Path=Conclusion, Converter={StaticResource ConclusionColorConverter}}"
4752
Text="{Binding Path=Conclusion, Converter={StaticResource ConclusionIconConverter}}"/>
48-
<emoji:TextBlock Text="{Binding DisplayName}" VerticalAlignment="Bottom" />
53+
<emoji:TextBlock Text="{Binding DisplayName}" VerticalAlignment="Bottom" Tag="{Binding Url}">
54+
<TextBlock.ContextMenu>
55+
<ContextMenu Visibility="{Binding Url, Converter={StaticResource NullVisibilityConverter}}">
56+
<MenuItem Header="View Log" Click="ViewLog_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}">
57+
<MenuItem.Icon>
58+
<Image Source="pack://application:,,,/GitHubActionsVS;component/Resources/OpenWebSite.png" />
59+
</MenuItem.Icon>
60+
</MenuItem>
61+
</ContextMenu>
62+
</TextBlock.ContextMenu>
63+
</emoji:TextBlock>
4964
</StackPanel>
5065
</HierarchicalDataTemplate>
5166
<DataTemplate x:Key="EnvironmentItemTemplate">
@@ -75,8 +90,16 @@
7590
<TextBlock Text="{Binding}">
7691
<TextBlock.ContextMenu>
7792
<ContextMenu>
78-
<MenuItem Header="Edit Secret" Click="EditSecret_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}" />
79-
<MenuItem Header="Delete Secret" Click="DeleteSecret_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}" />
93+
<MenuItem Header="Edit Secret" Click="EditSecret_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}">
94+
<MenuItem.Icon>
95+
<Image Source="pack://application:,,,/GitHubActionsVS;component/Resources/Edit.png" />
96+
</MenuItem.Icon>
97+
</MenuItem>
98+
<MenuItem Header="Delete Secret" Click="DeleteSecret_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}">
99+
<MenuItem.Icon>
100+
<Image Source="pack://application:,,,/GitHubActionsVS;component/Resources/Delete.png" />
101+
</MenuItem.Icon>
102+
</MenuItem>
80103
</ContextMenu>
81104
</TextBlock.ContextMenu>
82105
</TextBlock>

src/ToolWindows/GHActionsToolWindow.xaml.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ private async void EditSecret_Click(object sender, RoutedEventArgs e)
333333
{
334334
MenuItem menuItem = (MenuItem)sender;
335335
TextBlock tvi = GetParentTreeViewItem(menuItem);
336-
if (tvi is not null)
336+
if (tvi is not null && tvi.Text.ToLowerInvariant() != "no repository secrets defined") // yes a hack
337337
{
338338
string header = tvi.Text.ToString();
339339
string secretName = header.Substring(0, header.IndexOf(" ("));
@@ -360,7 +360,7 @@ private async void DeleteSecret_Click(object sender, RoutedEventArgs e)
360360
MenuItem menuItem = (MenuItem)sender;
361361
TextBlock tvi = GetParentTreeViewItem(menuItem);
362362

363-
if (tvi is not null)
363+
if (tvi is not null && tvi.Text.ToLowerInvariant() != "no repository secrets defined") // yes a hack
364364
{
365365
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
366366
// confirm the delete first
@@ -405,5 +405,18 @@ private async Task UpsertRepositorySecret(string secretName)
405405
await RefreshSecretsAsync(client);
406406
}
407407
}
408+
409+
private void ViewLog_Click(object sender, RoutedEventArgs e)
410+
{
411+
MenuItem menuItem = (MenuItem)sender;
412+
TextBlock tvi = GetParentTreeViewItem(menuItem);
413+
414+
// check the tag value to ensure it isn't null
415+
if (tvi is not null && tvi.Tag is not null)
416+
{
417+
string logUrl = tvi.Tag.ToString();
418+
Process.Start(logUrl);
419+
}
420+
}
408421
}
409422

0 commit comments

Comments
 (0)