Skip to content

Commit 4d00c4a

Browse files
authored
Merge pull request #1713 from github/charis-nora/introduce-error-view-in-db-panel
Introduce error in new db panel
2 parents 3dbd071 + 99e523f commit 4d00c4a

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

extensions/ql-vscode/src/databases/ui/db-tree-data-provider.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { logger } from '../../logging';
22
import { ProviderResult, TreeDataProvider, TreeItem } from 'vscode';
3-
import { DbTreeViewItem } from './db-tree-view-item';
3+
import { createDbTreeViewItemWarning, DbTreeViewItem } from './db-tree-view-item';
44
import { DbManager } from '../db-manager';
55

66
export class DbTreeDataProvider implements TreeDataProvider<DbTreeViewItem> {
@@ -41,6 +41,12 @@ export class DbTreeDataProvider implements TreeDataProvider<DbTreeViewItem> {
4141
// This will be fleshed out in a future change.
4242
void logger.log(`Creating database tree with ${dbItems.length} items`);
4343

44-
return [];
44+
// Add a sample warning as a proof of concept.
45+
const warningTreeViewItem = createDbTreeViewItemWarning(
46+
'There was an error',
47+
'Fix it'
48+
);
49+
50+
return [warningTreeViewItem];
4551
}
4652
}

extensions/ql-vscode/src/databases/ui/db-tree-view-item.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import * as vscode from 'vscode';
22
import { DbItem } from '../db-item';
33

44
/**
5-
* Represents an item in the database tree view.
5+
* Represents an item in the database tree view. This item could be
6+
* representing an actual database item or a warning.
67
*/
78
export class DbTreeViewItem extends vscode.TreeItem {
89
constructor(
9-
public readonly dbItem: DbItem,
10+
public readonly dbItem: DbItem | undefined,
11+
public readonly iconPath: vscode.ThemeIcon,
1012
public readonly label: string,
1113
public readonly tooltip: string,
1214
public readonly collapsibleState: vscode.TreeItemCollapsibleState,
@@ -15,3 +17,14 @@ export class DbTreeViewItem extends vscode.TreeItem {
1517
super(label, collapsibleState);
1618
}
1719
}
20+
21+
export function createDbTreeViewItemWarning(label: string, tooltip: string): DbTreeViewItem {
22+
return new DbTreeViewItem(
23+
undefined,
24+
new vscode.ThemeIcon('warning', new vscode.ThemeColor('problemsWarningIcon.foreground')),
25+
label,
26+
tooltip,
27+
vscode.TreeItemCollapsibleState.None,
28+
[]
29+
);
30+
}

0 commit comments

Comments
 (0)