2019-11-01 04:17:16 +07:00
|
|
|
import React, { useContext } from 'react';
|
2019-03-28 05:39:06 +07:00
|
|
|
|
2019-11-01 04:17:16 +07:00
|
|
|
import { DetailContext } from '../../pages/Version';
|
2019-10-06 23:30:05 +07:00
|
|
|
import Avatar from '../../muiComponents/Avatar';
|
2019-10-13 03:26:56 +07:00
|
|
|
import List from '../../muiComponents/List';
|
2019-10-08 03:19:18 +07:00
|
|
|
import npm from '../Install/img/npm.svg';
|
2019-10-31 14:12:18 +07:00
|
|
|
import ListItemText from '../../muiComponents/ListItemText';
|
|
|
|
import Grid from '../../muiComponents/Grid';
|
2019-10-06 23:30:05 +07:00
|
|
|
|
2019-10-13 02:41:42 +07:00
|
|
|
import { StyledText, EngineListItem } from './styles';
|
2019-03-28 05:39:06 +07:00
|
|
|
import node from './img/node.png';
|
|
|
|
|
2019-11-01 04:17:16 +07:00
|
|
|
const Engine: React.FC = () => {
|
|
|
|
const { packageMeta } = useContext(DetailContext);
|
2019-03-28 05:39:06 +07:00
|
|
|
|
2019-11-01 04:17:16 +07:00
|
|
|
const engines = packageMeta && packageMeta.latest && packageMeta.latest.engines;
|
2019-03-28 05:39:06 +07:00
|
|
|
|
2019-11-01 04:17:16 +07:00
|
|
|
if (!engines || (!engines.node && !engines.npm)) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-03-28 05:39:06 +07:00
|
|
|
|
2019-11-01 04:17:16 +07:00
|
|
|
/* eslint-disable react/jsx-max-depth */
|
|
|
|
return (
|
|
|
|
<Grid container={true}>
|
|
|
|
{engines.node && (
|
|
|
|
<Grid item={true} xs={6}>
|
|
|
|
<List subheader={<StyledText variant={'subtitle1'}>{'node JS'}</StyledText>}>
|
|
|
|
<EngineListItem button={true}>
|
|
|
|
<Avatar src={node} />
|
|
|
|
<ListItemText primary={engines.node} />
|
|
|
|
</EngineListItem>
|
|
|
|
</List>
|
|
|
|
</Grid>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{engines.npm && (
|
|
|
|
<Grid item={true} xs={6}>
|
|
|
|
<List subheader={<StyledText variant={'subtitle1'}>{'NPM version'}</StyledText>}>
|
|
|
|
<EngineListItem button={true}>
|
|
|
|
<Avatar src={npm} />
|
|
|
|
<ListItemText primary={engines.npm} />
|
|
|
|
</EngineListItem>
|
|
|
|
</List>
|
|
|
|
</Grid>
|
|
|
|
)}
|
|
|
|
</Grid>
|
|
|
|
);
|
|
|
|
/* eslint-enable react/jsx-max-depth */
|
|
|
|
};
|
2019-03-28 05:39:06 +07:00
|
|
|
|
|
|
|
export default Engine;
|