2024-05-09 21:44:50 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import { InjectedRouter } from "react-router";
|
|
|
|
|
|
2024-05-10 15:18:24 +00:00
|
|
|
import Icon from "components/Icon";
|
|
|
|
|
|
2024-05-09 21:44:50 +00:00
|
|
|
import SoftwareIcon from "pages/SoftwarePage/components/icons/SoftwareIcon";
|
|
|
|
|
|
|
|
|
|
import LinkCell from "../LinkCell";
|
|
|
|
|
|
|
|
|
|
const baseClass = "software-name-cell";
|
|
|
|
|
|
|
|
|
|
interface ISoftwareNameCellProps {
|
|
|
|
|
name: string;
|
|
|
|
|
source: string;
|
|
|
|
|
path?: string;
|
|
|
|
|
router?: InjectedRouter;
|
2024-05-10 15:18:24 +00:00
|
|
|
hasPackage?: boolean;
|
2024-05-09 21:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SoftwareNameCell = ({
|
|
|
|
|
name,
|
|
|
|
|
source,
|
|
|
|
|
path,
|
|
|
|
|
router,
|
2024-05-10 15:18:24 +00:00
|
|
|
hasPackage = false,
|
2024-05-09 21:44:50 +00:00
|
|
|
}: 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} />
|
|
|
|
|
<span className="software-name">{name}</span>
|
2024-05-10 15:18:24 +00:00
|
|
|
{hasPackage && (
|
|
|
|
|
<Icon name="install" className={`${baseClass}__install-icon`} />
|
|
|
|
|
)}
|
2024-05-09 21:44:50 +00:00
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SoftwareNameCell;
|