Sha256: cb51ba1aa89d4b84e4a3074899868e6cbf07c23735655be6f47512b6247d60d9

Contents?: true

Size: 1.77 KB

Versions: 81

Compression:

Stored size: 1.77 KB

Contents

import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Alert, AlertActionCloseButton } from '@patternfly/react-core';
import { translate as __ } from 'foremanReact/common/I18n';

export const SettingsWarning = ({
  autoUpload,
  hostObfuscation,
  isCloudConnector,
}) => {
  const [showUploadWarning, setShowUploadWarning] = useState(true);
  const [showObfuscationWarning, setShowObfuscationWarning] = useState(true);
  if (!isCloudConnector || (!showUploadWarning && !showObfuscationWarning)) {
    return null;
  }
  if (autoUpload && !hostObfuscation) {
    return null;
  }

  const alerts = [];
  if (!autoUpload && showUploadWarning) {
    alerts.push(
      <Alert
        key="auto-upload"
        variant="warning"
        title={__(
          "Cloud Connector has been configured however the inventory auto-upload is disabled, it's recommended to enable it"
        )}
        actionClose={
          <AlertActionCloseButton onClose={() => setShowUploadWarning(false)} />
        }
      />
    );
  }
  if (hostObfuscation && showObfuscationWarning) {
    alerts.push(
      <Alert
        key="obfuscating-host"
        variant="warning"
        title={__(
          "Cloud Connector has been configured however obfuscating host names setting is enabled, it's recommended to disable it"
        )}
        actionClose={
          <AlertActionCloseButton
            onClose={() => setShowObfuscationWarning(false)}
          />
        }
      />
    );
  }
  return <div className="settings-alert">{alerts}</div>;
};

SettingsWarning.propTypes = {
  autoUpload: PropTypes.bool,
  hostObfuscation: PropTypes.bool,
  isCloudConnector: PropTypes.bool,
};

SettingsWarning.defaultProps = {
  autoUpload: false,
  hostObfuscation: false,
  isCloudConnector: false,
};

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.59 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-11.0.2 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-11.0.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-11.0.0 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-9.0.58 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-10.0.2 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-9.0.57 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-10.0.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-9.0.56 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-9.0.55 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-9.0.54 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-9.0.53 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-9.0.52 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-8.0.52 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-9.0.51 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-8.0.51 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-7.0.48 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-7.0.47 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-8.0.50 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-8.0.49 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js