2019-10-05 11:20:33 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { isEmpty } from 'ramda';
|
2019-10-05 12:03:17 +03:00
|
|
|
import { compareVersions } from './utils';
|
2019-10-05 11:20:33 +03:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
minVersion: PropTypes.string.isRequired,
|
|
|
|
currentServerVersion: PropTypes.string.isRequired,
|
|
|
|
children: PropTypes.node.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
const ForVersion = ({ minVersion, currentServerVersion, children }) =>
|
2019-10-05 12:03:17 +03:00
|
|
|
isEmpty(currentServerVersion) || compareVersions(currentServerVersion, '<', minVersion)
|
2019-10-05 11:20:33 +03:00
|
|
|
? null
|
|
|
|
: <React.Fragment>{children}</React.Fragment>;
|
|
|
|
|
|
|
|
ForVersion.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default ForVersion;
|