Total Complexity | 0 |
Complexity/F | 0 |
Lines of Code | 37 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | import React from 'react'; |
||
2 | import { faMinusCircle as deleteIcon } from '@fortawesome/free-solid-svg-icons'; |
||
3 | import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
||
4 | import PropTypes from 'prop-types'; |
||
5 | import { useToggle } from '../utils/helpers/hooks'; |
||
6 | import { serverType } from './prop-types'; |
||
7 | |||
8 | 1 | const propTypes = { |
|
9 | server: serverType, |
||
10 | className: PropTypes.string, |
||
11 | textClassName: PropTypes.string, |
||
12 | children: PropTypes.node, |
||
13 | }; |
||
14 | |||
15 | 1 | const DeleteServerButton = (DeleteServerModal) => { |
|
16 | 2 | const DeleteServerButtonComp = ({ server, className, children, textClassName }) => { |
|
17 | 3 | const [ isModalOpen, , showModal, hideModal ] = useToggle(); |
|
18 | |||
19 | 3 | return ( |
|
20 | <React.Fragment> |
||
21 | <span className={className} onClick={showModal}> |
||
22 | {!children && <FontAwesomeIcon icon={deleteIcon} />} |
||
23 | <span className={textClassName}>{children || 'Remove this server'}</span> |
||
24 | </span> |
||
25 | |||
26 | <DeleteServerModal server={server} isOpen={isModalOpen} toggle={hideModal} /> |
||
27 | </React.Fragment> |
||
28 | ); |
||
29 | }; |
||
30 | |||
31 | 2 | DeleteServerButtonComp.propTypes = propTypes; |
|
32 | |||
33 | 2 | return DeleteServerButtonComp; |
|
34 | }; |
||
35 | |||
36 | export default DeleteServerButton; |
||
37 |