mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
relates to #21775 > NOTE: there still needs to be integrated with the API when this work is done. Adds the UI for adding Fleet maintained applications. This includes: **the view to see all the fleet maintained apps**  **The fleet maintained app details Page:**  <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [ ] Added/updated tests - [ ] Manual QA for all new/changed functionality
115 lines
2.8 KiB
TypeScript
115 lines
2.8 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>
|
|
.
|
|
</>
|
|
) : (
|
|
<>
|
|
Install manually on <b>Host details</b> page or automatically with
|
|
policy automations.
|
|
</>
|
|
)}
|
|
</span>
|
|
</ReactTooltip>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
interface ISoftwareNameCellProps {
|
|
name?: string;
|
|
source?: string;
|
|
/** pass in a `path` that this cell will link to */
|
|
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;
|