fleet/frontend/components/ViewAllHostsLink/ViewAllHostsLink.tsx
jacobshandling 32c42c301f
UI - Show software details My device page (#25022)
## #23315 

- On device user page > Software, make rows clickable and on click, open
the Software details modal to display information about the installation
on the host.
- Update Software details modal copy and allow long file paths to wrap


https://github.com/user-attachments/assets/1e714c5e-1614-46c0-bb56-d6dc8ad4f8ae

<img width="1350" alt="Screenshot 2024-12-26 at 10 27 44 AM"
src="https://github.com/user-attachments/assets/5cefc45a-b0ef-41d9-84e6-21ac17aaeffe"
/>
<img width="1350" alt="Screenshot 2024-12-26 at 10 27 19 AM"
src="https://github.com/user-attachments/assets/e0866961-31a4-4bd3-82e8-18f72cf4dc30"
/>
<img width="1350" alt="Screenshot 2024-12-26 at 10 27 37 AM"
src="https://github.com/user-attachments/assets/2bf6c880-664d-4315-8a40-8de61a5e4748"
/>


- [x] Changes file added for user-visible changes in `changes/`, 
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-12-26 14:51:28 -08:00

73 lines
1.8 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;
excludeChevron?: boolean;
responsive?: boolean;
customText?: string;
/** Table links shows on row hover and tab focus 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,
excludeChevron = 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>
)}
{!excludeChevron && (
<Icon
name="chevron-right"
className={`${baseClass}__icon`}
color="core-fleet-blue"
/>
)}
</Link>
);
};
export default ViewAllHostsLink;