@@ -104,10 +104,8 @@ private void ShowInfoMessage(string messageString)
104
104
private void ClearTreeViews ( )
105
105
{
106
106
tvSecrets . Items . Clear ( ) ;
107
- //tvWorkflows.Items.Clear();
108
107
tvCurrentBranch . ItemsSource = null ;
109
108
CurrentBranchExpander . IsExpanded = false ;
110
- tvEnvironments . Items . Clear ( ) ;
111
109
}
112
110
113
111
private async Task LoadDataAsync ( )
@@ -128,79 +126,94 @@ private async Task LoadDataAsync()
128
126
{
129
127
// get secrets
130
128
var repoSecrets = await client . Repository ? . Actions ? . Secrets ? . GetAll ( _repoInfo . RepoOwner , _repoInfo . RepoName ) ;
131
- foreach ( var secret in repoSecrets . Secrets )
129
+ if ( repoSecrets . TotalCount > 0 )
132
130
{
133
- var updatedOrCreatedAt = secret . UpdatedAt . GetValueOrDefault ( secret . CreatedAt ) ;
134
- var item = new TreeViewItem
131
+ foreach ( var secret in repoSecrets . Secrets )
135
132
{
136
- Header = $ "{ secret . Name } ({ updatedOrCreatedAt : g} )",
137
- Tag = secret ,
138
- } ;
133
+ var updatedOrCreatedAt = secret . UpdatedAt . GetValueOrDefault ( secret . CreatedAt ) ;
134
+ var item = new TreeViewItem
135
+ {
136
+ Header = $ "{ secret . Name } ({ updatedOrCreatedAt : g} )",
137
+ Tag = secret ,
138
+ } ;
139
139
140
- tvSecrets . Items . Add ( item ) ;
140
+ tvSecrets . Items . Add ( item ) ;
141
+ }
142
+ }
143
+ else
144
+ {
145
+ var noSecretItem = new TreeViewItem
146
+ {
147
+ Header = "No repository secrets defined"
148
+ } ;
149
+ tvSecrets . Items . Add ( noSecretItem ) ;
141
150
}
142
-
143
- // get workflows
144
- //var workflows = await client.Actions?.Workflows?.List(_repoInfo.RepoOwner, _repoInfo.RepoName);
145
- //foreach (var workflow in workflows.Workflows)
146
- //{
147
- // var item = new TreeViewItem
148
- // {
149
- // Header = workflow.Name,
150
- // Tag = workflow
151
- // };
152
- // tvWorkflows.Items.Add(item);
153
- //}
154
151
155
152
// get current branch
156
153
var runs = await client . Actions ? . Workflows ? . Runs ? . List ( _repoInfo . RepoOwner , _repoInfo . RepoName , new WorkflowRunsRequest ( ) { Branch = _repoInfo . CurrentBranch } , new ApiOptions ( ) { PageCount = 1 , PageSize = maxRuns } ) ;
157
-
158
- // creating simplified model of the GH info for the treeview
154
+
159
155
List < SimpleRun > runsList = new List < SimpleRun > ( ) ;
160
156
161
- // iterate throught the runs
162
- foreach ( var run in runs . WorkflowRuns )
157
+ if ( runs . TotalCount > 0 )
163
158
{
164
- SimpleRun simpleRun = new ( )
159
+ // creating simplified model of the GH info for the treeview
160
+
161
+ // iterate throught the runs
162
+ foreach ( var run in runs . WorkflowRuns )
165
163
{
166
- Conclusion = run . Conclusion . Value . StringValue ,
167
- Name = run . Name ,
168
- LogDate = run . UpdatedAt ,
169
- Id = run . Id . ToString ( ) ,
170
- RunNumber = run . RunNumber . ToString ( )
171
- } ;
164
+ SimpleRun simpleRun = new ( )
165
+ {
166
+ Conclusion = run . Conclusion . Value . StringValue ,
167
+ Name = run . Name ,
168
+ LogDate = run . UpdatedAt ,
169
+ Id = run . Id . ToString ( ) ,
170
+ RunNumber = run . RunNumber . ToString ( )
171
+ } ;
172
172
173
- // get the jobs for the run
174
- var jobs = await client . Actions . Workflows . Jobs ? . List ( _repoInfo . RepoOwner , _repoInfo . RepoName , run . Id ) ;
173
+ // get the jobs for the run
174
+ var jobs = await client . Actions . Workflows . Jobs ? . List ( _repoInfo . RepoOwner , _repoInfo . RepoName , run . Id ) ;
175
175
176
- List < SimpleJob > simpleJobs = new ( ) ;
176
+ List < SimpleJob > simpleJobs = new ( ) ;
177
177
178
- // iterate through the jobs' steps
179
- foreach ( var job in jobs . Jobs )
180
- {
181
- List < SimpleJob > steps = new ( ) ;
182
- foreach ( var step in job . Steps )
178
+ // iterate through the jobs' steps
179
+ foreach ( var job in jobs . Jobs )
183
180
{
184
- steps . Add ( new SimpleJob ( )
181
+ List < SimpleJob > steps = new ( ) ;
182
+ foreach ( var step in job . Steps )
183
+ {
184
+ steps . Add ( new SimpleJob ( )
185
+ {
186
+ Conclusion = step . Conclusion . Value . StringValue ,
187
+ Name = step . Name ,
188
+ Url = $ "{ job . HtmlUrl } #step:{ step . Number . ToString ( ) } :1"
189
+ } ) ;
190
+ }
191
+ simpleJobs . Add ( new SimpleJob ( )
185
192
{
186
- Conclusion = step . Conclusion . Value . StringValue ,
187
- Name = step . Name ,
188
- Url = $ "{ job . HtmlUrl } #step:{ step . Number . ToString ( ) } :1"
193
+ Conclusion = job . Conclusion . Value . StringValue ,
194
+ Name = job . Name ,
195
+ Id = job . Id . ToString ( ) ,
196
+ Jobs = steps // add the steps to the job
189
197
} ) ;
190
198
}
191
- simpleJobs . Add ( new SimpleJob ( )
192
- {
193
- Conclusion = job . Conclusion . Value . StringValue ,
194
- Name = job . Name ,
195
- Id = job . Id . ToString ( ) ,
196
- Jobs = steps // add the steps to the job
197
- } ) ;
198
- }
199
199
200
- // add the jobs to the run
201
- simpleRun . Jobs = simpleJobs ;
200
+ // add the jobs to the run
201
+ simpleRun . Jobs = simpleJobs ;
202
202
203
- runsList . Add ( simpleRun ) ;
203
+ runsList . Add ( simpleRun ) ;
204
+ }
205
+ }
206
+ else
207
+ {
208
+ // no runs found
209
+ var noRunsItem = new SimpleRun
210
+ {
211
+ Name = "No workflow runs found for query" ,
212
+ Conclusion = "warning" ,
213
+ LogDate = DateTime . Now ,
214
+ RunNumber = "N/A"
215
+ } ;
216
+ runsList . Add ( noRunsItem ) ;
204
217
}
205
218
206
219
tvCurrentBranch . ItemsSource = runsList ;
0 commit comments