src/servers/helpers/ForServerVersion.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 0

Size

Lines of Code 31
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 26
mnd 2
bc 2
fnc 0
dl 0
loc 31
ccs 10
cts 10
cp 1
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import React from 'react';
2
import PropTypes from 'prop-types';
3
import { serverType } from '../prop-types';
4
import { versionMatch } from '../../utils/helpers/version';
5
6 1
const propTypes = {
7
  minVersion: PropTypes.string,
8
  maxVersion: PropTypes.string,
9
  selectedServer: serverType,
10
  children: PropTypes.node.isRequired,
11
};
12
13 1
const ForServerVersion = ({ minVersion, maxVersion, selectedServer, children }) => {
14 9
  if (!selectedServer) {
15 1
    return null;
16
  }
17
18 8
  const { version } = selectedServer;
19 8
  const matchesVersion = versionMatch(version, { maxVersion, minVersion });
20
21 8
  if (!matchesVersion) {
22 3
    return null;
23
  }
24
25 5
  return <React.Fragment>{children}</React.Fragment>;
26
};
27
28 1
ForServerVersion.propTypes = propTypes;
29
30
export default ForServerVersion;
31