Move db item expansion models to db-item-expansion

This commit is contained in:
Charis Kyriakou
2023-01-04 09:05:12 +00:00
parent 5e864ae8e0
commit 1a08ae4df2
6 changed files with 42 additions and 43 deletions

View File

@@ -87,37 +87,6 @@ export interface LocalDatabase {
storagePath: string;
}
export type ExpandedDbItem =
| RootLocalExpandedDbItem
| LocalUserDefinedListExpandedDbItem
| RootRemoteExpandedDbItem
| RemoteUserDefinedListExpandedDbItem;
export enum ExpandedDbItemKind {
RootLocal = "rootLocal",
LocalUserDefinedList = "localUserDefinedList",
RootRemote = "rootRemote",
RemoteUserDefinedList = "remoteUserDefinedList",
}
export interface RootLocalExpandedDbItem {
kind: ExpandedDbItemKind.RootLocal;
}
export interface LocalUserDefinedListExpandedDbItem {
kind: ExpandedDbItemKind.LocalUserDefinedList;
listName: string;
}
export interface RootRemoteExpandedDbItem {
kind: ExpandedDbItemKind.RootRemote;
}
export interface RemoteUserDefinedListExpandedDbItem {
kind: ExpandedDbItemKind.RemoteUserDefinedList;
listName: string;
}
export function cloneDbConfig(config: DbConfig): DbConfig {
return {
databases: {

View File

@@ -1,6 +1,36 @@
import { ExpandedDbItem, ExpandedDbItemKind } from "./config/db-config";
import { DbItem, DbItemKind } from "./db-item";
export type ExpandedDbItem =
| RootLocalExpandedDbItem
| LocalUserDefinedListExpandedDbItem
| RootRemoteExpandedDbItem
| RemoteUserDefinedListExpandedDbItem;
export enum ExpandedDbItemKind {
RootLocal = "rootLocal",
LocalUserDefinedList = "localUserDefinedList",
RootRemote = "rootRemote",
RemoteUserDefinedList = "remoteUserDefinedList",
}
export interface RootLocalExpandedDbItem {
kind: ExpandedDbItemKind.RootLocal;
}
export interface LocalUserDefinedListExpandedDbItem {
kind: ExpandedDbItemKind.LocalUserDefinedList;
listName: string;
}
export interface RootRemoteExpandedDbItem {
kind: ExpandedDbItemKind.RootRemote;
}
export interface RemoteUserDefinedListExpandedDbItem {
kind: ExpandedDbItemKind.RemoteUserDefinedList;
listName: string;
}
export function calculateNewExpandedState(
currentExpandedItems: ExpandedDbItem[],
dbItem: DbItem,

View File

@@ -1,10 +1,9 @@
import { App } from "../common/app";
import { AppEvent, AppEventEmitter } from "../common/events";
import { ValueResult } from "../common/value-result";
import { ExpandedDbItem } from "./config/db-config";
import { DbConfigStore } from "./config/db-config-store";
import { DbItem, DbListKind } from "./db-item";
import { calculateNewExpandedState } from "./db-item-expansion";
import { calculateNewExpandedState, ExpandedDbItem } from "./db-item-expansion";
import {
getSelectedDbItem,
mapDbItemToSelectedDbItem,

View File

@@ -1,7 +1,5 @@
import {
DbConfig,
ExpandedDbItem,
ExpandedDbItemKind,
LocalDatabase,
LocalList,
RemoteRepositoryList,
@@ -18,6 +16,7 @@ import {
RootLocalDbItem,
RootRemoteDbItem,
} from "./db-item";
import { ExpandedDbItem, ExpandedDbItemKind } from "./db-item-expansion";
export function createRemoteTree(
dbConfig: DbConfig,

View File

@@ -1,12 +1,12 @@
import {
ExpandedDbItem,
ExpandedDbItemKind,
} from "../../../src/databases/config/db-config";
import {
RemoteUserDefinedListDbItem,
RootRemoteDbItem,
} from "../../../src/databases/db-item";
import { calculateNewExpandedState } from "../../../src/databases/db-item-expansion";
import {
calculateNewExpandedState,
ExpandedDbItem,
ExpandedDbItemKind,
} from "../../../src/databases/db-item-expansion";
import {
createRemoteUserDefinedListDbItem,
createRootRemoteDbItem,

View File

@@ -1,7 +1,5 @@
import {
DbConfig,
ExpandedDbItem,
ExpandedDbItemKind,
SelectedDbItemKind,
} from "../../../src/databases/config/db-config";
import {
@@ -10,6 +8,10 @@ import {
isRemoteRepoDbItem,
isRemoteUserDefinedListDbItem,
} from "../../../src/databases/db-item";
import {
ExpandedDbItem,
ExpandedDbItemKind,
} from "../../../src/databases/db-item-expansion";
import {
createLocalTree,
createRemoteTree,