2023-02-23 00:35:26 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import ReactTooltip from "react-tooltip";
|
2023-06-05 15:52:57 +00:00
|
|
|
import { uniqueId } from "lodash";
|
|
|
|
|
|
|
|
|
|
import Icon from "components/Icon";
|
|
|
|
|
import TextCell from "components/TableContainer/DataTable/TextCell";
|
2023-06-06 14:52:10 +00:00
|
|
|
import {
|
|
|
|
|
FLEET_FILEVAULT_PROFILE_DISPLAY_NAME,
|
2023-11-20 21:35:46 +00:00
|
|
|
ProfileOperationType,
|
2023-06-06 14:52:10 +00:00
|
|
|
} from "interfaces/mdm";
|
2023-06-05 15:52:57 +00:00
|
|
|
|
2023-10-06 22:04:33 +00:00
|
|
|
import {
|
|
|
|
|
isMdmProfileStatus,
|
2023-10-12 15:57:39 +00:00
|
|
|
OsSettingsTableStatusValue,
|
2023-11-07 14:58:08 +00:00
|
|
|
} from "../OSSettingsTableConfig";
|
2023-11-20 21:35:46 +00:00
|
|
|
import TooltipContent from "./components/Tooltip/TooltipContent";
|
|
|
|
|
import {
|
|
|
|
|
PROFILE_DISPLAY_CONFIG,
|
|
|
|
|
ProfileDisplayOption,
|
|
|
|
|
WINDOWS_DISK_ENCRYPTION_DISPLAY_CONFIG,
|
|
|
|
|
} from "./helpers";
|
2023-02-23 00:35:26 +00:00
|
|
|
|
2023-11-07 14:58:08 +00:00
|
|
|
const baseClass = "os-setting-status-cell";
|
2023-02-23 00:35:26 +00:00
|
|
|
|
2023-11-07 14:58:08 +00:00
|
|
|
interface IOSSettingStatusCellProps {
|
2023-10-12 15:57:39 +00:00
|
|
|
status: OsSettingsTableStatusValue;
|
2023-11-20 21:35:46 +00:00
|
|
|
operationType: ProfileOperationType | null;
|
2023-06-06 14:52:10 +00:00
|
|
|
profileName: string;
|
2023-02-23 00:35:26 +00:00
|
|
|
}
|
2023-06-05 15:52:57 +00:00
|
|
|
|
2023-11-07 14:58:08 +00:00
|
|
|
const OSSettingStatusCell = ({
|
2023-02-23 00:35:26 +00:00
|
|
|
status,
|
|
|
|
|
operationType,
|
2023-06-05 15:52:57 +00:00
|
|
|
profileName = "",
|
2023-11-07 14:58:08 +00:00
|
|
|
}: IOSSettingStatusCellProps) => {
|
2023-10-06 22:04:33 +00:00
|
|
|
let displayOption: ProfileDisplayOption = null;
|
|
|
|
|
|
|
|
|
|
// windows hosts do not have an operation type at the moment and their display options are
|
|
|
|
|
// different than mac hosts.
|
|
|
|
|
if (!operationType && isMdmProfileStatus(status)) {
|
|
|
|
|
displayOption = WINDOWS_DISK_ENCRYPTION_DISPLAY_CONFIG[status];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (operationType) {
|
|
|
|
|
displayOption = PROFILE_DISPLAY_CONFIG[operationType]?.[status];
|
|
|
|
|
}
|
2023-06-06 14:52:10 +00:00
|
|
|
|
2023-06-05 15:52:57 +00:00
|
|
|
const isDeviceUser = window.location.pathname
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.includes("/device/");
|
2023-02-23 00:35:26 +00:00
|
|
|
|
2023-06-06 14:52:10 +00:00
|
|
|
const isDiskEncryptionProfile =
|
|
|
|
|
profileName === FLEET_FILEVAULT_PROFILE_DISPLAY_NAME;
|
|
|
|
|
|
2023-10-06 22:04:33 +00:00
|
|
|
if (displayOption) {
|
|
|
|
|
const { statusText, iconName, tooltip } = displayOption;
|
2023-06-05 15:52:57 +00:00
|
|
|
const tooltipId = uniqueId();
|
2023-02-23 00:35:26 +00:00
|
|
|
return (
|
|
|
|
|
<span className={baseClass}>
|
|
|
|
|
<Icon name={iconName} />
|
2023-06-05 15:52:57 +00:00
|
|
|
{tooltip ? (
|
2023-02-23 00:35:26 +00:00
|
|
|
<>
|
|
|
|
|
<span
|
|
|
|
|
className="tooltip tooltip__tooltip-icon"
|
|
|
|
|
data-tip
|
|
|
|
|
data-for={tooltipId}
|
|
|
|
|
data-tip-disable={false}
|
|
|
|
|
>
|
|
|
|
|
{statusText}
|
|
|
|
|
</span>
|
|
|
|
|
<ReactTooltip
|
|
|
|
|
place="top"
|
|
|
|
|
effect="solid"
|
|
|
|
|
backgroundColor="#3e4771"
|
|
|
|
|
id={tooltipId}
|
|
|
|
|
data-html
|
|
|
|
|
>
|
2023-06-05 15:52:57 +00:00
|
|
|
<span className="tooltip__tooltip-text">
|
2023-06-06 14:52:10 +00:00
|
|
|
{status !== "action_required" ? (
|
|
|
|
|
<TooltipContent
|
|
|
|
|
innerContent={tooltip}
|
|
|
|
|
innerProps={{
|
|
|
|
|
isDiskEncryptionProfile,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<TooltipContent
|
|
|
|
|
innerContent={tooltip}
|
|
|
|
|
innerProps={{ isDeviceUser, profileName }}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2023-06-05 15:52:57 +00:00
|
|
|
</span>
|
2023-02-23 00:35:26 +00:00
|
|
|
</ReactTooltip>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
statusText
|
|
|
|
|
)}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
// graceful error - this state should not be reached based on the API spec
|
|
|
|
|
return <TextCell value="Unrecognized" />;
|
|
|
|
|
};
|
2023-11-07 14:58:08 +00:00
|
|
|
export default OSSettingStatusCell;
|