"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const react_core_1 = require("@patternfly/react-core");
const common_1 = require("../../../common");
const ClusterDefaultConfigurationContext_1 = require("../clusterConfiguration/ClusterDefaultConfigurationContext");
const external_link_alt_icon_1 = require("@patternfly/react-icons/dist/js/icons/external-link-alt-icon");
const DateAndTime_1 = require("../../../common/services/DateAndTime");
const api_1 = require("../../../common/api");
const constants_1 = require("../clusterConfiguration/platformIntegration/constants");
const newFeatureSupportLevels_1 = require("../../../common/components/newFeatureSupportLevels");
const PostInstallAlert_1 = tslib_1.__importDefault(require("../../../common/components/clusterDetail/PostInstallAlert"));
const use_feature_1 = require("../../hooks/use-feature");
const ClusterDetailStatusMessages = ({ cluster, showAddHostsInfo, }) => {
    var _a;
    const isSingleClusterFeatureEnabled = (0, use_feature_1.useFeature)('ASSISTED_INSTALLER_SINGLE_CLUSTER_FEATURE');
    const featureSupportLevelContext = (0, newFeatureSupportLevels_1.useNewFeatureSupportLevel)();
    const { inactiveDeletionHours } = (0, ClusterDefaultConfigurationContext_1.useDefaultConfiguration)(['inactiveDeletionHours']);
    const inactiveDeletionDays = Math.round((inactiveDeletionHours || 0) / 24);
    const dateDifference = (0, DateAndTime_1.calculateClusterDateDiff)(inactiveDeletionDays, cluster.installCompletedAt);
    const showAddHostsAlert = Boolean(showAddHostsInfo &&
        api_1.isInOcm &&
        cluster.status === 'installed' &&
        (!(0, common_1.isSNO)(cluster) || featureSupportLevelContext.isFeatureSupported('SINGLE_NODE_EXPANSION')));
    const platformLink = (0, common_1.isClusterPlatformTypeVM)(cluster)
        ? constants_1.ExternalPlatformLinks[(_a = cluster.platform) === null || _a === void 0 ? void 0 : _a.type]
        : '';
    return (react_1.default.createElement(react_core_1.Stack, { hasGutter: true },
        !isSingleClusterFeatureEnabled &&
            typeof inactiveDeletionHours === 'number' &&
            (0, common_1.canDownloadKubeconfig)(cluster.status) && (react_1.default.createElement(react_core_1.StackItem, null,
            react_1.default.createElement(react_core_1.Alert, { variant: "info", isInline: true, title: dateDifference > 0
                    ? `Download and save your kubeconfig file in a safe place. This file will be automatically ` +
                        `deleted from Assisted Installer's service in ${dateDifference} days.`
                    : `Kubeconfig file was automatically deleted ${inactiveDeletionDays} days after installation.` }))),
        showAddHostsAlert && (react_1.default.createElement(react_core_1.StackItem, null,
            react_1.default.createElement(react_core_1.Alert, { variant: "info", isInline: true, "data-testid": "alert-add-hosts", title: react_1.default.createElement("p", null,
                    (0, common_1.isClusterPlatformTypeVM)(cluster)
                        ? 'Add new hosts by using the platform auto-scale feature or manually generating a new Discovery ISO under the "Add hosts" tab on '
                        : 'Add new hosts by generating a new Discovery ISO under your cluster\'s "Add hosts" tab on ',
                    react_1.default.createElement("a", { href: common_1.REDHAT_CONSOLE_OPENSHIFT, target: "_blank", rel: "noopener noreferrer" },
                        "console.redhat.com/openshift ",
                        react_1.default.createElement(external_link_alt_icon_1.ExternalLinkAltIcon, null)),
                    ".") }))),
        platformLink && (react_1.default.createElement(react_core_1.StackItem, null,
            react_1.default.createElement(PostInstallAlert_1.default, { link: platformLink })))));
};
exports.default = ClusterDetailStatusMessages;
//# sourceMappingURL=ClusterDetailStatusMessages.js.map