mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move subnamespace badge show check to parent
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
f9cf6ad87f
commit
5b8de287d8
@ -970,7 +970,7 @@ exports[`<NamespaceTreeView /> renders namespace with children namespaces and a
|
|||||||
|
|
||||||
<span
|
<span
|
||||||
class="subnamespaceBadge"
|
class="subnamespaceBadge"
|
||||||
data-testid="subnamespace-badge-for-service-1-1"
|
data-testid="namespace-details-badge-for-service-1-1"
|
||||||
id="namespace-details-badge-for-service-1-1"
|
id="namespace-details-badge-for-service-1-1"
|
||||||
>
|
>
|
||||||
S
|
S
|
||||||
|
|||||||
@ -150,14 +150,14 @@ describe("<NamespaceTreeView />", () => {
|
|||||||
it("renders an indicator badge for the subnamespace", () => {
|
it("renders an indicator badge for the subnamespace", () => {
|
||||||
const result = render(<NamespaceTreeView root={orgA} />);
|
const result = render(<NamespaceTreeView root={orgA} />);
|
||||||
|
|
||||||
expect(result.getByTestId("subnamespace-badge-for-service-1-1")).toBeInTheDocument();
|
expect(result.getByTestId("namespace-details-badge-for-service-1-1")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not render an indicator badge for the true namespace", () => {
|
it("does not render an indicator badge for the true namespace", () => {
|
||||||
const result = render(<NamespaceTreeView root={orgA} />);
|
const result = render(<NamespaceTreeView root={orgA} />);
|
||||||
const trueNamespace = result.getByTestId("namespace-team-c-1");
|
const trueNamespace = result.getByTestId("namespace-team-c-1");
|
||||||
|
|
||||||
expect(trueNamespace.querySelector("[data-testid='subnamespace-badge-for-team-c-1']")).toBeNull();
|
expect(trueNamespace.querySelector("[data-testid='namespace-details-badge-for-team-c-1']")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders 2 levels deep", () => {
|
it("renders 2 levels deep", () => {
|
||||||
|
|||||||
@ -61,10 +61,9 @@ function NonInjectableNamespaceTreeView({ root, namespaces, getDetailsUrl }: Dep
|
|||||||
{child.getName()}
|
{child.getName()}
|
||||||
</Link>
|
</Link>
|
||||||
{" "}
|
{" "}
|
||||||
<SubnamespaceBadge
|
{child.isSubnamespace() && (
|
||||||
id={`namespace-details-badge-for-${child.getId()}`}
|
<SubnamespaceBadge id={`namespace-details-badge-for-${child.getId()}`} />
|
||||||
namespace={child}
|
)}
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -5,24 +5,18 @@
|
|||||||
import styles from "./subnamespace-badge.module.scss";
|
import styles from "./subnamespace-badge.module.scss";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import type { Namespace } from "../../../common/k8s-api/endpoints";
|
|
||||||
import { Tooltip } from "../tooltip";
|
import { Tooltip } from "../tooltip";
|
||||||
|
|
||||||
interface SubnamespaceBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
interface SubnamespaceBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
||||||
namespace: Namespace;
|
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SubnamespaceBadge({ namespace, id, ...other }: SubnamespaceBadgeProps) {
|
export function SubnamespaceBadge({ id, ...other }: SubnamespaceBadgeProps) {
|
||||||
if (!namespace.isSubnamespace()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span
|
<span
|
||||||
className={styles.subnamespaceBadge}
|
className={styles.subnamespaceBadge}
|
||||||
data-testid={`subnamespace-badge-for-${namespace.getId()}`}
|
data-testid={id}
|
||||||
id={id}
|
id={id}
|
||||||
{...other}
|
{...other}
|
||||||
>
|
>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user