0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00

feat: improve "Current Tags" version list (#3401)

This commit is contained in:
Marc Bernard 2022-09-28 01:26:18 -04:00 committed by GitHub
parent 2c0d5ceab8
commit d4019f6349
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 7 deletions

View file

@ -0,0 +1,5 @@
---
'@verdaccio/ui-theme': patch
---
Add links to "Current Tags" and sort them in descending order

View file

@ -52,7 +52,7 @@
},
"versions": {
"current-tags": "Current Tags",
"version-history": "Version history",
"version-history": "Version History",
"not-available": "Not available"
},
"package": {

View file

@ -21,10 +21,10 @@ const Versions: React.FC = () => {
return (
<>
{distTags && Object.keys(distTags).length > 0 && (
{distTags && Object.keys(distTags).length > 0 && packageName && (
<>
<StyledText variant="subtitle1">{t('versions.current-tags')}</StyledText>
<VersionsTagList tags={distTags} />
<VersionsTagList packageName={packageName} tags={distTags} time={time} />
</>
)}
{versions && Object.keys(versions).length > 0 && packageName && (

View file

@ -3,19 +3,26 @@ import ListItem from '@mui/material/ListItem';
import React from 'react';
import { DistTags } from '../../../../../types/packageMeta';
import { ListItemText, Spacer } from './styles';
import { Time } from '../../../../../types/packageMeta';
import { ListItemText, Spacer, StyledLink } from './styles';
interface Props {
tags: DistTags;
packageName: string;
time: Time;
}
const VersionsTagList: React.FC<Props> = ({ tags }) => (
const VersionsTagList: React.FC<Props> = ({ tags, packageName, time }) => (
<List dense={true}>
{Object.keys(tags)
.reverse()
.sort((a, b) => {
return time[tags[a]] < time[tags[b]] ? 1 : time[tags[a]] > time[tags[b]] ? -1 : 0;
})
.map((tag) => (
<ListItem className="version-item" key={tag}>
<StyledLink to={`/-/web/detail/${packageName}/v/${tags[tag]}`}>
<ListItemText>{tag}</ListItemText>
</StyledLink>
<Spacer />
<ListItemText>{tags[tag]}</ListItemText>
</ListItem>