Skip to content

Commit 1a08ae4

Browse files
committed
Move db item expansion models to db-item-expansion
1 parent 5e864ae commit 1a08ae4

6 files changed

Lines changed: 42 additions & 43 deletions

File tree

extensions/ql-vscode/src/databases/config/db-config.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -87,37 +87,6 @@ export interface LocalDatabase {
8787
storagePath: string;
8888
}
8989

90-
export type ExpandedDbItem =
91-
| RootLocalExpandedDbItem
92-
| LocalUserDefinedListExpandedDbItem
93-
| RootRemoteExpandedDbItem
94-
| RemoteUserDefinedListExpandedDbItem;
95-
96-
export enum ExpandedDbItemKind {
97-
RootLocal = "rootLocal",
98-
LocalUserDefinedList = "localUserDefinedList",
99-
RootRemote = "rootRemote",
100-
RemoteUserDefinedList = "remoteUserDefinedList",
101-
}
102-
103-
export interface RootLocalExpandedDbItem {
104-
kind: ExpandedDbItemKind.RootLocal;
105-
}
106-
107-
export interface LocalUserDefinedListExpandedDbItem {
108-
kind: ExpandedDbItemKind.LocalUserDefinedList;
109-
listName: string;
110-
}
111-
112-
export interface RootRemoteExpandedDbItem {
113-
kind: ExpandedDbItemKind.RootRemote;
114-
}
115-
116-
export interface RemoteUserDefinedListExpandedDbItem {
117-
kind: ExpandedDbItemKind.RemoteUserDefinedList;
118-
listName: string;
119-
}
120-
12190
export function cloneDbConfig(config: DbConfig): DbConfig {
12291
return {
12392
databases: {

extensions/ql-vscode/src/databases/db-item-expansion.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
1-
import { ExpandedDbItem, ExpandedDbItemKind } from "./config/db-config";
21
import { DbItem, DbItemKind } from "./db-item";
32

3+
export type ExpandedDbItem =
4+
| RootLocalExpandedDbItem
5+
| LocalUserDefinedListExpandedDbItem
6+
| RootRemoteExpandedDbItem
7+
| RemoteUserDefinedListExpandedDbItem;
8+
9+
export enum ExpandedDbItemKind {
10+
RootLocal = "rootLocal",
11+
LocalUserDefinedList = "localUserDefinedList",
12+
RootRemote = "rootRemote",
13+
RemoteUserDefinedList = "remoteUserDefinedList",
14+
}
15+
16+
export interface RootLocalExpandedDbItem {
17+
kind: ExpandedDbItemKind.RootLocal;
18+
}
19+
20+
export interface LocalUserDefinedListExpandedDbItem {
21+
kind: ExpandedDbItemKind.LocalUserDefinedList;
22+
listName: string;
23+
}
24+
25+
export interface RootRemoteExpandedDbItem {
26+
kind: ExpandedDbItemKind.RootRemote;
27+
}
28+
29+
export interface RemoteUserDefinedListExpandedDbItem {
30+
kind: ExpandedDbItemKind.RemoteUserDefinedList;
31+
listName: string;
32+
}
33+
434
export function calculateNewExpandedState(
535
currentExpandedItems: ExpandedDbItem[],
636
dbItem: DbItem,

extensions/ql-vscode/src/databases/db-manager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { App } from "../common/app";
22
import { AppEvent, AppEventEmitter } from "../common/events";
33
import { ValueResult } from "../common/value-result";
4-
import { ExpandedDbItem } from "./config/db-config";
54
import { DbConfigStore } from "./config/db-config-store";
65
import { DbItem, DbListKind } from "./db-item";
7-
import { calculateNewExpandedState } from "./db-item-expansion";
6+
import { calculateNewExpandedState, ExpandedDbItem } from "./db-item-expansion";
87
import {
98
getSelectedDbItem,
109
mapDbItemToSelectedDbItem,

extensions/ql-vscode/src/databases/db-tree-creator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {
22
DbConfig,
3-
ExpandedDbItem,
4-
ExpandedDbItemKind,
53
LocalDatabase,
64
LocalList,
75
RemoteRepositoryList,
@@ -18,6 +16,7 @@ import {
1816
RootLocalDbItem,
1917
RootRemoteDbItem,
2018
} from "./db-item";
19+
import { ExpandedDbItem, ExpandedDbItemKind } from "./db-item-expansion";
2120

2221
export function createRemoteTree(
2322
dbConfig: DbConfig,

extensions/ql-vscode/test/unit-tests/databases/db-item-expansion.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import {
2-
ExpandedDbItem,
3-
ExpandedDbItemKind,
4-
} from "../../../src/databases/config/db-config";
51
import {
62
RemoteUserDefinedListDbItem,
73
RootRemoteDbItem,
84
} from "../../../src/databases/db-item";
9-
import { calculateNewExpandedState } from "../../../src/databases/db-item-expansion";
5+
import {
6+
calculateNewExpandedState,
7+
ExpandedDbItem,
8+
ExpandedDbItemKind,
9+
} from "../../../src/databases/db-item-expansion";
1010
import {
1111
createRemoteUserDefinedListDbItem,
1212
createRootRemoteDbItem,

extensions/ql-vscode/test/unit-tests/databases/db-tree-creator.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {
22
DbConfig,
3-
ExpandedDbItem,
4-
ExpandedDbItemKind,
53
SelectedDbItemKind,
64
} from "../../../src/databases/config/db-config";
75
import {
@@ -10,6 +8,10 @@ import {
108
isRemoteRepoDbItem,
119
isRemoteUserDefinedListDbItem,
1210
} from "../../../src/databases/db-item";
11+
import {
12+
ExpandedDbItem,
13+
ExpandedDbItemKind,
14+
} from "../../../src/databases/db-item-expansion";
1315
import {
1416
createLocalTree,
1517
createRemoteTree,

0 commit comments

Comments
 (0)