1
0
mirror of https://github.com/SomboChea/ui synced 2024-11-04 21:54:30 +07:00
verdaccio-ui/src/components/Engines/Engines.tsx

52 lines
1.5 KiB
TypeScript
Raw Normal View History

import React, { useContext } from 'react';
2019-03-28 05:39:06 +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';
import npm from '../Install/img/npm.svg';
import ListItemText from '../../muiComponents/ListItemText';
import Grid from '../../muiComponents/Grid';
2019-10-06 23:30:05 +07:00
import { StyledText, EngineListItem } from './styles';
2019-03-28 05:39:06 +07:00
import node from './img/node.png';
const Engine: React.FC = () => {
const { packageMeta } = useContext(DetailContext);
2019-03-28 05:39:06 +07:00
const engines = packageMeta && packageMeta.latest && packageMeta.latest.engines;
2019-03-28 05:39:06 +07:00
if (!engines || (!engines.node && !engines.npm)) {
return null;
}
2019-03-28 05:39:06 +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;