UNPKG

@openshift-assisted/ui-lib

Version:

React component library for the Assisted Installer UI

54 lines 3.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isFormatDiskDisabled = exports.isFormatDiskChecked = exports.isInDiskToBeFormattedList = exports.isInDiskSkipFormattingList = exports.isInstallationDisk = void 0; const tslib_1 = require("tslib"); const react_1 = tslib_1.__importDefault(require("react")); const react_core_1 = require("@patternfly/react-core"); const __1 = require("../.."); const isInstallationDisk = (diskId, installationDiskId) => diskId === installationDiskId; exports.isInstallationDisk = isInstallationDisk; const isInDiskSkipFormattingList = (host, diskId) => { return ((0, __1.trimCommaSeparatedList)(host.skipFormattingDisks ? host.skipFormattingDisks : '') .split(',') .filter((diskSkipFormatting) => diskSkipFormatting === diskId).length > 0); }; exports.isInDiskSkipFormattingList = isInDiskSkipFormattingList; const isInDiskToBeFormattedList = (host, diskId) => { return ((0, __1.trimCommaSeparatedList)(host.disksToBeFormatted ? host.disksToBeFormatted : '') .split(',') .filter((diskToBeFormatted) => diskToBeFormatted === diskId).length > 0); }; exports.isInDiskToBeFormattedList = isInDiskToBeFormattedList; const isInvalidInstallationDisk = (host, diskId, installationDiskId) => { // If it's an installation disk that somehow is set to skip formatting, enable the checkbox to let the user fix it if ((0, exports.isInstallationDisk)(diskId, installationDiskId)) { return (0, exports.isInDiskSkipFormattingList)(host, diskId); } return false; }; const isFormatDiskChecked = (host, diskId, installationDiskId) => { if ((0, exports.isInstallationDisk)(diskId, installationDiskId)) { return !(0, exports.isInDiskSkipFormattingList)(host, diskId); } return (0, exports.isInDiskToBeFormattedList)(host, diskId) && !(0, exports.isInDiskSkipFormattingList)(host, diskId); }; exports.isFormatDiskChecked = isFormatDiskChecked; const isFormatDiskDisabled = (host, diskId, installationDiskId) => { if ((0, exports.isInstallationDisk)(diskId, installationDiskId)) { // If it's an installation disk that somehow is set to skip formatting, enable the checkbox to let the user fix it return !isInvalidInstallationDisk(host, diskId, installationDiskId); } return !(0, exports.isInDiskToBeFormattedList)(host, diskId); }; exports.isFormatDiskDisabled = isFormatDiskDisabled; const onSelectFormattingDisk = (shouldFormatDisk, hostId, diskId, updateDiskSkipFormatting) => { updateDiskSkipFormatting ? updateDiskSkipFormatting(shouldFormatDisk, hostId, diskId) : ''; }; const FormatDiskCheckbox = ({ host, diskId, installationDiskId, index, updateDiskSkipFormatting, }) => { return (react_1.default.createElement(react_core_1.Tooltip, { hidden: !(0, exports.isFormatDiskDisabled)(host, diskId, installationDiskId), content: (0, exports.isFormatDiskChecked)(host, diskId, installationDiskId) ? 'Installation disks are always being formatted.' : 'This disk is not bootable and will not be formatted.' }, react_1.default.createElement(react_core_1.Checkbox, { id: `select-formatted-${host.id}-${index}`, isChecked: (0, exports.isFormatDiskChecked)(host, diskId, installationDiskId), isDisabled: (0, exports.isFormatDiskDisabled)(host, diskId, installationDiskId), onChange: (_event, checked) => onSelectFormattingDisk(checked, host.id, diskId, updateDiskSkipFormatting) }))); }; exports.default = FormatDiskCheckbox; //# sourceMappingURL=FormatDiskCheckbox.js.map