fleet/frontend/components/TableContainer/DataTable/SoftwareNameCell/SoftwareNameCell.tsx
Gabriel Hernandez cedcadbb36
Add UI for Apple VPP apps feature on the software pages. (#20504)
relates to #19869

> NOTE: API integration will be included in a separate PR

This adds the UI updates to support the new VPP feature on the software
pages. This includes the software titles page and software titles
details page. The new UI includes:

**Add Vpp apps tab in Add software modal:**


![image](https://github.com/user-attachments/assets/f1751b5d-1393-45b7-894c-fa6d067d27d2)

**Various updates to the SoftwareIcon component to support icons from an
external source:**


![image](https://github.com/user-attachments/assets/c860d776-170c-4f51-813e-34f83e479471)

**Various updates to the SoftwarePackageCard compont to support app
store apps.**


![image](https://github.com/user-attachments/assets/7bdd369d-6c95-47a6-8942-63ac3c694ffe)

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated testss:
- [x] Manual QA for all new/changed functionality
2024-07-18 10:20:17 +01:00

111 lines
2.6 KiB
TypeScript

import React from "react";
import { InjectedRouter } from "react-router";
import ReactTooltip from "react-tooltip";
import { uniqueId } from "lodash";
import { ISoftwarePackage } from "interfaces/software";
import Icon from "components/Icon";
import SoftwareIcon from "pages/SoftwarePage/components/icons/SoftwareIcon";
import LinkCell from "../LinkCell";
const baseClass = "software-name-cell";
const InstallIconWithTooltip = ({
isSelfService,
}: {
isSelfService: ISoftwarePackage["self_service"];
}) => {
const tooltipId = uniqueId();
return (
<div className={`${baseClass}__install-icon-with-tooltip`}>
<div
className={`${baseClass}__install-icon-tooltip`}
data-tip
data-for={tooltipId}
>
<Icon
name={isSelfService ? "install-self-service" : "install"}
className={`${baseClass}__install-icon`}
/>
</div>
<ReactTooltip
className={`${baseClass}__install-tooltip`}
place="top"
effect="solid"
backgroundColor="#3e4771"
id={tooltipId}
data-html
>
<span className={`${baseClass}__install-tooltip-text`}>
{isSelfService ? (
<>
End users can install from <b>Fleet Desktop {">"} Self-service</b>
.
</>
) : (
"Software can be installed on Host details page."
)}
</span>
</ReactTooltip>
</div>
);
};
interface ISoftwareNameCellProps {
name: string;
source: string;
path?: string;
router?: InjectedRouter;
hasPackage?: boolean;
isSelfService?: boolean;
iconUrl?: string;
}
const SoftwareNameCell = ({
name,
source,
path,
router,
hasPackage = false,
isSelfService = false,
iconUrl,
}: ISoftwareNameCellProps) => {
// NO path or router means it's not clickable. return
// a non-clickable cell early
if (!router || !path) {
return (
<div className={baseClass}>
<SoftwareIcon name={name} source={source} />
<span className="software-name">{name}</span>
</div>
);
}
const onClickSoftware = (e: React.MouseEvent) => {
// Allows for button to be clickable in a clickable row
e.stopPropagation();
router.push(path);
};
return (
<LinkCell
className={baseClass}
path={path}
customOnClick={onClickSoftware}
value={
<>
<SoftwareIcon name={name} source={source} url={iconUrl} />
<span className="software-name">{name}</span>
{hasPackage && (
<InstallIconWithTooltip isSelfService={isSelfService} />
)}
</>
}
/>
);
};
export default SoftwareNameCell;