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( setShowUploadWarning(false)} /> } /> ); } if (hostObfuscation && showObfuscationWarning) { alerts.push( setShowObfuscationWarning(false)} /> } /> ); } return
{alerts}
; }; SettingsWarning.propTypes = { autoUpload: PropTypes.bool, hostObfuscation: PropTypes.bool, isCloudConnector: PropTypes.bool, }; SettingsWarning.defaultProps = { autoUpload: false, hostObfuscation: false, isCloudConnector: false, };