Skip to content

Commit cf2dec9

Browse files
authored
Merge pull request #2004 from github/nora/update-query-history-icons
Query history polish: new icons
2 parents 407aa14 + 5342b5b commit cf2dec9

File tree

4 files changed

+19
-75
lines changed

4 files changed

+19
-75
lines changed

extensions/ql-vscode/media/drive.svg

Lines changed: 0 additions & 7 deletions
This file was deleted.

extensions/ql-vscode/media/globe.svg

Lines changed: 0 additions & 16 deletions
This file was deleted.

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

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ExtensionContext,
99
ProviderResult,
1010
Range,
11+
ThemeColor,
1112
ThemeIcon,
1213
TreeDataProvider,
1314
TreeItem,
@@ -101,21 +102,6 @@ const SHOW_QUERY_TEXT_QUICK_EVAL_MSG = `\
101102
102103
`;
103104

104-
/**
105-
* Path to icon to display next to a failed query history item.
106-
*/
107-
const FAILED_QUERY_HISTORY_ITEM_ICON = "media/red-x.svg";
108-
109-
/**
110-
* Path to icon to display next to a successful local run.
111-
*/
112-
const LOCAL_SUCCESS_QUERY_HISTORY_ITEM_ICON = "media/drive.svg";
113-
114-
/**
115-
* Path to icon to display next to a successful remote run.
116-
*/
117-
const REMOTE_SUCCESS_QUERY_HISTORY_ITEM_ICON = "media/globe.svg";
118-
119105
export enum SortOrder {
120106
NameAsc = "NameAsc",
121107
NameDesc = "NameDesc",
@@ -158,28 +144,10 @@ export class HistoryTreeDataProvider
158144

159145
private history: QueryHistoryInfo[] = [];
160146

161-
private failedIconPath: string;
162-
163-
private localSuccessIconPath: string;
164-
165-
private remoteSuccessIconPath: string;
166-
167147
private current: QueryHistoryInfo | undefined;
168148

169-
constructor(
170-
extensionPath: string,
171-
private readonly labelProvider: HistoryItemLabelProvider,
172-
) {
149+
constructor(private readonly labelProvider: HistoryItemLabelProvider) {
173150
super();
174-
this.failedIconPath = join(extensionPath, FAILED_QUERY_HISTORY_ITEM_ICON);
175-
this.localSuccessIconPath = join(
176-
extensionPath,
177-
LOCAL_SUCCESS_QUERY_HISTORY_ITEM_ICON,
178-
);
179-
this.remoteSuccessIconPath = join(
180-
extensionPath,
181-
REMOTE_SUCCESS_QUERY_HISTORY_ITEM_ICON,
182-
);
183151
}
184152

185153
async getTreeItem(element: QueryHistoryInfo): Promise<TreeItem> {
@@ -206,12 +174,12 @@ export class HistoryTreeDataProvider
206174
return new ThemeIcon("sync~spin");
207175
case QueryStatus.Completed:
208176
if (element.t === "local") {
209-
return this.localSuccessIconPath;
177+
return new ThemeIcon("database");
210178
} else {
211-
return this.remoteSuccessIconPath;
179+
return new ThemeIcon("cloud");
212180
}
213181
case QueryStatus.Failed:
214-
return this.failedIconPath;
182+
return new ThemeIcon("error", new ThemeColor("errorForeground"));
215183
default:
216184
assertNever(element.status);
217185
}
@@ -421,7 +389,7 @@ export class QueryHistoryManager extends DisposableObject {
421389
);
422390

423391
this.treeDataProvider = this.push(
424-
new HistoryTreeDataProvider(ctx.extensionPath, this.labelProvider),
392+
new HistoryTreeDataProvider(this.labelProvider),
425393
);
426394
this.treeView = this.push(
427395
window.createTreeView("codeQLQueryHistory", {

extensions/ql-vscode/test/vscode-tests/no-workspace/query-history/query-history.test.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,10 +1652,7 @@ describe("query-history", () => {
16521652
labelProvider = new HistoryItemLabelProvider({
16531653
/**/
16541654
} as QueryHistoryConfig);
1655-
historyTreeDataProvider = new HistoryTreeDataProvider(
1656-
vscode.Uri.file(mockExtensionLocation).fsPath,
1657-
labelProvider,
1658-
);
1655+
historyTreeDataProvider = new HistoryTreeDataProvider(labelProvider);
16591656
});
16601657

16611658
afterEach(() => {
@@ -1683,9 +1680,7 @@ describe("query-history", () => {
16831680
});
16841681
expect(treeItem.label).toContain("query-file.ql");
16851682
expect(treeItem.contextValue).toBe("rawResultsItem");
1686-
expect(treeItem.iconPath).toEqual(
1687-
vscode.Uri.file(`${mockExtensionLocation}/media/drive.svg`).fsPath,
1688-
);
1683+
expect(treeItem.iconPath).toEqual(new vscode.ThemeIcon("database"));
16891684
});
16901685

16911686
it("should get a tree item with interpreted results", async () => {
@@ -1701,9 +1696,7 @@ describe("query-history", () => {
17011696
mockQueryWithInterpretedResults,
17021697
);
17031698
expect(treeItem.contextValue).toBe("interpretedResultsItem");
1704-
expect(treeItem.iconPath).toEqual(
1705-
vscode.Uri.file(`${mockExtensionLocation}/media/drive.svg`).fsPath,
1706-
);
1699+
expect(treeItem.iconPath).toEqual(new vscode.ThemeIcon("database"));
17071700
});
17081701

17091702
it("should get a tree item that did not complete successfully", async () => {
@@ -1716,8 +1709,11 @@ describe("query-history", () => {
17161709
});
17171710

17181711
const treeItem = await historyTreeDataProvider.getTreeItem(mockQuery);
1719-
expect(treeItem.iconPath).toBe(
1720-
vscode.Uri.file(`${mockExtensionLocation}/media/red-x.svg`).fsPath,
1712+
expect(treeItem.iconPath).toEqual(
1713+
new vscode.ThemeIcon(
1714+
"error",
1715+
new vscode.ThemeColor("errorForeground"),
1716+
),
17211717
);
17221718
});
17231719

@@ -1728,8 +1724,11 @@ describe("query-history", () => {
17281724
});
17291725

17301726
const treeItem = await historyTreeDataProvider.getTreeItem(mockQuery);
1731-
expect(treeItem.iconPath).toBe(
1732-
vscode.Uri.file(`${mockExtensionLocation}/media/red-x.svg`).fsPath,
1727+
expect(treeItem.iconPath).toEqual(
1728+
new vscode.ThemeIcon(
1729+
"error",
1730+
new vscode.ThemeColor("errorForeground"),
1731+
),
17331732
);
17341733
});
17351734

0 commit comments

Comments
 (0)