Total Complexity | 2 |
Complexity/F | 0 |
Lines of Code | 31 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 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 |