Skip to content

Commit acbd973

Browse files
committed
db-manager: remove tests and functionality
1 parent 9f667ef commit acbd973

File tree

4 files changed

+17
-302
lines changed

4 files changed

+17
-302
lines changed

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ export enum DbItemKind {
1313
RemoteRepo = "RemoteRepo",
1414
}
1515

16-
export enum DbListKind {
17-
Local = "Local",
18-
Remote = "Remote",
19-
}
20-
2116
export interface RootLocalDbItem {
2217
kind: DbItemKind.RootLocal;
2318
expanded: boolean;
@@ -108,16 +103,6 @@ export function isRemoteRepoDbItem(dbItem: DbItem): dbItem is RemoteRepoDbItem {
108103
return dbItem.kind === DbItemKind.RemoteRepo;
109104
}
110105

111-
export function isLocalListDbItem(dbItem: DbItem): dbItem is LocalListDbItem {
112-
return dbItem.kind === DbItemKind.LocalList;
113-
}
114-
115-
export function isLocalDatabaseDbItem(
116-
dbItem: DbItem,
117-
): dbItem is LocalDatabaseDbItem {
118-
return dbItem.kind === DbItemKind.LocalDatabase;
119-
}
120-
121106
type SelectableDbItem = RemoteDbItem | LocalDbItem;
122107

123108
export function isSelectableDbItem(dbItem: DbItem): dbItem is SelectableDbItem {

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

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ import { AppEvent, AppEventEmitter } from "../common/events";
33
import { ValueResult } from "../common/value-result";
44
import { DisposableObject } from "../common/disposable-object";
55
import { DbConfigStore } from "./config/db-config-store";
6-
import {
7-
DbItem,
8-
DbItemKind,
9-
DbListKind,
10-
LocalDatabaseDbItem,
11-
LocalListDbItem,
12-
RemoteUserDefinedListDbItem,
13-
} from "./db-item";
6+
import { DbItem, RemoteUserDefinedListDbItem } from "./db-item";
147
import {
158
updateExpandedItem,
169
replaceExpandedItem,
@@ -116,31 +109,15 @@ export class DbManager extends DisposableObject {
116109
await this.dbConfigStore.addRemoteOwner(owner);
117110
}
118111

119-
public async addNewList(
120-
listKind: DbListKind,
121-
listName: string,
122-
): Promise<void> {
123-
switch (listKind) {
124-
case DbListKind.Local:
125-
await this.dbConfigStore.addLocalList(listName);
126-
break;
127-
case DbListKind.Remote:
128-
await this.dbConfigStore.addRemoteList(listName);
129-
break;
130-
default:
131-
throw Error(`Unknown list kind '${listKind}'`);
132-
}
112+
public async addNewList(listName: string): Promise<void> {
113+
await this.dbConfigStore.addRemoteList(listName);
133114
}
134115

135116
public async renameList(
136-
currentDbItem: LocalListDbItem | RemoteUserDefinedListDbItem,
117+
currentDbItem: RemoteUserDefinedListDbItem,
137118
newName: string,
138119
): Promise<void> {
139-
if (currentDbItem.kind === DbItemKind.LocalList) {
140-
await this.dbConfigStore.renameLocalList(currentDbItem, newName);
141-
} else if (currentDbItem.kind === DbItemKind.RemoteUserDefinedList) {
142-
await this.dbConfigStore.renameRemoteList(currentDbItem, newName);
143-
}
120+
await this.dbConfigStore.renameRemoteList(currentDbItem, newName);
144121

145122
const newDbItem = { ...currentDbItem, listName: newName };
146123
const newExpandedItems = replaceExpandedItem(
@@ -152,26 +129,8 @@ export class DbManager extends DisposableObject {
152129
await this.setExpandedItems(newExpandedItems);
153130
}
154131

155-
public async renameLocalDb(
156-
currentDbItem: LocalDatabaseDbItem,
157-
newName: string,
158-
): Promise<void> {
159-
await this.dbConfigStore.renameLocalDb(
160-
currentDbItem,
161-
newName,
162-
currentDbItem.parentListName,
163-
);
164-
}
165-
166-
public doesListExist(listKind: DbListKind, listName: string): boolean {
167-
switch (listKind) {
168-
case DbListKind.Local:
169-
return this.dbConfigStore.doesLocalListExist(listName);
170-
case DbListKind.Remote:
171-
return this.dbConfigStore.doesRemoteListExist(listName);
172-
default:
173-
throw Error(`Unknown list kind '${listKind}'`);
174-
}
132+
public doesListExist(listName: string): boolean {
133+
return this.dbConfigStore.doesRemoteListExist(listName);
175134
}
176135

177136
public doesRemoteOwnerExist(owner: string): boolean {
@@ -182,10 +141,6 @@ export class DbManager extends DisposableObject {
182141
return this.dbConfigStore.doesRemoteDbExist(nwo, listName);
183142
}
184143

185-
public doesLocalDbExist(dbName: string, listName?: string): boolean {
186-
return this.dbConfigStore.doesLocalDbExist(dbName, listName);
187-
}
188-
189144
private getExpandedItems(): ExpandedDbItem[] {
190145
const items = this.app.workspaceState.get<ExpandedDbItem[]>(
191146
DbManager.DB_EXPANDED_STATE_KEY,

extensions/ql-vscode/src/databases/ui/db-panel.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ import {
1717
isValidGitHubOwner,
1818
} from "../../common/github-url-identifier-helper";
1919
import { DisposableObject } from "../../common/disposable-object";
20-
import {
21-
DbItem,
22-
DbItemKind,
23-
DbListKind,
24-
RemoteUserDefinedListDbItem,
25-
} from "../db-item";
20+
import { DbItem, DbItemKind, RemoteUserDefinedListDbItem } from "../db-item";
2621
import { getDbItemName } from "../db-item-naming";
2722
import { DbManager } from "../db-manager";
2823
import { DbTreeDataProvider } from "./db-tree-data-provider";
@@ -217,8 +212,6 @@ export class DbPanel extends DisposableObject {
217212
}
218213

219214
private async addNewList(): Promise<void> {
220-
const listKind = DbListKind.Remote;
221-
222215
const listName = await window.showInputBox({
223216
prompt: "Enter a name for the new list",
224217
placeHolder: "example-list",
@@ -227,15 +220,15 @@ export class DbPanel extends DisposableObject {
227220
return;
228221
}
229222

230-
if (this.dbManager.doesListExist(listKind, listName)) {
223+
if (this.dbManager.doesListExist(listName)) {
231224
void showAndLogErrorMessage(
232225
this.app.logger,
233226
`The list '${listName}' already exists`,
234227
);
235228
return;
236229
}
237230

238-
await this.dbManager.addNewList(listKind, listName);
231+
await this.dbManager.addNewList(listName);
239232
}
240233

241234
private async setSelectedItem(treeViewItem: DbTreeViewItem): Promise<void> {
@@ -286,7 +279,7 @@ export class DbPanel extends DisposableObject {
286279
return;
287280
}
288281

289-
if (this.dbManager.doesListExist(DbListKind.Remote, newName)) {
282+
if (this.dbManager.doesListExist(newName)) {
290283
void showAndLogErrorMessage(
291284
this.app.logger,
292285
`The list '${newName}' already exists`,

0 commit comments

Comments
 (0)