mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Add optional badge to Catalog Category label. Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Don't render badge container if there is no badge. Change CatalogCategoryLabel interface. Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Add badgeBackgroundColor CSS variable for extensions. Regenerate theme-vars.css. Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Use category as prop in CatalogCategoryLabel Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
|
|
import React from "react";
|
|
import { CatalogCategory, CatalogCategorySpec } from "../catalog";
|
|
|
|
class TestCatalogCategoryWithoutBadge 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",
|
|
},
|
|
};
|
|
}
|
|
|
|
class TestCatalogCategoryWithBadge extends TestCatalogCategoryWithoutBadge {
|
|
getBadge() {
|
|
return (<div>Test Badge</div>);
|
|
}
|
|
}
|
|
|
|
describe("CatalogCategory", () => {
|
|
it("returns name", () => {
|
|
const category = new TestCatalogCategoryWithoutBadge();
|
|
|
|
expect(category.getName()).toEqual("Test Category");
|
|
});
|
|
|
|
it("doesn't return badge by default", () => {
|
|
const category = new TestCatalogCategoryWithoutBadge();
|
|
|
|
expect(category.getBadge()).toEqual(null);
|
|
});
|
|
|
|
it("returns a badge", () => {
|
|
const category = new TestCatalogCategoryWithBadge();
|
|
|
|
expect(category.getBadge()).toBeTruthy();
|
|
});
|
|
});
|