Loaded version of selected server and created component to filter content based on that version

This commit is contained in:
Alejandro Celaya
2019-10-05 10:20:33 +02:00
parent 67a23bfe33
commit 4120d09220
11 changed files with 71 additions and 21 deletions

19
src/utils/ForVersion.js Normal file
View File

@@ -0,0 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
import { compare } from 'compare-versions';
import { isEmpty } from 'ramda';
const propTypes = {
minVersion: PropTypes.string.isRequired,
currentServerVersion: PropTypes.string.isRequired,
children: PropTypes.node.isRequired,
};
const ForVersion = ({ minVersion, currentServerVersion, children }) =>
isEmpty(currentServerVersion) || compare(minVersion, currentServerVersion, '>')
? null
: <React.Fragment>{children}</React.Fragment>;
ForVersion.propTypes = propTypes;
export default ForVersion;