mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Don't render badge container if there is no badge. Change CatalogCategoryLabel interface.
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
parent
799670ef31
commit
024278a0af
@ -37,7 +37,7 @@ describe("CatalogCategoryLabel", () => {
|
|||||||
it("renders without a badge", async () => {
|
it("renders without a badge", async () => {
|
||||||
const category = new CatalogCategoryWithoutBadge();
|
const category = new CatalogCategoryWithoutBadge();
|
||||||
|
|
||||||
render(<CatalogCategoryLabel category={category}/>);
|
render(<CatalogCategoryLabel label={category.metadata.name} badge={category.getBadge()}/>);
|
||||||
|
|
||||||
expect(await screen.findByText("Test Category")).toBeInTheDocument();
|
expect(await screen.findByText("Test Category")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
@ -45,7 +45,7 @@ describe("CatalogCategoryLabel", () => {
|
|||||||
it("renders with a badge", async () => {
|
it("renders with a badge", async () => {
|
||||||
const category = new CatalogCategoryWithBadge();
|
const category = new CatalogCategoryWithBadge();
|
||||||
|
|
||||||
render(<CatalogCategoryLabel category={category}/>);
|
render(<CatalogCategoryLabel label={category.metadata.name} badge={category.getBadge()}/>);
|
||||||
|
|
||||||
expect(await screen.findByText("Test Category")).toBeInTheDocument();
|
expect(await screen.findByText("Test Category")).toBeInTheDocument();
|
||||||
expect(await screen.findByText("Test Badge")).toBeInTheDocument();
|
expect(await screen.findByText("Test Badge")).toBeInTheDocument();
|
||||||
|
|||||||
@ -3,19 +3,19 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import type { CatalogCategory } from "../../../common/catalog/catalog-entity";
|
|
||||||
|
|
||||||
interface CatalogCategoryLabelProps {
|
interface CatalogCategoryLabelProps {
|
||||||
category: CatalogCategory;
|
label: string | React.ReactNode;
|
||||||
|
badge?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display label for Catalog Category for the Catalog menu
|
* Display label for Catalog Category for the Catalog menu
|
||||||
*/
|
*/
|
||||||
export const CatalogCategoryLabel = ({ category }: CatalogCategoryLabelProps) =>
|
export const CatalogCategoryLabel = ({ label, badge }: CatalogCategoryLabelProps) =>
|
||||||
(
|
(
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<div>{category.metadata.name}</div>
|
<div>{label}</div>
|
||||||
<div className="flex items-center">{category.getBadge()}</div>
|
{badge ? (<div className="flex items-center">{badge}</div>) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -67,7 +67,7 @@ export const CatalogMenu = observer((props: CatalogMenuProps) => {
|
|||||||
icon={getCategoryIcon(category)}
|
icon={getCategoryIcon(category)}
|
||||||
key={category.getId()}
|
key={category.getId()}
|
||||||
nodeId={category.getId()}
|
nodeId={category.getId()}
|
||||||
label={<CatalogCategoryLabel category={category} />}
|
label={<CatalogCategoryLabel label={category.metadata.name} badge={category.getBadge()} />}
|
||||||
data-testid={`${category.getId()}-tab`}
|
data-testid={`${category.getId()}-tab`}
|
||||||
onClick={() => props.onItemClick(category.getId())}
|
onClick={() => props.onItemClick(category.getId())}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user