Completed
Push — master ( 6ac893...01672b )
by Alejandro
22s queued 10s
created

src/servers/ServersListGroup.js

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 41
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 0
eloc 35
mnd 0
bc 0
fnc 0
dl 0
loc 41
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
ccs 7
cts 8
cp 0.875
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