import React from 'react'; import PropTypes from 'prop-types'; import { Button } from 'patternfly-react'; import { translate as __ } from 'foremanReact/common/I18n'; import SnapshotFormModal from './components/SnapshotFormModal'; import useSnapshotFormModal from './components/SnapshotFormModal/useSnapshotFormModal'; import SnapshotList from './components/SnapshotList/SnapshotList'; import './snapshotManagement.scss'; const SnapshotManagement = ({ canCreate, host, ...props }) => { const children = []; const { setModalOpen, setModalClosed } = useSnapshotFormModal(); const onCreateClick = () => { setModalOpen(); }; const allowedHostAttr = ['id', 'name']; const filteredHost = Object.keys(host) .filter(key => allowedHostAttr.includes(key)) .reduce( (obj, key) => ({ ...obj, [key]: host[key], }), {} ); if (canCreate) { children.push( ); children.push( ); } children.push( ); return
{children}
; }; SnapshotManagement.propTypes = { host: PropTypes.shape({ id: PropTypes.number.isRequired, name: PropTypes.string.isRequired, }).isRequired, canCreate: PropTypes.bool, canUpdate: PropTypes.bool, canRevert: PropTypes.bool, canDelete: PropTypes.bool, capabilities: PropTypes.shape({ editSnapshotName: PropTypes.bool, limitSnapshotNameFormat: PropTypes.bool, }), }; SnapshotManagement.defaultProps = { canCreate: false, canUpdate: false, canRevert: false, canDelete: false, capabilities: { editSnapshotName: true, limitSnapshotNameFormat: false, }, }; export default SnapshotManagement;