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:
parent
2c0d5ceab8
commit
d4019f6349
4 changed files with 19 additions and 7 deletions
5
.changeset/sour-maps-live.md
Normal file
5
.changeset/sour-maps-live.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@verdaccio/ui-theme': patch
|
||||
---
|
||||
|
||||
Add links to "Current Tags" and sort them in descending order
|
|
@ -52,7 +52,7 @@
|
|||
},
|
||||
"versions": {
|
||||
"current-tags": "Current Tags",
|
||||
"version-history": "Version history",
|
||||
"version-history": "Version History",
|
||||
"not-available": "Not available"
|
||||
},
|
||||
"package": {
|
||||
|
|
|
@ -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 && (
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue