import React, { useState } from 'react'; import PropTypes from 'prop-types'; import { ToggleGroup, ToggleGroupItem, } from '@patternfly/react-core'; import { noop } from 'foremanReact/common/helpers'; import CdnTypeForm from './CdnTypeForm'; import ExportSyncForm from './ExportSyncForm'; import NetworkSyncForm from './NetworkSyncForm'; import CustomCdnTypeForm from './CustomCdnTypeForm'; import './CdnConfigurationForm.scss'; import { CDN, EXPORT_SYNC, CUSTOM_CDN, NETWORK_SYNC, CDN_CONFIGURATION_TYPES } from './CdnConfigurationConstants'; const CdnConfigurationForm = (props) => { const { contentCredentials, cdnConfiguration, onUpdate, } = props; const [type, setType] = useState(cdnConfiguration.type); const updateType = (connectionType) => { if (type !== connectionType) { setType(connectionType); } }; return (
updateType(CDN)} /> updateType(CUSTOM_CDN)} /> updateType(NETWORK_SYNC)} /> updateType(EXPORT_SYNC)} /> { type === NETWORK_SYNC && } { type === CDN && } { type === CUSTOM_CDN && } { type === EXPORT_SYNC && }
); }; CdnConfigurationForm.propTypes = { contentCredentials: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.number, name: PropTypes.string, })), cdnConfiguration: PropTypes.shape({ type: PropTypes.string, url: PropTypes.string, username: PropTypes.string, upstream_organization_label: PropTypes.string, upstream_content_view_label: PropTypes.string, upstream_lifecycle_environment_label: PropTypes.string, ssl_ca_credential_id: PropTypes.number, password_exists: PropTypes.bool, }), onUpdate: PropTypes.func, }; CdnConfigurationForm.defaultProps = { contentCredentials: [], cdnConfiguration: {}, onUpdate: noop, }; export default CdnConfigurationForm;