Skip to content

Commit

Permalink
Adding links to logs
Browse files Browse the repository at this point in the history
- Added icons to menus
- Added view log context menu
  • Loading branch information
timheuer committed Jul 21, 2023
1 parent 6b40399 commit e18bb28
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 9 deletions.
17 changes: 17 additions & 0 deletions src/Converters/NullToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace GitHubActionsVS.Converters;
public class NullToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value == null ? Visibility.Hidden: Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
10 changes: 7 additions & 3 deletions src/GitHubActionsVS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Compile Include="Commands\RefreshRepoCommand.cs" />
<Compile Include="Converters\ConclusionColorConverter.cs" />
<Compile Include="Converters\ConclusionIconConverter.cs" />
<Compile Include="Converters\NullToVisibilityConverter.cs" />
<Compile Include="Helpers\CredentialManager.cs" />
<Compile Include="Helpers\RepoInfo.cs" />
<Compile Include="Models\BaseWorkflowType.cs" />
Expand Down Expand Up @@ -80,6 +81,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Resource Include="Resources\OpenWebSite.png" />
<Resource Include="Resources\codicon.ttf" />
<Content Include="LICENSE">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand All @@ -93,10 +95,12 @@
<IncludeInVSIX>true</IncludeInVSIX>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\Icon.png">
<Resource Include="Resources\AddItem.png" />
<Resource Include="Resources\Delete.png" />
<Resource Include="Resources\Edit.png" />
<Resource Include="Resources\Icon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
</Resource>
</ItemGroup>
<ItemGroup>
<VSCTCompile Include="VSCommandTable.vsct">
Expand Down
Binary file added src/Resources/AddItem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Resources/Delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Resources/Edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Resources/OpenWebSite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 27 additions & 4 deletions src/ToolWindows/GHActionsToolWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<FontFamily x:Key="CodiconFont">pack://application:,,,/GitHubActionsVS;component/Resources/#codicon</FontFamily>
<ivc:ConclusionIconConverter x:Key="ConclusionIconConverter" />
<ivc:ConclusionColorConverter x:Key="ConclusionColorConverter" />
<ivc:NullToVisibilityConverter x:Key="NullVisibilityConverter" />
<Style TargetType="{x:Type Expander}">
<Setter Property="toolkit:Themes.UseVsTheme" Value="True" />
</Style>
Expand All @@ -35,7 +36,11 @@
<TextBlock Text="{Binding}">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Header="Add Secret" Click="AddSecret_Click" />
<MenuItem Header="Add Secret" Click="AddSecret_Click">
<MenuItem.Icon>
<Image Source="pack://application:,,,/GitHubActionsVS;component/Resources/AddItem.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
Expand All @@ -45,7 +50,17 @@
<TextBlock VerticalAlignment="Center" FontFamily="{StaticResource CodiconFont}"
Foreground="{Binding Path=Conclusion, Converter={StaticResource ConclusionColorConverter}}"
Text="{Binding Path=Conclusion, Converter={StaticResource ConclusionIconConverter}}"/>
<emoji:TextBlock Text="{Binding DisplayName}" VerticalAlignment="Bottom" />
<emoji:TextBlock Text="{Binding DisplayName}" VerticalAlignment="Bottom" Tag="{Binding Url}">
<TextBlock.ContextMenu>
<ContextMenu Visibility="{Binding Url, Converter={StaticResource NullVisibilityConverter}}">
<MenuItem Header="View Log" Click="ViewLog_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}">
<MenuItem.Icon>
<Image Source="pack://application:,,,/GitHubActionsVS;component/Resources/OpenWebSite.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</TextBlock.ContextMenu>
</emoji:TextBlock>
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate x:Key="EnvironmentItemTemplate">
Expand Down Expand Up @@ -75,8 +90,16 @@
<TextBlock Text="{Binding}">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Header="Edit Secret" Click="EditSecret_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}" />
<MenuItem Header="Delete Secret" Click="DeleteSecret_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}" />
<MenuItem Header="Edit Secret" Click="EditSecret_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}">
<MenuItem.Icon>
<Image Source="pack://application:,,,/GitHubActionsVS;component/Resources/Edit.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Delete Secret" Click="DeleteSecret_Click" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}}">
<MenuItem.Icon>
<Image Source="pack://application:,,,/GitHubActionsVS;component/Resources/Delete.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
Expand Down
17 changes: 15 additions & 2 deletions src/ToolWindows/GHActionsToolWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private async void EditSecret_Click(object sender, RoutedEventArgs e)
{
MenuItem menuItem = (MenuItem)sender;
TextBlock tvi = GetParentTreeViewItem(menuItem);
if (tvi is not null)
if (tvi is not null && tvi.Text.ToLowerInvariant() != "no repository secrets defined") // yes a hack
{
string header = tvi.Text.ToString();
string secretName = header.Substring(0, header.IndexOf(" ("));
Expand All @@ -360,7 +360,7 @@ private async void DeleteSecret_Click(object sender, RoutedEventArgs e)
MenuItem menuItem = (MenuItem)sender;
TextBlock tvi = GetParentTreeViewItem(menuItem);

if (tvi is not null)
if (tvi is not null && tvi.Text.ToLowerInvariant() != "no repository secrets defined") // yes a hack
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
// confirm the delete first
Expand Down Expand Up @@ -405,5 +405,18 @@ private async Task UpsertRepositorySecret(string secretName)
await RefreshSecretsAsync(client);
}
}

private void ViewLog_Click(object sender, RoutedEventArgs e)
{
MenuItem menuItem = (MenuItem)sender;
TextBlock tvi = GetParentTreeViewItem(menuItem);

// check the tag value to ensure it isn't null
if (tvi is not null && tvi.Tag is not null)
{
string logUrl = tvi.Tag.ToString();
Process.Start(logUrl);
}
}
}

0 comments on commit e18bb28

Please sign in to comment.