Skip to content

Commit afc0d4e

Browse files
Merge pull request #1697 from github/robertbrignull/open_pending_analysis
Don't show "open on github" link when we don't yet have anything to show
2 parents 7296c64 + aac9971 commit afc0d4e

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

extensions/ql-vscode/src/query-history.ts

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,33 +173,53 @@ export class HistoryTreeDataProvider extends DisposableObject implements TreeDat
173173

174174
// Populate the icon and the context value. We use the context value to
175175
// control which commands are visible in the context menu.
176-
let hasResults;
176+
treeItem.iconPath = this.getIconPath(element);
177+
treeItem.contextValue = await this.getContextValue(element);
178+
179+
return treeItem;
180+
}
181+
182+
private getIconPath(element: QueryHistoryInfo): ThemeIcon | string {
177183
switch (element.status) {
178184
case QueryStatus.InProgress:
179-
treeItem.iconPath = new ThemeIcon('sync~spin');
180-
treeItem.contextValue = element.t === 'local' ? 'inProgressResultsItem' : 'inProgressRemoteResultsItem';
181-
break;
185+
return new ThemeIcon('sync~spin');
186+
case QueryStatus.Completed:
187+
if (element.t === 'local') {
188+
return this.localSuccessIconPath;
189+
} else {
190+
return this.remoteSuccessIconPath;
191+
}
192+
case QueryStatus.Failed:
193+
return this.failedIconPath;
194+
default:
195+
assertNever(element.status);
196+
}
197+
}
198+
199+
private async getContextValue(element: QueryHistoryInfo): Promise<string> {
200+
switch (element.status) {
201+
case QueryStatus.InProgress:
202+
if (element.t === 'local') {
203+
return 'inProgressResultsItem';
204+
} else if (element.t === 'variant-analysis' && element.variantAnalysis.actionsWorkflowRunId === undefined) {
205+
return 'pendingRemoteResultsItem';
206+
} else {
207+
return 'inProgressRemoteResultsItem';
208+
}
182209
case QueryStatus.Completed:
183210
if (element.t === 'local') {
184-
hasResults = await element.completedQuery?.query.hasInterpretedResults();
185-
treeItem.iconPath = this.localSuccessIconPath;
186-
treeItem.contextValue = hasResults
211+
const hasResults = await element.completedQuery?.query.hasInterpretedResults();
212+
return hasResults
187213
? 'interpretedResultsItem'
188214
: 'rawResultsItem';
189215
} else {
190-
treeItem.iconPath = this.remoteSuccessIconPath;
191-
treeItem.contextValue = 'remoteResultsItem';
216+
return 'remoteResultsItem';
192217
}
193-
break;
194218
case QueryStatus.Failed:
195-
treeItem.iconPath = this.failedIconPath;
196-
treeItem.contextValue = element.t === 'local' ? 'cancelledResultsItem' : 'cancelledRemoteResultsItem';
197-
break;
219+
return element.t === 'local' ? 'cancelledResultsItem' : 'cancelledRemoteResultsItem';
198220
default:
199221
assertNever(element.status);
200222
}
201-
202-
return treeItem;
203223
}
204224

205225
getChildren(

0 commit comments

Comments
 (0)