Sha256: cb51ba1aa89d4b84e4a3074899868e6cbf07c23735655be6f47512b6247d60d9

Contents?: true

Size: 1.77 KB

Versions: 82

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

82 entries across 82 versions & 1 rubygems

Version Path
foreman_rh_cloud-8.0.49 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-8.0.48 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-8.0.47 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-8.0.46 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-6.0.45 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-5.0.46 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-5.0.45 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-7.0.46 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-5.0.44 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-7.0.45 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-6.0.44 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-5.0.43 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-4.0.36 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-3.0.33 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-6.0.42.2 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-6.0.42.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-6.0.43 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-5.0.42 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-6.0.42 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
foreman_rh_cloud-5.0.41 webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js