| Total Complexity | 0 |
| Complexity/F | 0 |
| Lines of Code | 41 |
| Function Count | 0 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Coverage | 87.5% |
| Changes | 0 | ||
| 1 | import React from 'react'; |
||
| 2 | import PropTypes from 'prop-types'; |
||
| 3 | import { ListGroup, ListGroupItem } from 'reactstrap'; |
||
| 4 | import { Link } from 'react-router-dom'; |
||
| 5 | import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
||
| 6 | import { faChevronRight as chevronIcon } from '@fortawesome/free-solid-svg-icons'; |
||
| 7 | import { serverType } from './prop-types'; |
||
| 8 | import './ServersListGroup.scss'; |
||
| 9 | |||
| 10 | 3 | const propTypes = { |
|
| 11 | servers: PropTypes.arrayOf(serverType).isRequired, |
||
| 12 | children: PropTypes.node.isRequired, |
||
| 13 | }; |
||
| 14 | |||
| 15 | 3 | const ServerListItem = ({ id, name }) => ( |
|
| 16 | <ListGroupItem tag={Link} to={`/server/${id}/list-short-urls/1`} className="servers-list__server-item"> |
||
| 17 | {name} |
||
| 18 | <FontAwesomeIcon icon={chevronIcon} className="servers-list__server-item-icon" /> |
||
| 19 | </ListGroupItem> |
||
| 20 | ); |
||
| 21 | |||
| 22 | 3 | ServerListItem.propTypes = { |
|
| 23 | id: PropTypes.string, |
||
| 24 | name: PropTypes.string, |
||
| 25 | }; |
||
| 26 | |||
| 27 | 3 | const ServersListGroup = ({ servers, children }) => ( |
|
| 28 | 4 | <React.Fragment> |
|
| 29 | <h5>{children}</h5> |
||
| 30 | {servers.length > 0 && ( |
||
| 31 | <ListGroup className="servers-list__list-group mt-md-3"> |
||
| 32 | 2 | {servers.map(({ id, name }) => <ServerListItem key={id} id={id} name={name} />)} |
|
| 33 | </ListGroup> |
||
| 34 | )} |
||
| 35 | </React.Fragment> |
||
| 36 | ); |
||
| 37 | |||
| 38 | 3 | ServersListGroup.propTypes = propTypes; |
|
| 39 | |||
| 40 | export default ServersListGroup; |
||
| 41 |