2025-03-21 13:33:06 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import { InjectedRouter } from "react-router";
|
|
|
|
|
|
|
|
|
|
import PATHS from "router/paths";
|
|
|
|
|
import { getPathWithQueryParams } from "utilities/url";
|
|
|
|
|
import { IFleetMaintainedApp } from "interfaces/software";
|
|
|
|
|
|
|
|
|
|
import { softwareAlreadyAddedTipContent } from "pages/SoftwarePage/SoftwareAddPage/SoftwareFleetMaintained/FleetMaintainedAppDetailsPage/FleetAppDetailsForm/FleetAppDetailsForm";
|
|
|
|
|
import classnames from "classnames";
|
|
|
|
|
import Icon from "components/Icon";
|
|
|
|
|
import Button from "components/buttons/Button";
|
|
|
|
|
import TooltipWrapper from "components/TooltipWrapper";
|
|
|
|
|
import TextCell from "../TextCell";
|
|
|
|
|
|
|
|
|
|
const baseClass = "installer-action-cell";
|
|
|
|
|
|
|
|
|
|
interface IInstallerActionCellProps {
|
|
|
|
|
value?: Omit<IFleetMaintainedApp, "name" | "version"> | null;
|
|
|
|
|
router?: InjectedRouter;
|
|
|
|
|
className?: string;
|
|
|
|
|
teamId?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const InstallerActionCell = ({
|
|
|
|
|
value,
|
|
|
|
|
router,
|
|
|
|
|
className = "w250",
|
|
|
|
|
teamId,
|
|
|
|
|
}: IInstallerActionCellProps) => {
|
|
|
|
|
const cellClasses = classnames(baseClass, className);
|
|
|
|
|
|
|
|
|
|
// Not all FMAs are supported for all platforms
|
|
|
|
|
if (!value) {
|
|
|
|
|
return (
|
|
|
|
|
<TextCell
|
|
|
|
|
className={cellClasses}
|
|
|
|
|
emptyCellTooltipText="Currently unavailable for this platform."
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { id, software_title_id: softwareTitleId } = value;
|
|
|
|
|
|
|
|
|
|
const onClick = () => {
|
|
|
|
|
const path = getPathWithQueryParams(
|
|
|
|
|
PATHS.SOFTWARE_FLEET_MAINTAINED_DETAILS(id),
|
2026-02-17 21:19:33 +00:00
|
|
|
{ fleet_id: teamId }
|
2025-03-21 13:33:06 +00:00
|
|
|
);
|
|
|
|
|
if (router && path) {
|
|
|
|
|
router?.push(path);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (softwareTitleId) {
|
|
|
|
|
return (
|
|
|
|
|
<div className={cellClasses}>
|
|
|
|
|
<TooltipWrapper
|
|
|
|
|
tipContent={softwareAlreadyAddedTipContent(
|
|
|
|
|
softwareTitleId,
|
|
|
|
|
teamId?.toString()
|
|
|
|
|
)}
|
|
|
|
|
disableTooltip={!softwareTitleId}
|
|
|
|
|
position="top"
|
|
|
|
|
underline={false}
|
|
|
|
|
showArrow
|
|
|
|
|
clickable
|
|
|
|
|
tipOffset={10}
|
|
|
|
|
>
|
|
|
|
|
<Icon name="success" />
|
|
|
|
|
</TooltipWrapper>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<div className={cellClasses}>
|
2025-04-16 13:56:09 +00:00
|
|
|
<Button variant="pill" onClick={onClick}>
|
2025-03-21 13:33:06 +00:00
|
|
|
Add
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default InstallerActionCell;
|