fleet/frontend/components/ViewAllHostsLink/ViewAllHostsLink.tsx
Jacob Shandling f0c4dd854b Add teams features to Vuln details page (#16761)
## Addresses #16758 

- Add Teams functionality to the Vulnerability details page
  - Premium only
  -  All links from page include team_id query param
      - To hosts page
      - To OS details pages
      - To SW version details pages
  - API call includes `team_id` query param 
  - Teams header
- If user only has access to one team, just shows the teamname (no
dropdown)
    -  Otherwise, Dropdown with team options
    - Includes "All teams," but not "No teams"
- Add empty state when ~both vulnerable OS versions and SW versions are
empty~ affected hosts === 0

<img width="1657" alt="Screenshot 2024-02-12 at 4 47 36 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/4f0bb856-57c4-4905-b82b-b00dac6a8306">
<img width="1552" alt="Screenshot 2024-02-12 at 4 45 42 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/45d6bbb5-0b31-46df-a715-7fa176029a1d">
<img width="1552" alt="Screenshot 2024-02-12 at 4 45 47 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/de6c68a6-aaa4-4637-998c-569b4d189433">

---------
Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-02-15 10:35:58 -07:00

69 lines
1.7 KiB
TypeScript

import React from "react";
import PATHS from "router/paths";
import { Link } from "react-router";
import classnames from "classnames";
import Icon from "components/Icon";
import { buildQueryStringFromParams, QueryParams } from "utilities/url";
interface IHostLinkProps {
queryParams?: QueryParams;
className?: string;
/** Including the platformId will view all hosts for the platform provided */
platformLabelId?: number;
/** Shows right chevron without text */
condensed?: boolean;
responsive?: boolean;
customText?: string;
/** Table links shows on row hover only */
rowHover?: boolean;
// don't actually create a link, useful when click is handled by an ancestor
noLink?: boolean;
}
const baseClass = "view-all-hosts-link";
const ViewAllHostsLink = ({
queryParams,
className,
platformLabelId,
condensed = false,
responsive = false,
customText,
rowHover = false,
noLink = false,
}: IHostLinkProps): JSX.Element => {
const viewAllHostsLinkClass = classnames(baseClass, className, {
"row-hover-link": rowHover,
});
const endpoint = platformLabelId
? PATHS.MANAGE_HOSTS_LABEL(platformLabelId)
: PATHS.MANAGE_HOSTS;
const path = queryParams
? `${endpoint}?${buildQueryStringFromParams(queryParams)}`
: endpoint;
return (
<Link
className={viewAllHostsLinkClass}
to={noLink ? "" : path}
title="host-link"
>
{!condensed && (
<span
className={`${baseClass}__text${responsive ? "--responsive" : ""}`}
>
{customText ?? "View all hosts"}
</span>
)}
<Icon
name="chevron-right"
className={`${baseClass}__icon`}
color="core-fleet-blue"
/>
</Link>
);
};
export default ViewAllHostsLink;