1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Adding tooltip for subnamespace badge

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2023-02-01 13:42:53 +03:00
parent 78e77f7536
commit 1489264953
3 changed files with 21 additions and 9 deletions

View File

@ -871,6 +871,7 @@ exports[`<NamespaceTreeView /> once the subscribe resolves renders namespace wit
<span
class="subnamespaceBadge"
data-testid="subnamespace-badge-for-service-1-1"
id="namespace-details-badge-for-service-1-1"
>
S
</span>

View File

@ -50,7 +50,10 @@ function NonInjectableNamespaceTreeView({ root, namespaceStore, getDetailsUrl }:
{child.getName()}
</Link>
{" "}
<SubnamespaceBadge namespace={child} />
<SubnamespaceBadge
id={`namespace-details-badge-for-${child.getId()}`}
namespace={child}
/>
</>
)}
>

View File

@ -2,23 +2,31 @@ import styles from "./subnamespace-badge.module.scss";
import React from "react";
import type { Namespace } from "../../../common/k8s-api/endpoints";
import { Tooltip } from "../tooltip";
interface SubnamespaceBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
namespace: Namespace;
id: string;
}
export function SubnamespaceBadge({ namespace, ...other }: SubnamespaceBadgeProps) {
export function SubnamespaceBadge({ namespace, id, ...other }: SubnamespaceBadgeProps) {
if (!namespace.getAnnotations().find(annotation => annotation.includes("hnc.x-k8s.io/subnamespace-of"))) {
return null;
}
return (
<>
<span
className={styles.subnamespaceBadge}
data-testid={`subnamespace-badge-for-${namespace.getId()}`}
id={id}
{...other}
>
S
</span>
<Tooltip targetId={id}>
Subnamespace
</Tooltip>
</>
);
}