Skip to content

Commit

Permalink
Fixing some contrast and conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
timheuer committed Jul 19, 2023
1 parent 32fdfb3 commit 31f6ed4
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 71 deletions.
1 change: 0 additions & 1 deletion src/Converters/ConclusionColorConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
"success" => new SolidColorBrush(Colors.Green),
"failure" => new SolidColorBrush(Colors.Red),
"startup_failure" => new SolidColorBrush(Colors.Red),
"warning" => new SolidColorBrush(Colors.Yellow),
_ => new SolidColorBrush(Colors.Black),
};
}
2 changes: 1 addition & 1 deletion src/Converters/ConclusionIconConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
"waiting" => "\uEA82 ",
"inprogress" => "\uEA82 ",
"in_progress" => "\uEA82 ",
"warning" => "\uEB82 ",
"warning" => "\uEC1F ",
_ => "\uEA74 ",
};
}
14 changes: 0 additions & 14 deletions src/ToolWindows/GHActionsToolWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,12 @@
<Style TargetType="{x:Type TreeView}">
<Setter Property="BorderThickness" Value="0" />
</Style>
<DataTemplate x:Key="EnvironmentHeaderTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="{StaticResource CodiconFont}" Text="&#xEBA3;" VerticalAlignment="Center" />
<TextBlock Text="{Binding}" Margin="5,0" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="SecretsHeaderTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="{StaticResource CodiconFont}" Text="&#xEA75;" VerticalAlignment="Center" />
<TextBlock Text="{Binding}" Margin="5,0" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="VariablesHeaderTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="{StaticResource CodiconFont}" Text="&#xEA93;" VerticalAlignment="Center" />
<TextBlock Text="{Binding}" Margin="5,0" />
</StackPanel>
</DataTemplate>
<HierarchicalDataTemplate x:Key="TreeViewRunNodeDataTemplate" ItemsSource="{Binding Jobs}">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Column="0">
<TextBlock VerticalAlignment="Center" FontFamily="{StaticResource CodiconFont}"
Expand Down Expand Up @@ -73,11 +61,9 @@
</Expander>
<Expander Header="Settings">
<TreeView BorderThickness="0">
<TreeViewItem Header="Environments" HeaderTemplate="{DynamicResource EnvironmentHeaderTemplate}" x:Name="tvEnvironments" />
<TreeViewItem Header="Secrets" HeaderTemplate="{DynamicResource SecretsHeaderTemplate}">
<TreeViewItem Header="Repository Secrets" x:Name="tvSecrets"/>
</TreeViewItem>
<TreeViewItem Header="Variables" HeaderTemplate="{DynamicResource VariablesHeaderTemplate}"/>
</TreeView>
</Expander>
</StackPanel>
Expand Down
123 changes: 68 additions & 55 deletions src/ToolWindows/GHActionsToolWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ private void ShowInfoMessage(string messageString)
private void ClearTreeViews()
{
tvSecrets.Items.Clear();
//tvWorkflows.Items.Clear();
tvCurrentBranch.ItemsSource = null;
CurrentBranchExpander.IsExpanded = false;
tvEnvironments.Items.Clear();
}

private async Task LoadDataAsync()
Expand All @@ -128,79 +126,94 @@ private async Task LoadDataAsync()
{
// get secrets
var repoSecrets = await client.Repository?.Actions?.Secrets?.GetAll(_repoInfo.RepoOwner, _repoInfo.RepoName);
foreach (var secret in repoSecrets.Secrets)
if (repoSecrets.TotalCount > 0)
{
var updatedOrCreatedAt = secret.UpdatedAt.GetValueOrDefault(secret.CreatedAt);
var item = new TreeViewItem
foreach (var secret in repoSecrets.Secrets)
{
Header = $"{secret.Name} ({updatedOrCreatedAt:g})",
Tag = secret,
};
var updatedOrCreatedAt = secret.UpdatedAt.GetValueOrDefault(secret.CreatedAt);
var item = new TreeViewItem
{
Header = $"{secret.Name} ({updatedOrCreatedAt:g})",
Tag = secret,
};

tvSecrets.Items.Add(item);
tvSecrets.Items.Add(item);
}
}
else
{
var noSecretItem = new TreeViewItem
{
Header = "No repository secrets defined"
};
tvSecrets.Items.Add(noSecretItem);
}

// get workflows
//var workflows = await client.Actions?.Workflows?.List(_repoInfo.RepoOwner, _repoInfo.RepoName);
//foreach (var workflow in workflows.Workflows)
//{
// var item = new TreeViewItem
// {
// Header = workflow.Name,
// Tag = workflow
// };
// tvWorkflows.Items.Add(item);
//}

// get current branch
var runs = await client.Actions?.Workflows?.Runs?.List(_repoInfo.RepoOwner, _repoInfo.RepoName, new WorkflowRunsRequest() { Branch = _repoInfo.CurrentBranch }, new ApiOptions() { PageCount = 1, PageSize = maxRuns });

// creating simplified model of the GH info for the treeview

List<SimpleRun> runsList = new List<SimpleRun>();

// iterate throught the runs
foreach (var run in runs.WorkflowRuns)
if (runs.TotalCount > 0)
{
SimpleRun simpleRun = new()
// creating simplified model of the GH info for the treeview

// iterate throught the runs
foreach (var run in runs.WorkflowRuns)
{
Conclusion = run.Conclusion.Value.StringValue,
Name = run.Name,
LogDate = run.UpdatedAt,
Id = run.Id.ToString(),
RunNumber = run.RunNumber.ToString()
};
SimpleRun simpleRun = new()
{
Conclusion = run.Conclusion.Value.StringValue,
Name = run.Name,
LogDate = run.UpdatedAt,
Id = run.Id.ToString(),
RunNumber = run.RunNumber.ToString()
};

// get the jobs for the run
var jobs = await client.Actions.Workflows.Jobs?.List(_repoInfo.RepoOwner, _repoInfo.RepoName, run.Id);
// get the jobs for the run
var jobs = await client.Actions.Workflows.Jobs?.List(_repoInfo.RepoOwner, _repoInfo.RepoName, run.Id);

List<SimpleJob> simpleJobs = new();
List<SimpleJob> simpleJobs = new();

// iterate through the jobs' steps
foreach (var job in jobs.Jobs)
{
List<SimpleJob> steps = new();
foreach (var step in job.Steps)
// iterate through the jobs' steps
foreach (var job in jobs.Jobs)
{
steps.Add(new SimpleJob()
List<SimpleJob> steps = new();
foreach (var step in job.Steps)
{
steps.Add(new SimpleJob()
{
Conclusion = step.Conclusion.Value.StringValue,
Name = step.Name,
Url = $"{job.HtmlUrl}#step:{step.Number.ToString()}:1"
});
}
simpleJobs.Add(new SimpleJob()
{
Conclusion = step.Conclusion.Value.StringValue,
Name = step.Name,
Url = $"{job.HtmlUrl}#step:{step.Number.ToString()}:1"
Conclusion = job.Conclusion.Value.StringValue,
Name = job.Name,
Id = job.Id.ToString(),
Jobs = steps // add the steps to the job
});
}
simpleJobs.Add(new SimpleJob()
{
Conclusion = job.Conclusion.Value.StringValue,
Name = job.Name,
Id = job.Id.ToString(),
Jobs = steps // add the steps to the job
});
}

// add the jobs to the run
simpleRun.Jobs = simpleJobs;
// add the jobs to the run
simpleRun.Jobs = simpleJobs;

runsList.Add(simpleRun);
runsList.Add(simpleRun);
}
}
else
{
// no runs found
var noRunsItem = new SimpleRun
{
Name = "No workflow runs found for query",
Conclusion = "warning",
LogDate = DateTime.Now,
RunNumber = "N/A"
};
runsList.Add(noRunsItem);
}

tvCurrentBranch.ItemsSource = runsList;
Expand Down

0 comments on commit 31f6ed4

Please sign in to comment.