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 <span
class="subnamespaceBadge" class="subnamespaceBadge"
data-testid="subnamespace-badge-for-service-1-1" data-testid="subnamespace-badge-for-service-1-1"
id="namespace-details-badge-for-service-1-1"
> >
S S
</span> </span>

View File

@ -50,7 +50,10 @@ function NonInjectableNamespaceTreeView({ root, namespaceStore, getDetailsUrl }:
{child.getName()} {child.getName()}
</Link> </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 React from "react";
import type { Namespace } from "../../../common/k8s-api/endpoints"; import type { Namespace } from "../../../common/k8s-api/endpoints";
import { Tooltip } from "../tooltip";
interface SubnamespaceBadgeProps extends React.HTMLAttributes<HTMLSpanElement> { interface SubnamespaceBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
namespace: Namespace; 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"))) { if (!namespace.getAnnotations().find(annotation => annotation.includes("hnc.x-k8s.io/subnamespace-of"))) {
return null; return null;
} }
return ( return (
<>
<span <span
className={styles.subnamespaceBadge} className={styles.subnamespaceBadge}
data-testid={`subnamespace-badge-for-${namespace.getId()}`} data-testid={`subnamespace-badge-for-${namespace.getId()}`}
id={id}
{...other} {...other}
> >
S S
</span> </span>
<Tooltip targetId={id}>
Subnamespace
</Tooltip>
</>
); );
} }