diff --git a/src/common/__tests__/catalog-entity.test.ts b/src/common/__tests__/catalog-entity.test.ts
new file mode 100644
index 0000000000..3785ed1d49
--- /dev/null
+++ b/src/common/__tests__/catalog-entity.test.ts
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) OpenLens Authors. All rights reserved.
+ * Licensed under MIT License. See LICENSE in root directory for more information.
+ */
+
+import { CatalogCategory, CatalogCategorySpec } from "../catalog";
+
+class TestCatalogCategory extends CatalogCategory {
+ public readonly apiVersion = "catalog.k8slens.dev/v1alpha1";
+ public readonly kind = "CatalogCategory";
+ public metadata = {
+ name: "Test Category",
+ icon: "",
+ };
+ public spec: CatalogCategorySpec = {
+ group: "entity.k8slens.dev",
+ versions: [],
+ names: {
+ kind: "Test",
+ },
+ };
+}
+
+describe("CatalogCategory", () => {
+ it("returns name", () => {
+ const category = new TestCatalogCategory();
+
+ expect(category.getName()).toEqual("Test Category");
+ });
+});
diff --git a/src/common/catalog/catalog-entity.ts b/src/common/catalog/catalog-entity.ts
index daff2e6017..2704bed2e0 100644
--- a/src/common/catalog/catalog-entity.ts
+++ b/src/common/catalog/catalog-entity.ts
@@ -173,6 +173,13 @@ export abstract class CatalogCategory extends (EventEmitter as new () => TypedEm
return `${this.spec.group}/${this.spec.names.kind}`;
}
+ /**
+ * Get the name of this category
+ */
+ public getName(): string {
+ return this.metadata.name;
+ }
+
/**
* Add a filter for menu items of catalogAddMenu
* @param fn The function that should return a truthy value if that menu item should be displayed
diff --git a/src/renderer/components/+catalog/catalog.test.tsx b/src/renderer/components/+catalog/catalog.test.tsx
index 218bb60feb..5c221bb457 100644
--- a/src/renderer/components/+catalog/catalog.test.tsx
+++ b/src/renderer/components/+catalog/catalog.test.tsx
@@ -25,6 +25,8 @@ import { UserStore } from "../../../common/user-store";
import mockFs from "mock-fs";
import directoryForUserDataInjectable
from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
+import type { AppEvent } from "../../../common/app-event-bus/event-bus";
+import appEventBusInjectable from "../../../common/app-event-bus/app-event-bus.injectable";
mockWindow();
jest.mock("electron", () => ({
@@ -102,6 +104,7 @@ describe("", () => {
let di: DiContainer;
let catalogEntityStore: CatalogEntityStore;
let catalogEntityRegistry: CatalogEntityRegistry;
+ let emitEvent: (event: AppEvent) => void;
let render: DiRender;
beforeEach(async () => {
@@ -125,6 +128,12 @@ describe("", () => {
di.override(catalogEntityRegistryInjectable, () => catalogEntityRegistry);
+ emitEvent = jest.fn();
+
+ di.override(appEventBusInjectable, () => ({
+ emit: emitEvent,
+ }));
+
catalogEntityStore = di.inject(catalogEntityStoreInjectable);
});
@@ -320,4 +329,39 @@ describe("", () => {
userEvent.click(screen.getByTestId("detail-panel-hot-bar-icon"));
});
+
+ it("emits catalog open AppEvent", () => {
+ render(
+ ,
+ );
+
+ expect(emitEvent).toHaveBeenCalledWith( {
+ action: "open",
+ name: "catalog",
+ });
+ });
+
+ it("emits catalog change AppEvent when changing the category", () => {
+ render(
+ ,
+ );
+
+ userEvent.click(screen.getByText("Web Links"));
+
+ expect(emitEvent).toHaveBeenLastCalledWith({
+ action: "change-category",
+ name: "catalog",
+ params: {
+ category: "Web Links",
+ },
+ });
+ });
});
diff --git a/src/renderer/components/+catalog/catalog.tsx b/src/renderer/components/+catalog/catalog.tsx
index 359e538ac5..a3af640fc5 100644
--- a/src/renderer/components/+catalog/catalog.tsx
+++ b/src/renderer/components/+catalog/catalog.tsx
@@ -36,6 +36,8 @@ import getCategoryColumnsInjectable from "./get-category-columns.injectable";
import type { RegisteredCustomCategoryViewDecl } from "./custom-views.injectable";
import customCategoryViewsInjectable from "./custom-views.injectable";
import type { CustomCategoryViewComponents } from "./custom-views";
+import type { AppEvent } from "../../../common/app-event-bus/event-bus";
+import appEventBusInjectable from "../../../common/app-event-bus/app-event-bus.injectable";
export interface CatalogProps extends RouteComponentProps {}
@@ -44,6 +46,7 @@ interface Dependencies {
catalogEntityStore: CatalogEntityStore;
getCategoryColumns: (params: GetCategoryColumnsParams) => CategoryColumns;
customCategoryViews: IComputedValue