Hide system defined lists when enterprise URI is set
This commit is contained in:
@@ -570,6 +570,7 @@ export async function setRemoteControllerRepo(repo: string | undefined) {
|
|||||||
export interface VariantAnalysisConfig {
|
export interface VariantAnalysisConfig {
|
||||||
controllerRepo: string | undefined;
|
controllerRepo: string | undefined;
|
||||||
onDidChangeConfiguration?: Event<void>;
|
onDidChangeConfiguration?: Event<void>;
|
||||||
|
showSystemDefinedRepositoryLists: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class VariantAnalysisConfigListener
|
export class VariantAnalysisConfigListener
|
||||||
@@ -578,7 +579,7 @@ export class VariantAnalysisConfigListener
|
|||||||
{
|
{
|
||||||
protected handleDidChangeConfiguration(e: ConfigurationChangeEvent): void {
|
protected handleDidChangeConfiguration(e: ConfigurationChangeEvent): void {
|
||||||
this.handleDidChangeConfigurationForRelevantSettings(
|
this.handleDidChangeConfigurationForRelevantSettings(
|
||||||
[VARIANT_ANALYSIS_SETTING],
|
[VARIANT_ANALYSIS_SETTING, VSCODE_GITHUB_ENTERPRISE_URI_SETTING],
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -586,6 +587,10 @@ export class VariantAnalysisConfigListener
|
|||||||
public get controllerRepo(): string | undefined {
|
public get controllerRepo(): string | undefined {
|
||||||
return getRemoteControllerRepo();
|
return getRemoteControllerRepo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get showSystemDefinedRepositoryLists(): boolean {
|
||||||
|
return !hasEnterpriseUri();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const VARIANT_ANALYSIS_FILTER_RESULTS = new Setting(
|
const VARIANT_ANALYSIS_FILTER_RESULTS = new Setting(
|
||||||
|
|||||||
@@ -16,11 +16,14 @@ import {
|
|||||||
} from "./db-item-selection";
|
} from "./db-item-selection";
|
||||||
import { createRemoteTree } from "./db-tree-creator";
|
import { createRemoteTree } from "./db-tree-creator";
|
||||||
import type { DbConfigValidationError } from "./db-validation-errors";
|
import type { DbConfigValidationError } from "./db-validation-errors";
|
||||||
|
import { VariantAnalysisConfigListener } from "../config";
|
||||||
|
|
||||||
export class DbManager extends DisposableObject {
|
export class DbManager extends DisposableObject {
|
||||||
public readonly onDbItemsChanged: AppEvent<void>;
|
public readonly onDbItemsChanged: AppEvent<void>;
|
||||||
public static readonly DB_EXPANDED_STATE_KEY = "db_expanded";
|
public static readonly DB_EXPANDED_STATE_KEY = "db_expanded";
|
||||||
private readonly onDbItemsChangesEventEmitter: AppEventEmitter<void>;
|
private readonly onDbItemsChangesEventEmitter: AppEventEmitter<void>;
|
||||||
|
private readonly variantAnalysisConfigListener =
|
||||||
|
new VariantAnalysisConfigListener();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly app: App,
|
private readonly app: App,
|
||||||
@@ -36,6 +39,10 @@ export class DbManager extends DisposableObject {
|
|||||||
this.dbConfigStore.onDidChangeConfig(() => {
|
this.dbConfigStore.onDidChangeConfig(() => {
|
||||||
this.onDbItemsChangesEventEmitter.fire();
|
this.onDbItemsChangesEventEmitter.fire();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.variantAnalysisConfigListener.onDidChangeConfiguration(() => {
|
||||||
|
this.onDbItemsChangesEventEmitter.fire();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSelectedDbItem(): DbItem | undefined {
|
public getSelectedDbItem(): DbItem | undefined {
|
||||||
@@ -56,7 +63,11 @@ export class DbManager extends DisposableObject {
|
|||||||
|
|
||||||
const expandedItems = this.getExpandedItems();
|
const expandedItems = this.getExpandedItems();
|
||||||
|
|
||||||
const remoteTree = createRemoteTree(configResult.value, expandedItems);
|
const remoteTree = createRemoteTree(
|
||||||
|
configResult.value,
|
||||||
|
this.variantAnalysisConfigListener,
|
||||||
|
expandedItems,
|
||||||
|
);
|
||||||
return ValueResult.ok(remoteTree.children);
|
return ValueResult.ok(remoteTree.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { VariantAnalysisConfig } from "../config";
|
||||||
import type { DbConfig, RemoteRepositoryList } from "./config/db-config";
|
import type { DbConfig, RemoteRepositoryList } from "./config/db-config";
|
||||||
import { SelectedDbItemKind } from "./config/db-config";
|
import { SelectedDbItemKind } from "./config/db-config";
|
||||||
import type {
|
import type {
|
||||||
@@ -13,13 +14,17 @@ import { ExpandedDbItemKind } from "./db-item-expansion";
|
|||||||
|
|
||||||
export function createRemoteTree(
|
export function createRemoteTree(
|
||||||
dbConfig: DbConfig,
|
dbConfig: DbConfig,
|
||||||
|
variantAnalysisConfig: VariantAnalysisConfig,
|
||||||
expandedItems: ExpandedDbItem[],
|
expandedItems: ExpandedDbItem[],
|
||||||
): RootRemoteDbItem {
|
): RootRemoteDbItem {
|
||||||
const systemDefinedLists = [
|
const systemDefinedLists =
|
||||||
createSystemDefinedList(10, dbConfig),
|
variantAnalysisConfig.showSystemDefinedRepositoryLists
|
||||||
createSystemDefinedList(100, dbConfig),
|
? [
|
||||||
createSystemDefinedList(1000, dbConfig),
|
createSystemDefinedList(10, dbConfig),
|
||||||
];
|
createSystemDefinedList(100, dbConfig),
|
||||||
|
createSystemDefinedList(1000, dbConfig),
|
||||||
|
]
|
||||||
|
: [];
|
||||||
|
|
||||||
const userDefinedRepoLists =
|
const userDefinedRepoLists =
|
||||||
dbConfig.databases.variantAnalysis.repositoryLists.map((r) =>
|
dbConfig.databases.variantAnalysis.repositoryLists.map((r) =>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { VariantAnalysisConfig } from "../../../src/config";
|
||||||
import type { DbConfig } from "../../../src/databases/config/db-config";
|
import type { DbConfig } from "../../../src/databases/config/db-config";
|
||||||
import { SelectedDbItemKind } from "../../../src/databases/config/db-config";
|
import { SelectedDbItemKind } from "../../../src/databases/config/db-config";
|
||||||
import {
|
import {
|
||||||
@@ -12,11 +13,20 @@ import { createRemoteTree } from "../../../src/databases/db-tree-creator";
|
|||||||
import { createDbConfig } from "../../factories/db-config-factories";
|
import { createDbConfig } from "../../factories/db-config-factories";
|
||||||
|
|
||||||
describe("db tree creator", () => {
|
describe("db tree creator", () => {
|
||||||
|
const defaultVariantAnalysisConfig: VariantAnalysisConfig = {
|
||||||
|
controllerRepo: "foo/bar",
|
||||||
|
showSystemDefinedRepositoryLists: true,
|
||||||
|
};
|
||||||
|
|
||||||
describe("createRemoteTree", () => {
|
describe("createRemoteTree", () => {
|
||||||
it("should build root node and system defined lists", () => {
|
it("should build root node and system defined lists", () => {
|
||||||
const dbConfig = createDbConfig();
|
const dbConfig = createDbConfig();
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, []);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
@@ -45,6 +55,24 @@ describe("db tree creator", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("displays empty list when no remote user defined list nodes and system defined lists are disabled", () => {
|
||||||
|
const dbConfig = createDbConfig();
|
||||||
|
|
||||||
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
{
|
||||||
|
...defaultVariantAnalysisConfig,
|
||||||
|
showSystemDefinedRepositoryLists: false,
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
|
expect(dbTreeRoot.expanded).toBe(false);
|
||||||
|
expect(dbTreeRoot.children.length).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
it("should create remote user defined list nodes", () => {
|
it("should create remote user defined list nodes", () => {
|
||||||
const dbConfig = createDbConfig({
|
const dbConfig = createDbConfig({
|
||||||
remoteLists: [
|
remoteLists: [
|
||||||
@@ -59,10 +87,15 @@ describe("db tree creator", () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, []);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
|
expect(dbTreeRoot.children.length).toBe(5);
|
||||||
const repositoryListNodes = dbTreeRoot.children.filter(
|
const repositoryListNodes = dbTreeRoot.children.filter(
|
||||||
isRemoteUserDefinedListDbItem,
|
isRemoteUserDefinedListDbItem,
|
||||||
);
|
);
|
||||||
@@ -102,12 +135,76 @@ describe("db tree creator", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("shows only user defined list nodes when system defined lists are disabled", () => {
|
||||||
|
const dbConfig = createDbConfig({
|
||||||
|
remoteLists: [
|
||||||
|
{
|
||||||
|
name: "my-list-1",
|
||||||
|
repositories: ["owner1/repo1", "owner1/repo2", "owner2/repo1"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "my-list-2",
|
||||||
|
repositories: ["owner3/repo1", "owner3/repo2", "owner4/repo1"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
{
|
||||||
|
...defaultVariantAnalysisConfig,
|
||||||
|
showSystemDefinedRepositoryLists: false,
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
|
expect(dbTreeRoot.children.length).toBe(2);
|
||||||
|
expect(dbTreeRoot.children[0]).toEqual({
|
||||||
|
kind: DbItemKind.RemoteUserDefinedList,
|
||||||
|
selected: false,
|
||||||
|
expanded: false,
|
||||||
|
listName: dbConfig.databases.variantAnalysis.repositoryLists[0].name,
|
||||||
|
repos:
|
||||||
|
dbConfig.databases.variantAnalysis.repositoryLists[0].repositories.map(
|
||||||
|
(repo) => ({
|
||||||
|
kind: DbItemKind.RemoteRepo,
|
||||||
|
selected: false,
|
||||||
|
repoFullName: repo,
|
||||||
|
parentListName:
|
||||||
|
dbConfig.databases.variantAnalysis.repositoryLists[0].name,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
expect(dbTreeRoot.children[1]).toEqual({
|
||||||
|
kind: DbItemKind.RemoteUserDefinedList,
|
||||||
|
selected: false,
|
||||||
|
expanded: false,
|
||||||
|
listName: dbConfig.databases.variantAnalysis.repositoryLists[1].name,
|
||||||
|
repos:
|
||||||
|
dbConfig.databases.variantAnalysis.repositoryLists[1].repositories.map(
|
||||||
|
(repo) => ({
|
||||||
|
kind: DbItemKind.RemoteRepo,
|
||||||
|
selected: false,
|
||||||
|
repoFullName: repo,
|
||||||
|
parentListName:
|
||||||
|
dbConfig.databases.variantAnalysis.repositoryLists[1].name,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should create remote owner nodes", () => {
|
it("should create remote owner nodes", () => {
|
||||||
const dbConfig: DbConfig = createDbConfig({
|
const dbConfig: DbConfig = createDbConfig({
|
||||||
remoteOwners: ["owner1", "owner2"],
|
remoteOwners: ["owner1", "owner2"],
|
||||||
});
|
});
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, []);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
@@ -131,7 +228,11 @@ describe("db tree creator", () => {
|
|||||||
remoteRepos: ["owner1/repo1", "owner1/repo2", "owner2/repo1"],
|
remoteRepos: ["owner1/repo1", "owner1/repo2", "owner2/repo1"],
|
||||||
});
|
});
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, []);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
@@ -170,7 +271,11 @@ describe("db tree creator", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, []);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
@@ -191,7 +296,11 @@ describe("db tree creator", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, []);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
@@ -213,7 +322,11 @@ describe("db tree creator", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, []);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
@@ -240,7 +353,11 @@ describe("db tree creator", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, []);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
|
|
||||||
@@ -265,7 +382,11 @@ describe("db tree creator", () => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, expanded);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
expanded,
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
@@ -291,7 +412,11 @@ describe("db tree creator", () => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const dbTreeRoot = createRemoteTree(dbConfig, expanded);
|
const dbTreeRoot = createRemoteTree(
|
||||||
|
dbConfig,
|
||||||
|
defaultVariantAnalysisConfig,
|
||||||
|
expanded,
|
||||||
|
);
|
||||||
|
|
||||||
expect(dbTreeRoot).toBeTruthy();
|
expect(dbTreeRoot).toBeTruthy();
|
||||||
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
expect(dbTreeRoot.kind).toBe(DbItemKind.RootRemote);
|
||||||
|
|||||||
Reference in New Issue
Block a user